This page tests the markdown embedding techniques.
A table of contents will be generated as well.
Go back to the homepage
This is File 1
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
This is File 2
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
@register.inclusion_tag('pyblue_content.html', takes_context=True)
def content(context, pattern):
"""
Loops over all markdown files in a pattern
and includes the markdown files
"""
files = context['files']
items = filter(lambda page: re.search(pattern, page.fname, re.IGNORECASE), files)
items = map(lambda f: MDEntry(f.path), items)
items = list(items)
params = dict(items=items, pattern=pattern)
return params
This is File 3
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
def match_file(context, pattern):
"""
Returns a relative path and a name for a matched pattern.
The path is computed relative to the page object of the current context.
Returns a triplet of the object, the path and the name to of the object.
"""
start = context['page']
files = context['files']
items = filter(lambda page: re.search(pattern, page.fname, re.IGNORECASE), files)
items = list(items)
if not items:
# Pattern does not match
relpath = "#"
msg = "Nothing matches pattern: '{}'".format(pattern)
logger.error(msg)
return None, relpath, msg
first = items[0]
if len(items) > 1:
# More than one file matches the pattern.
msg = "{} files match pattern: '{}' in file '{}'".format(len(items), pattern, start.fname)
logger.error(msg)
for item in items:
logger.error("pattern '{}' matches '{}'".format(pattern, item.fname))
name = first.name
rpath = first.relpath(start=start)
return first, rpath, name
It is possible to iterate directly on the markdown entries. This provides full control over the formatting.
How to automatically embed a file 1 • This is the section from file 2 • And this comes from file 3 •