Example #1
0
def format_wikitext(request, data, parser=None):
    request.page.formatter = request.formatter
    request.formatter.page = request.page

    if not parser:
        parser = Parser(data, request)
    else:
        parser.raw = data
    parser.request = request

    # Do not store pagelinks for values in metadata listings
    plstore = getattr(request.formatter, '_store_pagelinks', 0)
    request.formatter._store_pagelinks = 0

    parser.formatter = request.formatter
    # No line anchors of any type to table cells
    request.page.formatter.in_p = 1
    parser._line_anchordef = lambda: ''

    # Do not parse macros from revision pages. For some reason,
    # it spawns multiple requests, which are not finished properly,
    # thus littering a number of readlocks. Besides, the macros do not
    # return anything useful anyway for pages they don't recognize
    if '?action=recall' in request.page.page_name:
        parser._macro_repl = lambda x: x

    out = parser.scan(data, inhibit_p=True)

    request.formatter._store_pagelinks = plstore
    return out.strip()
def format_wikitext(request, data, parser=None):
    request.page.formatter = request.formatter
    request.formatter.page = request.page

    if not parser:
        parser = Parser(data, request)
    else:
        parser.raw = data
    parser.request = request

    # Do not store pagelinks for values in metadata listings
    plstore = getattr(request.formatter, '_store_pagelinks', 0)
    request.formatter._store_pagelinks = 0

    parser.formatter = request.formatter
    # No line anchors of any type to table cells
    request.page.formatter.in_p = 1
    parser._line_anchordef = lambda: ''

    # Do not parse macros from revision pages. For some reason,
    # it spawns multiple requests, which are not finished properly,
    # thus littering a number of readlocks. Besides, the macros do not
    # return anything useful anyway for pages they don't recognize
    if '?action=recall' in request.page.page_name:
        parser._macro_repl = lambda x: x

    out = parser.scan(data, inhibit_p=True)

    request.formatter._store_pagelinks = plstore
    return out.strip()
Example #3
0
def t_cell(macro, value, head=0):
    out = macro.request

    style = dict()
    style['class'] = 'meta_cell'

    out.write(macro.formatter.table_cell(1, attrs=style))

    if not isinstance(value, unicode):
        value = unicode(value, config.charset)

    value = value.strip()

    if head:
        kw = {}
        if '?' in value:
            value, query = value.split('?')
            kw['querystr'] = query
        out.write(macro.formatter.pagelink(1, value, **kw))
        out.write(macro.formatter.text(value))
        out.write(macro.formatter.pagelink(0))
    else:
        out.page.formatter = out.formatter
        parser = Parser(value, out)
        # No line anchors of any type to table cells
        out.page.formatter.in_p = 1
        parser._line_anchordef = lambda: ''

        # Using StringIO in order to strip the output
        value = StringIO.StringIO()
        out.redirect(value)
        # Produces output on a single table cell
        out.page.format(parser)
        out.redirect()

        out.write(value.getvalue().strip())
def t_cell(macro, value):
    out = macro.request

    style = dict()
    style['class'] = 'meta_cell'

    out.write(macro.formatter.table_cell(1, attrs=style))

    value = value.strip()

    out.page.formatter = out.formatter
    parser = Parser(value, out)
    # No line anchors of any type to table cells
    out.page.formatter.in_p = 1
    parser._line_anchordef = lambda: ''

    # Using StringIO in order to strip the output
    value = StringIO.StringIO()
    out.redirect(value)
    # Produces output on a single table cell
    out.page.format(parser)
    out.redirect()

    out.write(value.getvalue().strip())
def t_cell(macro, value):
    out = macro.request

    style = dict()
    style['class'] = 'meta_cell'

    out.write(macro.formatter.table_cell(1, attrs=style))

    value = value.strip()

    out.page.formatter = out.formatter
    parser = Parser(value, out)
    # No line anchors of any type to table cells
    out.page.formatter.in_p = 1
    parser._line_anchordef = lambda: ''

    # Using StringIO in order to strip the output
    value = StringIO.StringIO()
    out.redirect(value)
    # Produces output on a single table cell
    out.page.format(parser)
    out.redirect()

    out.write(value.getvalue().strip())
Example #6
0
    def _line_anchordef(self):
        if self.in_dd:
            return ''

        return wikiParser._line_anchordef(self)
Example #7
0
    def _line_anchordef(self):
        if self.in_dd:
            return ''

        return wikiParser._line_anchordef(self)