def inline_nowiki_repl(self, stack, nowiki, nowiki_text=None, nowiki_text_pre=None, pre_args='', nowiki_text_code=None, nowiki_text_tt=None): text = None if nowiki_text is not None: text = nowiki_text stack.top_append(moin_page.code(children=[text])) elif nowiki_text_code is not None: text = nowiki_text_code stack.top_append(moin_page.code(children=[text])) elif nowiki_text_tt is not None: text = nowiki_text_tt stack.top_append(moin_page.code(children=[text])) # Remove empty backtick nowiki samples elif nowiki_text_pre: # TODO: pre_args parsing text = nowiki_text_pre stack.top_append(moin_page.blockcode(children=[text])) else: return
def macro(self, content, arguments, page_url, alternative): """ Invocation: <<MailTo(user AT example DOT org, write me)>> where 2nd parameter is optional. """ if arguments: arguments = arguments[0].split(',') try: assert len(arguments) > 0 and len(arguments) < 3 email = arguments[0] assert len(email) >= 5 except (AttributeError, AssertionError): raise ValueError( _("MailTo: invalid format, try: <<MailTo(user AT example DOT org, write me)>>" )) try: text = arguments[1] except IndexError: text = u'' if flaskg.user.valid: # decode address and generate mailto: link email = decodeSpamSafeEmail(email) result = moin_page.a( attrib={xlink.href: u'mailto:{0}'.format(email)}, children=[text or email]) else: # unknown user, maybe even a spambot, so just return text as given in macro args if text: text += " " result = moin_page.code(children=[text, "<{0}>".format(email)]) return result
def inline_nowiki_repl(self, stack, nowiki, nowiki_text=None, nowiki_text_backtick=None): text = None if nowiki_text is not None: return stack.top_append(moin_page.samp(children=[nowiki_text])) # we must pass empty strings for moinwiki in > out conversions (@``DATE@ must not be converted to @DATE@) elif nowiki_text_backtick is not None: return stack.top_append(moin_page.code(children=[nowiki_text_backtick]))
def create_number_pagelink_list(self, num_pagenames, ordered=False): """ creates an ET with a list of pagelinks from a list of pagenames """ num_page_list = moin_page.list(attrib={ moin_page.item_label_generate: ordered and 'ordered' or 'unordered' }) for num, pagename in num_pagenames: num_code = moin_page.code(children=["{0:6d} ".format(num)]) # This link can never reach pagelinks url = unicode( iri.Iri(scheme=u'wiki', authority=u'', path=u'/' + pagename)) pagelink = moin_page.a(attrib={xlink.href: url}, children=[pagename]) item_body = moin_page.list_item_body(children=[num_code, pagelink]) item = moin_page.list_item(children=[item_body]) num_page_list.append(item) return num_page_list
def inline_nowiki_repl(self, stack, nowiki, nowiki_text): stack.top_append(moin_page.code(children=(nowiki_text, )))
def visit_literal(self, node): self.open_moin_page_node(moin_page.code()) self.open_moin_page_node(node.astext()) node.children = [] self.close_moin_page_node() self.close_moin_page_node()