Exemplo n.º 1
0
    def parse(self, input_data, reason):
        usesettings = dict(self.settings)

        if reason == 'comment':
            usesettings['file_insertion_enabled'] = 0
        usesettings['initial_header_level'] = get_application(
        ).cfg[CFG_HEADER_LEVEL]

        parts = publish_parts(input_data,
                              writer_name='html',
                              settings_overrides=usesettings)

        return parse_html(parts['html_body'])
Exemplo n.º 2
0
 def parse(self, input_data, reason):
     cfg = get_application().cfg
     parser = md.Markdown(safe_mode=reason == 'comment' and 'escape',
                          extensions=cfg[CFG_EXTENSIONS],
                          #: For compatibility with the Pygments plugin
                          extension_configs={'codehilite':
                                                 {'css_class': 'syntax'}})
     html = parser.convert(input_data)
     if cfg[CFG_MAKEINTRO]:
         if MORE_TAG.search(html):
             #: Crude hack, but parse_html will correct any html
             #: closure errors we introduce
             html = u'<intro>' + MORE_TAG.sub(u'</intro>', html, 1)
     return parse_html(html)
Exemplo n.º 3
0
 def cmdlogger(self, messages):
     from zine.utils.zeml import parse_html  # late import
     for message in messages:
         if hasattr(message, '__iter__'):
             self.cmdlogger(message)
         else:
             trailing_new_line = message and message.endswith('\n') or False
             message = parse_html(message).to_text(simple=True)
             if message:
                 # make the textifier output more compact
                 if message.endswith('\n\n') and trailing_new_line:
                     message = message[:-1]
                 elif message.endswith('\n') and not trailing_new_line:
                     message = message.rstrip('\n')
                 sys.stdout.write(message.encode('utf-8'))
                 sys.stdout.flush()
Exemplo n.º 4
0
 def parse(self, input_data, reason):
     cfg = get_application().cfg
     parser = md.Markdown(
         safe_mode=reason == 'comment' and 'escape',
         extensions=cfg[CFG_EXTENSIONS],
         #: For compatibility with the Pygments plugin
         extension_configs={'codehilite': {
             'css_class': 'syntax'
         }})
     html = parser.convert(input_data)
     if cfg[CFG_MAKEINTRO]:
         if MORE_TAG.search(html):
             #: Crude hack, but parse_html will correct any html
             #: closure errors we introduce
             html = u'<intro>' + MORE_TAG.sub(u'</intro>', html, 1)
     return parse_html(html)
Exemplo n.º 5
0
    def cmdlogger(self, messages):
        from zine.utils.zeml import parse_html  # late import

        for message in messages:
            if hasattr(message, "__iter__"):
                self.cmdlogger(message)
            else:
                trailing_new_line = message and message.endswith("\n") or False
                message = parse_html(message).to_text(simple=True)
                if message:
                    # make the textifier output more compact
                    if message.endswith("\n\n") and trailing_new_line:
                        message = message[:-1]
                    elif message.endswith("\n") and not trailing_new_line:
                        message = message.rstrip("\n")
                    sys.stdout.write(message.encode("utf-8"))
                    sys.stdout.flush()
Exemplo n.º 6
0
 def parse(self, input_data, reason):
     rv = parse_html(input_data)
     if reason == 'comment':
         rv = sanitize(rv)
     return rv
Exemplo n.º 7
0
def _wordpress_to_html(markup):
    """Convert WordPress-HTML into read HTML."""
    return inject_implicit_paragraphs(parse_html(markup)).to_html()
Exemplo n.º 8
0
 def parse(self, input_data, reason):
     rv = parse_html(input_data)
     if reason == 'comment':
         rv = sanitize(rv)
     return rv
Exemplo n.º 9
0
def _wordpress_to_html(markup):
    """Convert WordPress-HTML into read HTML."""
    return inject_implicit_paragraphs(parse_html(markup)).to_html()