Skip to content

Instantly share code, notes, and snippets.

@davidbgk
Last active July 8, 2019 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidbgk/b666c5b85ab3d3fd94baef04367ff379 to your computer and use it in GitHub Desktop.
Save davidbgk/b666c5b85ab3d3fd94baef04367ff379 to your computer and use it in GitHub Desktop.
Given a folder containing CommonMark files, turn it into HTML.

Folder2HTML

Goal

Given a folder containing CommonMark files, turn it into HTML.

Requirements

File structure

foo/
  detail.html     # Jinja2 template for detail
  list.html       # …for list
  feed.xml        # …for feed
  2017-01-30.md   # An item to be generated
  hello-world.md  # Another one
  why-not.md      # Filename is not significative
  and so one…

Metadata

Each CommonMark file must have the given metadata elements:

title: A title
url: /bar/a-title/
date: 2017-01-30

And then the content.

Parsing with the metadata extension? The thread about that on CommonMark has no conclusion…

Usage

Generate HTML

$ python3 foo

Launch local server

$ python3 -m http.server

Browse it!

$ open http://localhost:8000/bar/a-title/

Discussion

  • which URL for the list?
  • deploy with now? git*-pages? quid of domains?
  • use pex to ease Python execution?
  • add search with lunrjs which works even with i18n?
@davidbgk
Copy link
Author

davidbgk commented Jul 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment