How to use the nikola.shortcodes.extract_shortcodes function in Nikola

To help you get started, we’ve selected a few Nikola examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github undertherain / pycontextfree / site / plugins / pdoc / pdoc.py View on Github external
def compile_string(self, data, source_path=None, is_two_file=True, post=None, lang=None):
        """Compile docstrings into HTML strings, with shortcode support."""
        if not is_two_file:
            _, data = self.split_metadata(data, None, lang)
        new_data, shortcodes = sc.extract_shortcodes(data)
        # The way pdoc generates output is a bit inflexible
        with tempfile.TemporaryDirectory() as tmpdir:
            subprocess.check_call(['pdoc', '--html', '--html-dir', tmpdir] + shlex.split(new_data.strip()))
            fname = os.listdir(tmpdir)[0]
            with open(os.path.join(tmpdir, fname), 'r', encoding='utf8') as inf:
                output = inf.read()
        return self.site.apply_shortcodes_uuid(output, shortcodes, filename=source_path, extra_context={'post': post})