Skip to content
Permalink
Browse files

Allowing to compile MarkDown posts from string to string.

  • Loading branch information
felixfontein committed Jan 8, 2017
1 parent 7207adc commit b6617b8eb6d6179e47246b9a59d5f410410b633c
Showing with 9 additions and 0 deletions.
  1. +9 −0 nikola/plugins/compile/markdown/__init__.py
@@ -63,6 +63,15 @@ def set_site(self, site):

self.config_dependencies.append(str(sorted(site.config.get("MARKDOWN_EXTENSIONS"))))

def compile_to_string(self, content):
"""Compile the content into HTML."""
if markdown is None:
req_missing(['markdown'], 'build this site (compile Markdown)')
self.extensions += self.site.config.get("MARKDOWN_EXTENSIONS")
output = markdown(content, self.extensions, output_format="html5")
output, _ = self.site.apply_shortcodes(output, filename=source, with_dependencies=True, extra_context=dict(post=post))
return output

def compile(self, source, dest, is_two_file=True, post=None, lang=None):
"""Compile the source file into HTML and save as dest."""
if markdown is None:

0 comments on commit b6617b8

Please sign in to comment.
You can’t perform that action at this time.