mixu / markdown-styles

Markdown to static HTML generator and multiple CSS themes for Markdown
1.85k stars 251 forks source link

Metadata handling weirdo #39

Closed csandor closed 7 years ago

csandor commented 8 years ago

I have this in my index.md:

title: "some title"
version: "2.0.0"
authors: "xy"
locationref: "place"

---
# my markdown
positive

My template like this:

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui">
    <title>{{title}}</title>
    <link type="text/css" rel="stylesheet" href="{{asset 'css/github-markdown.css'}}">
    <link type="text/css" rel="stylesheet" href="{{asset 'css/pilcrow.css'}}">
    <link type="text/css" rel="stylesheet" href="{{asset 'css/hljs-github.min.css'}}"/>
  </head>
  <body>
    <article class="markdown-body">
      {{title}}
      {{version}}
      {{authors}}
      {{locationref}}
      {{~> content}}
    </article>
  </body>
</html>

Rendered html like this:


<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui">
    <title>locationref: &quot;place&quot;</title>
    <link type="text/css" rel="stylesheet" href="assets/css/github-markdown.css">
    <link type="text/css" rel="stylesheet" href="assets/css/pilcrow.css">
    <link type="text/css" rel="stylesheet" href="assets/css/hljs-github.min.css"/>
  </head>
  <body>
    <article class="markdown-body">
      locationref: &quot;place&quot;

      <p>title: &quot;some title&quot;
version: &quot;2.0.0&quot;
authors: &quot;xy&quot;</p>
<h2 id="locationref-place-"><a class="header-link" href="#locationref-place-"></a>locationref: &quot;place&quot;</h2>
<h1 id="my-markdown"><a class="header-link" href="#my-markdown"></a>my markdown</h1>
<p>positive</p>
    </article>
  </body>
</html>

It seems I'm not getting the idea of embedded metadata on the page. I tried also JSON format, but it did not care about it at all, but inserted it directly into the html.

mixu commented 8 years ago

ahh looks like a line endings issue - I'm guessing you are on Windows. Looks like Unix line endings (\n) will work correctly but the metadata parsing doesn't take into account Windows-style line endings (\r\n). If you have a bit of time I'd love a patch.

csandor commented 8 years ago

Submitted PR to the markdown-stream-utils. Thanks for looking into it!

mixu commented 7 years ago

aaaand finally merged and bumped, fixed in v3.1.9