Пример #1
0
 def parse(self, input_data, reason):
     intro_t, body_t = htmlize_markup(input_data, reason)
     intro = sanitize(parse_zeml(intro_t))
     body = sanitize(parse_zeml(body_t))
     # The following complicated procedure is required only because
     # Zine provides no way to cast RootElement objects (which `intro`
     # and `body` are) into Element objects (which `intro` needs to become)
     if intro_t:
         newintro = Element('intro')
         newintro.children.extend(intro.children)
         newintro.text = intro.text
         for child in newintro.children:
             child.parent = newintro
         body.children.insert(0, newintro)
         newintro.parent = body
         newintro.tail = body.text
         body.text = u''
     return body
Пример #2
0
 def parse(self, input_data, reason):
     if not RstParser.extensions_registered:
         # need to do this only once...
         directives.register_directive('intro', IntroDirective)
         for extension in self.app.markup_extensions:
             if extension.is_block_level:
                 directives.register_directive(
                     extension.name,
                     make_extension_directive(self.app, extension))
             else:
                 roles.register_local_role(
                     extension.name, make_extension_role(extension))
         RstParser.extensions_registered = True
     settings_overrides = {
         'file_insertion_enabled': False,
         'parsing_reason': reason,
     }
     rv = publish_string(source=input_data, writer=ZemlWriter(),
                         settings_overrides=settings_overrides)
     if reason == 'comment':
         rv = sanitize(rv)
     return rv
Пример #3
0
 def parse(self, input_data, reason):
     if not RstParser.extensions_registered:
         # need to do this only once...
         directives.register_directive('intro', IntroDirective)
         for extension in self.app.markup_extensions:
             if extension.is_block_level:
                 directives.register_directive(
                     extension.name,
                     make_extension_directive(self.app, extension))
             else:
                 roles.register_local_role(extension.name,
                                           make_extension_role(extension))
         RstParser.extensions_registered = True
     settings_overrides = {
         'file_insertion_enabled': False,
         'parsing_reason': reason,
     }
     rv = publish_string(source=input_data,
                         writer=ZemlWriter(),
                         settings_overrides=settings_overrides)
     if reason == 'comment':
         rv = sanitize(rv)
     return rv
Пример #4
0
 def parse(self, input_data, reason):
     rv = parse_html(input_data)
     if reason == 'comment':
         rv = sanitize(rv)
     return rv
Пример #5
0
 def parse(self, input_data, reason):
     rv = parse_zeml(input_data, reason, self.app.markup_extensions)
     if reason == 'comment':
         rv = sanitize(rv)
     return rv
Пример #6
0
 def parse(self, input_data, reason):
     rv = parse_zeml(input_data, self.app.zeml_element_handlers)
     if reason == 'comment':
         rv = sanitize(rv)
     return rv
Пример #7
0
 def parse(self, input_data, reason):
     rv = parse_html(input_data)
     if reason == 'comment':
         rv = sanitize(rv)
     return rv
Пример #8
0
 def parse(self, input_data, reason):
     rv = parse_zeml(input_data, reason, self.app.markup_extensions)
     if reason == 'comment':
         rv = sanitize(rv)
     return rv