DEV Community

Katie Liu
Katie Liu

Posted on

go-go-web: new front matter parsing feature!

Today I added a new feature to my Open Source project repo, go-go-web, a program that converts TIL posts in .txt or .md format to .html.

Markdown Front Matter Support

Given an .md input file with front matter, my program can convert the file into an .html file with the front matter converted into corresponding HTML metadata.

frontmatter usage

Example

Front matter can be specified in .md input files like so:

markdown input file

Running my program via the command line (for full usage details see GitHub documentation):

command line run

Resulting output .html file with the relevant metadata:

html output file

Inspiration from Docusaurus

In my previous post, I explored the code behind Docusaurus to learn how it was parsing front matter in markdown files. Docusaurus employed a JavaScript based open source parser called gray-matter to do the job.

Similarly, I decided to use a Python based open source parser called python-frontmatter, since my program is written in Python. This parser is also open source and has an MIT license.

My approach is very similar to Docusaurus, except that my program is written in Python and so the parser I used. The parser Docusaurus used was written in JavaScript and returned a JavaScript object with key-value pairs for the front matter. The parser I used returned a Python dictionary of key-value pairs.

Follow-Up Issues

future issues

I have filed some future issues that I will work on in the coming weeks:

Top comments (0)