Skip to content

Instantly share code, notes, and snippets.

@So-Cool
So-Cool / reference-markdown-metadata-from-jinja-template.py
Created January 7, 2019 11:41 — forked from glombard/reference-markdown-metadata-from-jinja-template.py
How to use Markdown as a filter in a Jinja2 template, and then extract the Markdown Meta property directly from the template. Assuming you want to use the Meta-data value before rendering the converted Markdown content (e.g. in the html head), the trick is to render the markdown first, save it to a variable (html_content in this example) using a…
from pprint import pprint
import jinja2
import markdown
HTML_TEMPLATE = """{% macro get_html() %}
{{ content | markdown }}
{% endmacro %}
{% set html_content = get_html() %}
Title from Markdown meta-data: {{ get_title() }}
@So-Cool
So-Cool / MarkdownExample.md
Created October 13, 2015 15:45
Markdown Example

Welcome to Marxico

@(Sample notebook)[Marxico|Manual|Markdown]

Marxico is a delicate Markdown editor for Evernote. With reliable storage and sync powered by Evernote, Marxico offers greate writing experience.

  • Versatile - supporting code highlight, LaTex & flow charts, inserting images by all means.
  • Exquisite - neat but powerful editor, featuring offline docs, shortcuts, live preview.
  • Sophisticated - deeply integrated with Evernote, supporting notebook & tags, two-way bind editing.
@So-Cool
So-Cool / extractor.py
Last active January 23, 2024 19:53
Prettify ugly MS Word HTML
import os
import sys
from bs4 import BeautifulSoup
if len(sys.argv) != 3:
sys.exit("First argument is HTML second is an output directory.")
with open(sys.argv[1], "r") as html:
soup = BeautifulSoup(html.read(), "html.parser")