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'])
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)
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()
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)
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()
def parse(self, input_data, reason): rv = parse_html(input_data) if reason == 'comment': rv = sanitize(rv) return rv
def _wordpress_to_html(markup): """Convert WordPress-HTML into read HTML.""" return inject_implicit_paragraphs(parse_html(markup)).to_html()