Skip to content
Permalink
Browse files

More new-shortcode support

  • Loading branch information
ralsina committed May 12, 2017
1 parent 5246265 commit d68cef3c2dc9697e3c71931969ac85b3446a39a6
Showing with 11 additions and 5 deletions.
  1. +3 −1 nikola/plugins/compile/html.py
  2. +4 −2 nikola/plugins/compile/ipynb.py
  3. +4 −2 nikola/plugins/compile/markdown/__init__.py
@@ -31,6 +31,7 @@
import os
import io

from nikola import shortcodes as sc
from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, write_metadata

@@ -45,7 +46,8 @@ def compile_string(self, data, source_path=None, is_two_file=True, post=None, la
"""Compile HTML into HTML strings, with shortcode support."""
if not is_two_file:
_, data = self.split_metadata(data)
return self.site.apply_shortcodes(data, with_dependencies=True, extra_context={'post': post})
new_data, shortcodes = sc.extract_shortcodes(data)
return self.site.apply_shortcodes_uuid(new_data, shortcodes, filename=source_path, with_dependencies=True, extra_context=dict(post=post))

def compile(self, source, dest, is_two_file=True, post=None, lang=None):
"""Compile the source file into HTML and save as dest."""
@@ -61,6 +61,7 @@
flag = None
ipy_modern = None

from nikola import shortcodes as sc
from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, req_missing, get_logger, STDERR_HANDLER

@@ -94,8 +95,9 @@ def _nbformat_read(in_file):

def compile_string(self, data, source_path=None, is_two_file=True, post=None, lang=None):
"""Compile notebooks into HTML strings."""
output = self._compile_string(nbformat.reads(data, current_nbformat))
return self.site.apply_shortcodes(output, filename=source_path, with_dependencies=True, extra_context={'post': post})
new_data, shortcodes = sc.extract_shortcodes(data)
output = self._compile_string(nbformat.reads(new_data, current_nbformat))
return self.site.apply_shortcodes_uuid(output, shortcodes, filename=source_path, with_dependencies=True, extra_context=dict(post=post))

# TODO remove in v8
def compile_html_string(self, source, is_two_file=True):
@@ -40,6 +40,7 @@
gist_extension = None
podcast_extension = None

form nikola import shortcodes as sc
from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, req_missing, write_metadata

@@ -91,8 +92,9 @@ def compile_string(self, data, source_path=None, is_two_file=True, post=None, la
req_missing(['markdown'], 'build this site (compile Markdown)')
if not is_two_file:
_, data = self.split_metadata(data)
output = self.converter.convert(data)
output, shortcode_deps = self.site.apply_shortcodes(output, filename=source_path, with_dependencies=True, extra_context={'post': post})
new_data, shortcodes = sc.extract_shortcodes(data)
output = self.converter.convert(new_data)
output, shortcode_deps = self.site.apply_shortcodes_uuid(output, shortcodes, filename=source_path, 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):

0 comments on commit d68cef3

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