Skip to content

Instantly share code, notes, and snippets.

import mistune
def main(meta, content, classes=[]):
"""Adding classes to a `<p>`.
"""
html = mistune.markdown(content)
return html.replace("<p>", '<p class="{0}">'.format(" ".join(classes)))
@jdkato
jdkato / alert.py
Last active February 17, 2019 23:45
import mistune
def main(meta, content, level):
"""A Bootstrap-style alert.
"""
# We want to be able to write our body content in Markdown,
# so we use the `mistune` library to convert it to HTML.
html = mistune.markdown(content)
return '<div class="alert alert-{0}" role="alert">{1}</div>'.format(level, html)
def main(meta, arg1, arg2):
"""An example directive.
These functions return a string that replaces the original
directive in the Markdown source file.
`meta` is a dictionary created from front matter (`{}` by
default). In this case, it will be:
{'title': 'An example Markdown file'}
@jdkato
jdkato / simple.md
Last active February 23, 2019 22:30
title An example Markdown file

This is a Markdown file

Here's an inline (code span) directive:

name_of_function{'arg1': 'value', 'arg2': 'value2'}

By including code examples from external sources, we can ensure that they're properly tested, linted, and updated without having to duplicate content.

`document{'path': 'my_file.py', 'span': (10, 13)}`

We can include non-code content, too:

document{'path': 'includes/some_file.md'}

---
-
age: 90
first_name: John
last_name: Adams
-
age: 83
first_name: Henry
last_name: Ford
<table class="table">
<caption>My data</caption>
<thead>
<tr>
<th>age</th>
<th>first_name</th>
<th>last_name</th>
</tr>
</thead>
<tbody>
def main(meta, video, clip=[]):
"""Example directive for including a YouTube video.
`meta` is a dictionary containing any front matter that was
listed in the Markdown file.
`clip` specifies an optional start and stop point for the video.
"""
link = "https://www.youtube.com/embed/{0}".format(video)
addons
alertmanager
anonymized
arity
autocommit
backfilling
backfills
bitwise
bolded
burstable