readthedocs/commonmark.py

Support for YAML front-matter

dend opened this issue · 4 comments

dend commented

Currently, when getting the AST for a Markdown file with YAML front-matter, the content is not identified as such.

image

thematic_break is seen first, but after that the closing --- is not properly identified and is seen as part of the header.

Simple test case

import commonmark
parser = commonmark.Parser()
with open('index.md', 'r') as f:
    read_data = f.read()
ast = parser.parse(read_data)

renderer = commonmark.HtmlRenderer()
html = renderer.render(ast)
print(html)

With index.md

---
layout: default
title: Using GeckoView
nav_order: 3
---

# my doc imported from jekyll

We are working on providing detailed usage documentation for all of GeckoView's most popular features. Here is what we have so far.

Generates

<hr />
<h2>layout: default
title: Using GeckoView
nav_order: 3</h2>
<h1>my doc imported from jekyll</h1>

Currently, when getting the AST for a Markdown file with YAML front-matter, the content is not identified as such.

image

thematic_break is seen first, but after that the closing --- is not properly identified and is seen as part of the header.#208

Here is what i implemented for Firefox
https://searchfox.org/mozilla-central/rev/2e355fa82aaa87e8424a9927c8136be184eeb6c7/tools/moztreedocs/__init__.py#127

If a fm header is found, extract the data and inject it in the markdown file