How to use the pelican.readers.PelicanHTMLTranslator function in pelican

To help you get started, we’ve selected a few pelican 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 justanr / ipynb_reader / ipynb_reader / ipynb_reader.py View on Github external
'input_encoding': 'utf-8',
            'exit_status_level': 2,
            'embed_stylesheet': False
            }

        user_params = self.settings.get('DOCUTILS_SETTINGS', None)

        if user_params:
            extra_params.update(user_params)

        pub = docutils.core.Publisher(
            source_class=RstReader.FileInput,
            destination_class=docutils.io.StringOutput)

        pub.set_components('standalone', 'restructuredtext', 'html')
        pub.writer.translator_class = PelicanHTMLTranslator
        pub.process_programmatic_settings(None, extra_params, None)
        pub.set_source(source=contents)
        pub.publish(enable_exit_status=True)
        return pub
github pyvideo / pyvideo / bin / article_maker.py View on Github external
def _get_publisher(self, source):
        extra_params = {'initial_header_level': '2',
                        'syntax_highlight': 'short',
                        'input_encoding': 'utf-8',
                        'exit_status_level': 2,
                        'embed_stylesheet': False}
        user_params = self.settings.get('DOCUTILS_SETTINGS')
        if user_params:
            extra_params.update(user_params)

        pub = docutils.core.Publisher(
            source_class=self.FileInput,
            destination_class=docutils.io.StringOutput)
        pub.set_components('standalone', 'restructuredtext', 'html')
        pub.writer.translator_class = PelicanHTMLTranslator
        pub.process_programmatic_settings(None, extra_params, None)
        pub.set_source(source=source)
        pub.publish(enable_exit_status=True)
        return pub
github noirbizarre / pelican-microdata / microdata / plugin.py View on Github external
def register():
    directives.register_directive('itemscope', ItemScopeDirective)
    roles.register_canonical_role('itemprop', itemprop_role)

    PelicanHTMLTranslator.visit_ItemProp = as_method(visit_ItemProp)
    PelicanHTMLTranslator.depart_ItemProp = as_method(depart_ItemProp)
    PelicanHTMLTranslator.visit_ItemScope = as_method(visit_ItemScope)
    PelicanHTMLTranslator.depart_ItemScope = as_method(depart_ItemScope)

    # handle compact parameter
    # TODO: find a cleaner way to handle this case
    PelicanHTMLTranslator.visit_paragraph = as_method(visit_paragraph)

    # Fetch settings on initialized
    initialized.connect(set_vocabulary)
github pyvideo / pyvideo / plugins / event_info.py View on Github external
def _generate_html(data):
    extra_params = {'initial_header_level': '2',
                    'syntax_highlight': 'short',
                    'input_encoding': 'utf-8',
                    'exit_status_level': 2,
                    'compact_p': False,
                    'embed_stylesheet': False}
    pub = docutils.core.Publisher(
        source_class=docutils.io.StringInput,
        destination_class=docutils.io.StringOutput)
    pub.set_components('standalone', 'restructuredtext', 'html')
    pub.writer.translator_class = PelicanHTMLTranslator
    pub.process_programmatic_settings(None, extra_params, None)
    pub.set_source(source=data, source_path=None)
    pub.publish(enable_exit_status=True)
    return pub.writer.parts['body']
github noirbizarre / pelican-microdata / microdata / plugin.py View on Github external
def as_method(func):
    return six.create_unbound_method(func, PelicanHTMLTranslator)
github pyvideo / pyvideo / plugins / json_reader.py View on Github external
def _get_publisher(self, source, source_file_path):
        # This is a slightly modified copy of `RstReader._get_publisher`
        extra_params = {'initial_header_level': '4',
                        'syntax_highlight': 'short',
                        'input_encoding': 'utf-8',
                        'exit_status_level': 2,
                        'embed_stylesheet': False}
        user_params = self.settings.get('DOCUTILS_SETTINGS')
        if user_params:
            extra_params.update(user_params)

        pub = docutils.core.Publisher(
            source_class=docutils.io.StringInput,
            destination_class=docutils.io.StringOutput)
        pub.set_components('standalone', 'restructuredtext', 'html')
        pub.writer.translator_class = PelicanHTMLTranslator
        pub.process_programmatic_settings(None, extra_params, None)
        pub.set_source(source=source, source_path=source_file_path)
        pub.publish(enable_exit_status=True)
        return pub