def apply_markup(raw_content, markup_no, request, escape_django_tags=False): """ render markup content to html. """ page_msg = FileLikeMessages(request, messages.INFO) assemble_tags = markup_no not in (MARKUP_HTML, MARKUP_HTML_EDITOR) if assemble_tags: # cut out every Django tags from content assembler = DjangoTagAssembler() raw_content2, cut_data = assembler.cut_out(raw_content) else: raw_content2 = raw_content html_content = convert(raw_content2, markup_no, page_msg) if assemble_tags: # reassembly cut out django tags into text if not isinstance(html_content, unicode): if settings.DEBUG: markup_name = MARKUP_DICT[markup_no] page_msg("Info: Markup converter %r doesn't return unicode!" % markup_name) html_content = force_unicode(html_content) html_content2 = assembler.reassembly(html_content, cut_data) else: # html "markup" used html_content2 = raw_content if escape_django_tags: html_content2 = escape_django_template_tags(html_content2) return mark_safe(html_content2) # turn Django auto-escaping off
def get_search_content(self, request): """ Use this content for display search results: * render markup content to html without existing django tags """ content = self.get_html(request) # remove django tags assembler = DjangoTagAssembler() content2, cut_data = assembler.cut_out(content) return content2
def convert_markup(raw_content, source_markup_no, dest_markup_no, request): """ Convert one markup in a other. """ page_msg = FileLikeMessages(request, messages.INFO) html_source = source_markup_no in (MARKUP_HTML, MARKUP_HTML_EDITOR) html_dest = dest_markup_no in (MARKUP_HTML, MARKUP_HTML_EDITOR) if source_markup_no == dest_markup_no or (html_source and html_dest): # Nothing to do ;) return raw_content if not html_dest and dest_markup_no != MARKUP_CREOLE: raise NotImplementedError("Converting into %r not supported." % dest_markup_no) if html_source: # Source markup is HTML html_content = raw_content else: # cut out every Django tags from content assembler = DjangoTagAssembler() raw_content2, cut_data = assembler.cut_out(raw_content) # convert to html html_content = convert(raw_content2, source_markup_no, page_msg) if html_dest: # Destination markup is HTML new_content = html_content else: # Skip: if dest_markup_no == MARKUP_CREOLE: - only creole supported here from creole import html2creole new_content = html2creole(html_content) if not html_source: # Source markup is not HTML # reassembly cut out django tags into text new_content = assembler.reassembly(new_content, cut_data) return new_content
raise messages.error(request, "Can't get plugin view: %s" % err) continue doc = None examples = None fallback_example = None if lucidtag_view.__name__ == "wrapper": messages.info(request, _("Info: lucidTag %s used a decorator without functools.wraps!") % plugin_name ) else: lucidtag_doc = inspect.getdoc(lucidtag_view) if lucidtag_doc: # Cutout lucidTag examples from DocString assembler = DjangoTagAssembler() cut_data = assembler.cut_out(lucidtag_doc)[1] examples = cut_data for example in examples: if not ( example.startswith("{%% lucidTag %s " % plugin_name) or \ example.startswith("{%% lucidTag %s." % plugin_name) ): messages.info(request, _("Info: lucidTag %(plugin_name)s has wrong tag example: %(example)r") % { "plugin_name": plugin_name, "example": example } ) examples = [escape(example) for example in examples]
def setUp(self): self.assembler = DjangoTagAssembler()