Пример #1
0
    _name = 'Structured Text + LaTeX'
    supportsLaTeX = yes
    supportsPlone = yes

    def preRender(self, page, text=None):
        t = text or (page.document()+'\n'+MIDSECTIONMARKER+\
                     self.preRenderMessages(page))
        t = page.applyWikiLinkLineEscapesIn(t)
        # Be more generous in STX for links...so they can contain equations
        t = re.sub(r'(^| )(?ms)"([^"]*)":(http://[-:A-Za-z0-9_,./\?=@#~&%()]*?)([.!?,;](?= )|(?= )|$)',\
            r'\1<a href="\3">\2</a>\4',t)
        # render latex
        # FIXME and the same for WikiLinks (harder)
        latexTemplate = None
        latexTemplatePage = getattr(page.folder(),
                                    'LatexTemplate', None)
        if latexTemplatePage:
            latexTemplate = latexTemplatePage.text()
        t = replaceInlineLatex(t, getattr(page.folder(),'latex_font_size',defaultcharsizepx), \
                                  getattr(page.folder(),'latex_align_fudge',0), 
                                  getattr(page.folder(),'latex_res_fudge',1.03), latexTemplate)
        # render stx
        t = self.format(t)
        t = page.markLinksIn(t)
        t = self.protectEmailAddresses(page,t)
        # add a CSS class to the whole thing
        t = '<div class="latexwiki">\n' + t + '\n</div>\n'
        return t

registerPageType(PageTypeStxLatex)
Пример #2
0
    def makeCommentHeading(self, page,
                           subject, username, time, 
                           message_id=None,in_reply_to=None):
        """
        Generate HTML markup for a comment heading in a HTML page.

        Note that we just work on the comment heading here. The content of the 
        comment is left as is, not certain what to do with it. Users likely 
        expect to be able to write comments like on every other page type
        (e.g. with two newlines to format paragraphs) - but what kind of markup
        would be expected on a html page? XXX
        """
        heading = '\n\n<p class="commentheading"> '
        heading += '<strong>%s</strong> --' % (subject or '...')
        if username: heading = heading + '%s, ' % (username)
        heading += time or ''
        heading += ' <a class="reference" href="%s?subject=%s%s#bottom">%s</a>' % (
            page.pageUrl(),
            quote(subject or ''),
            ((message_id and '&amp;in_reply_to='+quote(message_id))
             or ''),
            _("reply"),
            )
        heading += '\n\n</p>'
        return heading

registerPageType(PageTypeHtml)

# backwards compatibility - need this here for old zodb objects
ZwikiHtmlPageType = PageTypeHtml
Пример #3
0
        if username: heading = heading + '%s, ' % (username)
        if message_id:
            heading += ' <a href="%s#msg%s">%s</a>' % \
                       (page.page_url(),
                        re.sub(r'^<(.*)>$',r'\1',message_id),
                        html_quote(time))
            inreplytobit = '&in_reply_to='+quote(message_id)
        else:
            heading += html_quote(time)
            inreplytobit = ''
        heading += ' <a href="%s?subject=%s%s#bottom">reply</a>'\
                   % (page.page_url(),quote(subject or ''),inreplytobit)
        heading += '</div>'
        return heading

registerPageType(PageTypeStxMath)


# This class supports pamphlet (noweb) format for MathAction
# Oct 6, 2005 Bill Page

# XXX this doesn't/can't use STX and so should just use PageTypeBase
# but it doesn't work so well and needs investigation (no skin, shows
# midsection marker)
#class PageTypePamphlet(PageTypeBase):
class PageTypePamphlet(PageTypeStx):
    """
    docstring
    """
    _id = 'pamphlet'
    _name = 'Noweb pamphlet'
Пример #4
0
                        valign="top"
                    elif bottomindent < 1:
                        valign="bottom"
                    else:
                        valign="middle"

                    if left[0] < 1:
                        align = "left"
                    elif right[0] < 1:
                        align = "right"
                    elif left[0] > 1 and right[0] > 1:
                        align="center"
                    else:
                        align="left"

                    cols.append((row[index][0],row[index][1],align,valign,row[index][2]))
                rows.append(cols)
                cols = []
            return StructuredTextTable(rows,text,subs,indent=paragraph.indent)

        # XXX bad, but we just don't want to hear about STX table breakage
        except:
            return StructuredTextTable([],'',subs,indent=paragraph.indent)
            
ZwikiDocumentWithImages = ZwikiDocumentWithImages()
    
registerPageType(PageTypeStx)

# backwards compatibility - need this here for old zodb objects
ZwikiStxPageType = PageTypeStx
Пример #5
0
from common import *
from Products.ZWiki.I18n import _
from Products.ZWiki.pagetypes import registerPageType

class PageTypePlaintext(PageTypeBase):
    _id = 'plaintext'
    _name = 'Plain text'

    def format(self,t):
        return "<pre>\n%s\n</pre>\n" % html_quote(t)

    def preRender(self, page, text=None):
        t = text or page.read()
        t = self.format(t)
        if not text: t += '\n'+MIDSECTIONMARKER
        t = self.protectEmailAddresses(page,t)
        return t

    def render(self, page, REQUEST={}, RESPONSE=None, **kw):
        t = page.preRendered()
        if page.isIssue() and kw.get('show_issueproperties',1):
            t = page.addIssueFormTo(t)
        t = page.renderMidsectionIn(t,**kw)
        t = page.addSkinTo(t,**kw)
        return t

registerPageType(PageTypePlaintext)

# backwards compatibility - need this here for old zodb objects
ZwikiPlaintextPageType = PageTypePlaintext
Пример #6
0
                self.pushList( newCode )

        self.topList.append( line )


    def translate( self, lines ) :
        """
        """
        for line in lines :
            # PM: Turn leading spaces into tabs ... someone smarter than
            # me can figure out how to do this with a single regexp ...
            splitted = self.leadingSpaces.split(line)
            if len(splitted) == 3:
                line = self.spaceChunks.sub("\t", splitted[1]) + splitted[2]
            if self.codeLine.match( line ) :
                self.appendCodeLine( line )
            else :
                self.parseLine( line )
        return self.translatedLines
    
    __call__ = translate

def translate_WWML(text) :
    return string.join(WWMLTranslator()(str(text).split('\n')),'\n')


registerPageType(PageTypeWwml)

# backwards compatibility - need this here for old zodb objects
ZwikiWwmlPageType = PageTypeWwml
Пример #7
0
            OptionParser(components=(Parser,)).get_default_values())
        Parser().parse(page.text(), d)
        #walk the offspring, adding as elements to the tree and deleting
        def walk(p):
            d2 = new_document(
                p.pageName(),
                OptionParser(components=(Parser,)).get_default_values())
            Parser().parse(p.text(), d2)
            d += d2.traverse()
            for c in page.childrenNesting():
                c = p.pageWithName(c)
                walk(c)
                c.delete()
        walk(page)
        #convert the tree back to source text and update this page
        page.edit(text=d.astext())

        #or: walk the offspring, adding as text to this page with
        #appropriate headings, and deleting
        #need to adjust headings ?
        #for p in page.offspringNesting():
        #    pass

        if getattr(page,'REQUEST',None):
            page.REQUEST.RESPONSE.redirect(page.pageUrl())

registerPageType(PageTypeRst)

# backwards compatibility - need this here for old zodb objects
ZwikiRstPageType = PageTypeRst