Ejemplo n.º 1
0
def SpanHandler(rest, acc):
    (text, rest) = Inline.collectSpan(rest)
    textparts = text.split('|', 1)
    if len(textparts) > 1:
        target = textparts[0]
        vistext = textparts[1]
    else:
        target = text
        vistext = target
    acc.append(Inline.ExternalLink(target, vistext))
    return rest
Ejemplo n.º 2
0
def SublanguageHandler(args, doc, renderer):
    code = doc.reconstruct_child_text().as_string()
    literalfragment = Inline.LiteralFragment(code)
    if Config.code_enscript_command:
	filename = os.tmpnam()
	file = open(filename, 'w+')
	file.write(code)
	file.close()
	command = Config.code_enscript_command + ' -B -p - --language=html --color -E' + \
	    args + ' ' + filename + ' 2>/dev/null'
	child_stdout = os.popen(command)
	result = child_stdout.read()
	child_stdout.close()
	os.unlink(filename)
        renderer.add(HighlightedCode(Inline.HtmlFragment(enscriptre.sub(r'\1', result)),
                                     literalfragment))
    else:
	renderer.add(HighlightedCode(literalfragment, literalfragment))
Ejemplo n.º 3
0
def SpanHandler(rest, acc):
    (text, rest) = Inline.collectSpan(rest)
    textparts = text.split('|', 1)
    if len(textparts) > 1:
        target = textparts[0]
        vistext = textparts[1]
    else:
        target = text
        vistext = target
    acc.append(Inline.ExternalLink(target, vistext))
    return rest
Ejemplo n.º 4
0
def SpanHandler(rest, acc):
    (inner, rest) = Inline.parse(rest)

    rendercache = web.ctx.active_page.rendercache()
    if not rendercache.has_key("footnotes"):
        rendercache["footnotes"] = []

    number = len(rendercache["footnotes"]) + 1
    note = Footnote(number, inner)
    rendercache["footnotes"].append(note)
    acc.append(note)
    return rest
def SpanHandler(rest, acc):
    (inner, rest) = Inline.parse(rest)

    rendercache = web.ctx.active_page.rendercache()
    if not rendercache.has_key('footnotes'):
        rendercache['footnotes'] = []

    number = len(rendercache['footnotes']) + 1
    note = Footnote(number, inner)
    rendercache['footnotes'].append(note)
    acc.append(note)
    return rest
Ejemplo n.º 6
0
 def visit_sublanguage(self, commandline, doc):
     commandparts = commandline.split(' ', 1)
     command = commandparts[0]
     if len(commandparts) > 1:
         args = commandparts[1]
     else:
         args = ''
     (err, plugin) = Plugin.find_plugin('sublanguages', command,
                                        'SublanguageHandler')
     if plugin:
         try:
             plugin(args, doc, self)
         except BlockSyntaxError, e:
             import Inline
             self.add(Inline.MarkupError(True, 'pluginerror', e.message))
         except:
def SpanHandler(rest, acc):
    (text, rest) = Inline.collectSpan(rest)

    parts = text.split('/', 1)
    name = parts[0]
    pagename = ''

    if name.find(':') != -1:
        (pagename, name) = name.split(':', 1)
    if not pagename:
        pagename = web.ctx.source_page_title

    if len(parts) > 1:
        alt = parts[1]
    else:
        alt = '[Attachment ' + pagename + ':' + name + ']'

    a = Core.Attachment(pagename, name, None)
    acc.append(AttachmentReference(a, alt))
    return rest
Ejemplo n.º 8
0
def SpanHandler(rest, acc):
    return Inline.discardSpan(rest)
Ejemplo n.º 9
0
def SpanHandler(rest, acc):
    (fragments, rest) = Inline.parse(rest)
    acc.append(Inline.TagFragment('pyle_tt', fragments))
    return rest
Ejemplo n.º 10
0
def SublanguageHandler(args, doc, renderer):
    text = doc.reconstruct_child_text().as_string()
    (fragments, rest) = Inline.parse(text)
    renderer.add(Inline.TagFragment('pyle_pre', fragments, 'pre'))
