question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for Front Matter?

See original GitHub issue

I have a blog with markdown files generated by Jekyll. They use Markdown files that has a metadata block on top that contains yaml. Is this something that mistune would be willing to support? Jekyll is a very common blog engine, so I think it would be useful to many!

---
id: 29
title: How this website was built
date: 2005-12-20T00:00:36
categories:
  - CSS
---
Hi there early readers!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
quantologycommented, Jun 26, 2020

For posterity, @karlcow 's snippet above is missing a line; the full version is here: https://github.com/lepture/mistune-contrib/blob/master/mistune_contrib/meta.py

@EmilStenstrom let me know if you ended up with a gist of the above, I’m playing around with something similar

1reaction
x2fcommented, Oct 31, 2021

In case it helps other people interested in YAML frontmatter processing: consider using https://github.com/eyeseast/python-frontmatter.

(To clarify, this post does not suggest to change mistune. A user of mistune can use python-frontmatter on the file before invoking mistune.)

Here is a simple example:

import mistune, frontmatter
with open("text.md", "r") as f:
    obj = frontmatter.load(f)
    html = mistune.html(obj.content)
    with open("text.html", "w") as of:
        of.write(html)

Where text.md is something like this:

---
title: Text Title
---
# Some Title
some text
Read more comments on GitHub >

github_iconTop Results From Across the Web

Front Matter - Hugo
Hugo supports four formats for front matter, each with their own identifying tokens. TOML: identified by opening and closing +++ . YAML: identified...
Read more >
Support Front Matter for GitHub Pages · Issue #144
Description. If making markdown files for GitHub Pages, a header in the Front Matter format is needed. It would be nice if this...
Read more >
Front Matter
Front Matter helps with setting up and maintaining cloud infrastructure for scholarly services. Public Cloud Providers. Help with running scholarly ...
Read more >
Front Matter: What it is and Why it is Important | Scribendi
In this article, we define front matter and give examples of what can be included.
Read more >
Front Matter - Article - Formatting - Author Learning Center
Front matter is the content of your book preceding the main body text. Learn what's included in front matter, the sequence, and why...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found