Skip to content

Commit

Permalink
Allowing to compile MarkDown posts from string to string.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Jan 8, 2017
1 parent 7207adc commit b6617b8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nikola/plugins/compile/markdown/__init__.py
Expand Up @@ -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:
Expand Down

0 comments on commit b6617b8

Please sign in to comment.