Ejemplo n.º 11
0
def SpanHandler(rest, acc):
    (fragments, rest) = Inline.parse(rest)
    acc.append(Inline.TagFragment('pyle_tt', fragments))
    return rest
def SpanHandler(rest, acc):
    (text, rest) = Inline.collectSpan(rest)
    acc.append(Inline.LiteralFragment(text))
    return rest
Ejemplo n.º 13
0
def SpanHandler(rest, acc):
    acc.append(Inline.TagFragment('pyle_br', []))
    return Inline.discardSpan(rest)
Ejemplo n.º 14
0
def SpanHandler(rest, acc):
    (inner, rest) = Inline.collectSpan(rest)
    acc.append(Inline.TagFragment('pyle_code',
                                  [Inline.LiteralFragment(inner)]))
    return rest
Ejemplo n.º 15
0
def SpanHandler(rest, acc):
    (inner, rest) = Inline.collectSpan(rest)
    acc.append(Inline.HtmlFragment(inner))
    return rest
Ejemplo n.º 16
0
def SpanHandler(rest, acc):
    (inner, rest) = Inline.collectSpan(rest)
    acc.append(Inline.TagFragment("pyle_code", [Inline.LiteralFragment(inner)]))
    return rest
Ejemplo n.º 17
0
            args = commandparts[1]
        else:
            args = ''
        (err, plugin) = Plugin.find_plugin('sublanguages', command,
                                           'SublanguageHandler')
        if plugin:
            try:
                plugin(args, doc, self)
            except BlockSyntaxError, e:
                import Inline
                self.add(Inline.MarkupError(True, 'pluginerror', e.message))
            except:
                import traceback
                import Inline
                tb = traceback.format_exc()
                self.add(Inline.MarkupError(True, 'pluginerror', tb))
                sys.stderr.write(tb)
        else:
            import Inline
            self.add(Inline.MarkupError(True, 'missingsublanguage', err))

    def visit_normal(self, para):
        self.add(Paragraph(para))


class DefaultPageContent(Renderable):
    def __init__(self, title):
        self.title = title

    def templateName(self):
        return 'default_page_content'
Ejemplo n.º 18
0
    def __init__(self, blockPara):
	import Inline
	self.fragments = []
	Inline.parse(blockPara.as_string(), self.fragments)
Ejemplo n.º 19
0
 def __init__(self, blockPara):
     import Inline
     self.fragments = []
     Inline.parse(blockPara.as_string(), self.fragments)
Ejemplo n.º 20
0
def SpanHandler(rest, acc):
    return Inline.discardSpan(rest)
Ejemplo n.º 21
0
def SublanguageHandler(args, doc, renderer):
    text = doc.reconstruct_child_text().as_string()
    (fragments, rest) = Inline.parse(text)
    renderer.add(Inline.TagFragment("pyle_pre", fragments, "pre"))
Ejemplo n.º 22
0
def SpanHandler(rest, acc):
    (text, rest) = Inline.collectSpan(rest)
    text = text.strip()
    acc.append(Inline.ExternalLink(Config.bug_url_template % text, "bug %s" % text))
    return rest
Ejemplo n.º 23
0
def SpanHandler(rest, acc):
    (inner, rest) = Inline.parse(rest)
    acc.append(Inline.TagFragment('pyle_b', inner))
    return rest
Ejemplo n.º 24
0
def SpanHandler(rest, acc):
    acc.append(Inline.TagFragment('pyle_br', []))
    return Inline.discardSpan(rest)
Ejemplo n.º 25
0
def SpanHandler(rest, acc):
    (inner, rest) = Inline.parse(rest)
    acc.append(Inline.TagFragment('pyle_b', inner))
    return rest
Ejemplo n.º 26
0
def SublanguageHandler(args, doc, renderer):
    renderer.add(Inline.HtmlFragment(doc.reconstruct_child_text().as_string()))