Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gruber dialect parses content between two tight hr's incorrectly. #106

Closed
anupshinde opened this issue Aug 2, 2013 · 3 comments
Closed

Comments

@anupshinde
Copy link

The stuff between "---" in the headers is not getting rendered - only horizontal lines are created

Why does this occur? Does this automatically convert the stuff into some kind of meta-data? Example below:


---
layout: post    
title: Just another post
something: more
this
and that
and more of that

---

About Me
--------
I'm a programmer 

Output is like:

<hr/><hr/>About Me<h1>I'm a programmer....

The stuff between the first two hrs is missing for some reason I do not understand. Is it considered as document metadata?

I've also posted the same question on stackoverflow:
http://stackoverflow.com/questions/18007857/markdown-rendered-incorrectly-with-npm-markdown

@evilstreak
Copy link
Owner

The content should be rendered into something like:

<hr />
<p>layout: post<br />
title: Just another post something: more this and that</p>
<h2>and more of that</h2>

<h2>About Me</h2>
<p>I'm a programmer</p>

So that's definitely a bug that needs to be looked into.

The default (Gruber) dialect doesn't support any metadata. The Maruku dialect should support metadata, but it's in a different format.

The format you have looks like front-matter. If so, the YAML block would need to be stripped from the document before it's passed to markdown-js to be parsed.

@ashb
Copy link
Collaborator

ashb commented Aug 2, 2013

To expand on Dom's suggestion, here is an example of how to use the Maruku dialect:

var markdown = require('markdown').markdown;

var content = fs.readFileSync(filepath, 'utf8');
var jsonML = markdown.parse(content, "Maruku");

// You might want to add some sanity checking to make sure that attrs is not a
// string or an array - that would signal no document metadata.
var attrs = jsonML[1];

var htmlContent = markdown.toHTML(jsonML);

// You can now look at attrs.title, attrs.layout etc.

@anupshinde
Copy link
Author

@evilstreak Thanks - that text is the frontmatter - i am working on a static-site-generator since wintersmith/docpad dont meet my needs and require too much pre/post processing. I think I can use Maruku dialect for that.

@ashb Thanks for that tip - saved me a lot of time

ashb added a commit that referenced this issue Aug 22, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants