Skip to content
Permalink
Browse files

Matching API of ReST compiler.

  • Loading branch information
felixfontein committed Jan 8, 2017
1 parent b6617b8 commit 0a904e0b9a86867b081fff9b1e8ca689f5a8277a
Showing with 7 additions and 8 deletions.
  1. +7 −8 nikola/plugins/compile/markdown/__init__.py
@@ -63,14 +63,16 @@ 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."""
def compile_string(self, content, source_path=None, is_two_file=True):
"""Compile MarkDown into HTML strings."""
if markdown is None:
req_missing(['markdown'], 'build this site (compile Markdown)')
self.extensions += self.site.config.get("MARKDOWN_EXTENSIONS")
if not is_two_file:
_, content = self.split_metadata(content)
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
output, shortcode_deps = self.site.apply_shortcodes(output, filename=source, with_dependencies=True, extra_context=dict(post=post))
return output, shortcode_deps

def compile(self, source, dest, is_two_file=True, post=None, lang=None):
"""Compile the source file into HTML and save as dest."""
@@ -81,10 +83,7 @@ def compile(self, source, dest, is_two_file=True, post=None, lang=None):
with io.open(dest, "w+", encoding="utf8") as out_file:
with io.open(source, "r", encoding="utf8") as in_file:
data = in_file.read()
if not is_two_file:
_, data = self.split_metadata(data)
output = markdown(data, self.extensions, output_format="html5")
output, shortcode_deps = self.site.apply_shortcodes(output, filename=source, with_dependencies=True, extra_context=dict(post=post))
output, shortcode_deps = self.compile_string(data, source, is_two_file)
out_file.write(output)
if post is None:
if shortcode_deps:

0 comments on commit 0a904e0

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