assemble/grunt-assemble

Update? Markdown parsing not working

Closed this issue · 7 comments

Can we get an update to grunt-assemble from at least 0.6?

@ethikz Thanks for the issue! If you're reporting a bug, please be sure to include:

  • The version of assemble you are using.
  • Your assemblefile.js (This can be in a gist)
  • The commandline output. (Screenshot or gist is fine)
  • What you expected to happen instead.

The issue I am having is trying to run markdown inside .hbs but doesn't render as html, just plain text.

When trying to include the markdown in an .hbs file it doesn't compile the md.

{{#markdown}}
        ## Inline Markdown is awesome
        > this is markdown content
        *  useful for simple content
        *  great for blog posts
        *  easier on the eyes than angle brackets
        *  even links look prettier
        ### Pretty links
        [Visit Assemble] (http://github.com/assemble/assemble )
        ### Even Prettier links
        Embed handlebars templates to make them even prettier.
    {{/markdown}}

My assemble file for grunt is:

module.exports = function( grunt ) {
  grunt.config('assemble', {
    options: {
      stage: '<%= stage %>',
      layout: 'default.hbs',
      layoutdir: 'layouts',
      partials: [
        'includes/**/*.hbs'
      ],
      helpers: ['helper-markdown'],
      flatten: true,
      data: 'json/**/*.json'
    },
    index: {
      files: {
        '_build/index.html': ['index.hbs']
      }
    }
  });

  grunt.loadNpmTasks('grunt-assemble');
};

My package.json:

{
  "name": "name",
  "version": "0.1.0",
  "author": "",
  "license": "ISC",
  "main": "Gruntfile.js",
  "directories": {
    "doc": "docs"
  },
  ...
  "dependencies": {
    "grunt": "^0.4.5",
    "time-grunt": "^0.2.10"
  },
  "devDependencies": {
    "autoprefixer": "^6.3.6",
    "build": "^0.1.4",
    "compile": "0.0.2",
    "grunt-assemble": "^0.4.0",
    "grunt-autoprefixer": "^3.0.4",
    "grunt-bless": "^1.0.2",
    "grunt-browser-sync": "^2.2.0",
    "grunt-concurrent": "^2.3.0",
    "grunt-contrib-clean": "^1.0.0",
    "grunt-contrib-concat": "^1.0.1",
    "grunt-contrib-connect": "^1.0.2",
    "grunt-contrib-copy": "^1.0.0",
    "grunt-contrib-imagemin": "^1.0.0",
    "grunt-contrib-jshint": "^1.0.0",
    "grunt-contrib-uglify": "^1.0.1",
    "grunt-contrib-watch": "^1.0.0",
    "grunt-delegate": "^1.0.0",
    "grunt-newer": "^1.2.0",
    "grunt-parallelize": "^1.1.7",
    "grunt-rename": "^0.1.4",
    "grunt-sass": "^1.2.0",
    "grunt-sass-globbing": "^1.5.1",
    "grunt-scss-lint": "^0.3.8",
    "grunt-svgmin": "^3.2.0",
    "handlebars-helper-minify": "^0.1.3",
    "handlebars-helpers": "^0.5.8",
    "helper-moment": "^0.1.0",
    "helper-markdown": "^0.2.1", // can't use since it only supports assemble@0.6.0+
    "jshint-stylish": "^2.2.0",
    "patternpack": "^1.0.5",
    "uglify": "^0.1.5"
  }
}

If I try to update handlebars-helpers it will run but then throws errors like Warning: Missing helper: "extend" Use --force to continue.

doowb commented

@ethikz the current version of grunt-assemble is still using handlebars-helpers@0.5.8 which includes a markdown helper. You don't need to use helper-markdown directly.

If the indentation inside your template is the same as what you posted above, then the markdown helper is probably reading that as a code block and putting it inside a <pre> tag.

Try making sure there isn't any indentation by reducing indentation in or around partials (if being used) or try using handlebars whitespace control.

@doowb Thanks for the quick response. I tried without helper-markdown and it's still the same issue, it doesn't parse the .md inside .hbs and does in fact wrap it in a <pre> tag

To give an example, here is my .hbs with correct indentation:

{{#extend "sub-wrapper-layout"}}
{{#content "body-content"}}

    {{#markdown}}
    ## Inline Markdown is awesome
    > this is markdown content
    *  useful for simple content
    *  great for blog posts
    *  easier on the eyes than angle brackets
    *  even links look prettier
    ### Pretty links
    [Visit Assemble] (http://github.com/assemble/assemble )
    ### Even Prettier links
    Embed handlebars templates to make them even prettier.
    {{/markdown}}

    <div class="grid grid--gutters grid--md">
     ...

Everything is closed obviously

doowb commented

To give an example, here is my .hbs with correct indentation

The markdown content is indented 4 spaces in that example which would tell markdown that it's a code block. Handlebars doesn't remove indentation unless you use the whitespace control characters.

Ohhh so even though it is inside an element it can't be nested like html unless the whitespace control is used?

Consider me informed! Thanks so much for that information.

doowb commented

Yeah, handlebars doesn't look at any of the html elements and will just use whatever string is passed in.