Git Product home page Git Product logo

Comments (20)

jonschlinkert avatar jonschlinkert commented on August 15, 2024

Since assemble.options can be passed into helpers now, a user should have the ability to set Marked.js options in the Gruntfile. My suggestion is that these options be namespaced in the options.marked object:

assemble: {
  options: {
    marked: {
      gfm: true,
      tables: true,
      breaks: false,
      pedantic: false,
      sanitize: true,
      silent: false,
      smartLists: true,
      langPrefix: 'language',
    }
  }
}

I tried to implement this but even when I tried to hardcode the options in the {{markdown}} and {{md}} helpers whatever I do is overridden somewhere else. @doowb can you try to get this working properly?

from handlebars-helpers.

doowb avatar doowb commented on August 15, 2024

@jonschlinkert I'll take a look.

from handlebars-helpers.

jonschlinkert avatar jonschlinkert commented on August 15, 2024

ping @doowb

from handlebars-helpers.

jonschlinkert avatar jonschlinkert commented on August 15, 2024

assemble/assemble#75

from handlebars-helpers.

jonschlinkert avatar jonschlinkert commented on August 15, 2024

@doowb so these options are able to be set in the task options now? is this ready to be documented?

from handlebars-helpers.

jonschlinkert avatar jonschlinkert commented on August 15, 2024

btw, make sure you uninstall grunt-contrib-coffee and reinstall it. you're compiling with an order version.

from handlebars-helpers.

devert avatar devert commented on August 15, 2024

Did this fix make it into the 0.4.2 release?

from handlebars-helpers.

jonschlinkert avatar jonschlinkert commented on August 15, 2024

It should have, assemble always pulls down the latest from this repo. please let me know if you have any issue though

from handlebars-helpers.

devert avatar devert commented on August 15, 2024

Still wasn't able to accomplish the goal of changing the langPrefix via an option in my Gruntfile. Tried this...

assemble: {
  options: {
    marked: {
      langPrefix: 'language-',
    }
  }
}

... but code blocks still have a class of 'lang-*' on them.

from handlebars-helpers.

doowb avatar doowb commented on August 15, 2024

@devert my bad... I moved the line to set the options to the correct place, but I forgot to specify that the marked options are located in the marked object.

@jonschlinkert I think we still need to bump the version and push to npm for the changes to make it to assemble.

from handlebars-helpers.

devert avatar devert commented on August 15, 2024

Updated to the lastest 0.4.3 release and I am still unable to configure the Marked.js options as it describes in the documentation. I applied the following marked options in my Gruntfile, but none of these options appear to have any affect on the compiled output.

    assemble: {
      options: {
        marked: {
          gfm: true,
          highlight: function (lang, code) {
            return hljs.highlightAuto(lang, code).value;
          },
          tables: true,
          breaks: false,
          pedantic: false,
          sanitize: false,
          smartLists: false,
          smartypants: false,
          langPrefix: 'language-'
        }
      }
    }

from handlebars-helpers.

jonschlinkert avatar jonschlinkert commented on August 15, 2024

@devert sorry you're having issues with this still. It seems to be working for me. Out of curiosity, assuming that you are using that exact configuration, are you requiring hljs somewhere? e.g.:

module.exports = function(grunt) {

  var hljs = require('highlight.js');

  // Project configuration.
  grunt.initConfig({

    // Templates
    assemble: {
      options: {
        marked: {
          gfm: true,
          highlight: function (lang, code) {
            return hljs.highlightAuto(lang, code).value;
          },
          tables: true,
          breaks: false,
          pedantic: false,
          sanitize: false,
          smartLists: false,
          smartypants: false,
          langPrefix: 'language-'
        }
      }
      ...
    }
  });

  // Load npm and local plugins.
  grunt.loadNpmTasks('assemble');

  // Default task to be run.
  grunt.registerTask('default', ['assemble']);
};

from handlebars-helpers.

devert avatar devert commented on August 15, 2024

@jonschlinkert Tried including requiring hljs as you specified above. Did not seem to make a difference unfortunately. I also tried removing the highlight option entirely. Still not working. I am using the latest node v0.10.15 and the latest grunt v0.4.1. For reference, here is my entire config options for assemble:

assemble: {
  options: {
    marked: {
      langPrefix: 'language-'
    }
  },
  build: {
    options: {
      flatten: true,
      layoutdir: 'src/templates/layouts',
      layout: 'default.hbs',
      partials: ['src/templates/partials/*.hbs']
    },
    files: [
      { expand: true, cwd: 'src/templates/pages', src: ['*.hbs'], dest: '<%= proj.buildDir %>' },
    ]
  }
}

I am including external markdown files using the {{{md}}} helper.

from handlebars-helpers.

devert avatar devert commented on August 15, 2024

@jonschlinkert I created a quick project to test both the {{#markdown}} and {{{md}}} helpers separate from the project I am working on. Available here: https://github.com/devert/assemble-markdown-test

This is still not working for me even in this test project. Strangely, it doesn't even seem to compile the code blocks with highlight.js either. When built they look like...

<pre><code class="lang-javascript">function hello2 () {
    console.log(&#39;oh hai again!&#39;);  
};</code></pre>

... without any of the <span> tags that provide syntax coloring.

As another note I am on Windows 7, not that it should necessarily make a difference.

from handlebars-helpers.

doowb avatar doowb commented on August 15, 2024

@devert have you checked to make sure the correct version of handlebars-helpers is getting pulled in from npm?
Look in \node_modules\assemble\node_modules\assemble-handlebars\node_modules\handlebars-helpers\package.json.

It should be v0.2.9. If it's not, I would do npm cache clear and delete the node_modules folder and try npm i again.

I know that path is a long one and we're working on cleaning it up so these modules are side-by-side dependencies instead of nested like this.

from handlebars-helpers.

devert avatar devert commented on August 15, 2024

@doowb Confirmed that handlebars-helpers module is v0.2.9 already.

from handlebars-helpers.

jonschlinkert avatar jonschlinkert commented on August 15, 2024

Sorry @devert, I'm looking into this as well - and this evening I'll take a look at the project you linked to. I wanted this to be fixed myself, because I also customize the options. But it seems to be working for me. view the source for one of the code examples here: http://assemble.io/docs/options-collections.html. The classes appear to be how I defined them in the options (here: https://github.com/assemble/assemble-docs/blob/master/Gruntfile.js#L53). In fact, I still have all of the markdown options in the Gruntfile because I was testing them per this ticket.

just in case, did you try installing highlight.js directly in node_modules, rather than depending on the nested one that the helpers depend on?

(@doowb this is another good use case for having a defaults.yml/json, so we can get all defaults aggregated making it easier to run tests against them with different scenarios.)

from handlebars-helpers.

devert avatar devert commented on August 15, 2024

@jonschlinkert No worries Jon. Really appreciate how responsive you guys are with addressing these issues. I did try install highlight.js as a top-level dependency and requiring it in the Gruntfile. It did not have any affect unfortunately. Very strange.

from handlebars-helpers.

devert avatar devert commented on August 15, 2024

@jonschlinkert and @doowb. Just wanted to confirm that I have tested the latest v0.4.4 of Assemble with my test project mentioned above and configuring markdown options appears to be working correcly now. I am able to successfully change the langPrefix and the code blocks are being compiled properly.

Thanks!

from handlebars-helpers.

jonschlinkert avatar jonschlinkert commented on August 15, 2024

awesome, sorry this took so long for us to fix.

from handlebars-helpers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.