Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Static Private Attributes
MoinMoin.formatter.text_docbook.Formatter Class Reference
Inheritance diagram for MoinMoin.formatter.text_docbook.Formatter:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.formatter.text_docbook.Formatter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def startDocument
def startContent
def endContent
def endDocument
def text
def heading
def paragraph
def linebreak
def strong
 Inline ##########################################################.
def emphasis
def underline
def highlight
def sup
def sub
def strike
def code
def preformatted
def number_list
 Lists ###########################################################.
def bullet_list
def listitem
def definition_list
def definition_term
def definition_desc
def pagelink
 Links ########################################################### TODO: Fix anchors to documents which are included.
def interwikilink
def url
def anchordef
def anchorlink
def attachment_link
 Attachments ######################################################.
def attachment_image
def attachment_drawing
def image
 Images and Smileys ##############################################.
def transclusion
def transclusion_param
def smiley
def icon
def code_area
 Code area #######################################################.
def code_line
def code_token
def macro
 Macro ###########################################################.
def rule
 Not supported ###################################################.
def small
def big
def rawHTML
def div
def span
def table
 Tables ##########################################################.
def table_row
def table_cell
def set_highlight_re
def lang
def setPage
def sysmsg
def attachment_inlined
def line_anchordef
def line_anchorlink
def nowikiword
def code_area
def listitem
def parser
def escapedText
def comment
def sanitize_to_id
def make_id_unique
def qualify_id

Public Attributes

 request
 include_kludge
 doctype
 curdepth
 cur
 doc
 title
 root
 curtable
 pagelinks
 in_p
 in_pre
 page

Static Public Attributes

list section_should_break = ['abstract', 'para', 'emphasis']
tuple blacklisted_macros = ('TableOfContents', 'ShowSmileys', 'Navigation')
tuple wrap_text_in_para = ('listitem', 'glossdef', 'article', 'chapter', 'tip', 'warning', 'note', 'caution', 'important')
string hardspace = ' '

Private Member Functions

def _copyExternalNodes
 Util functions ##################################################.
def _emitComment
def _handleNode
def _handleFormatting
def _isInsidePreformatted
def _hasContent
def _addTitleElement
def _convertStylesToDict
def _cleanupUlinkNode
def _addTextElem
def _addRevisionHistory

Static Private Attributes

tuple _can_contain_section = ("section", "appendix", "article", "chapter", "patintro", "preface")

Detailed Description

Definition at line 37 of file text_docbook.py.


Constructor & Destructor Documentation

def MoinMoin.formatter.text_docbook.Formatter.__init__ (   self,
  request,
  doctype = "article",
  kw 
)

Definition at line 54 of file text_docbook.py.

00054 
00055     def __init__(self, request, doctype="article", **kw):
00056         FormatterBase.__init__(self, request, **kw)
00057         self.request = request
00058 
00059         '''
00060         If the formatter is used by the Include macro, it will set
00061         is_included=True in which case we know we need to call startDocument
00062         and endDocument from startContent and endContent respectively, since
00063         the Include macro will not be calling them, and the formatter doesn't
00064         work properly unless they are called.
00065         '''
00066         if kw.has_key("is_included") and kw["is_included"]:
00067             self.include_kludge = True
00068         else:
00069             self.include_kludge = False
00070 
00071         self.doctype = doctype
00072         self.curdepth = 0
00073         self.cur = None


Member Function Documentation

def MoinMoin.formatter.text_docbook.Formatter._addRevisionHistory (   self,
  targetNode 
) [private]
This will generate a revhistory element which it will populate with
revision nodes. Each revision has the revnumber, date and author-
initial elements, and if a comment was supplied, the comment element.

The date elements format depends on the users settings, so it will
be in the same format as the revision history as viewed in the
page info on the wiki.

The authorinitials will be the UserName or if it was an anonymous
edit, then it will be the hostname/ip-address.

The revision history of included documents is NOT included at the
moment due to technical difficulties.

Definition at line 752 of file text_docbook.py.

00752 
00753     def _addRevisionHistory(self, targetNode):
00754         """
00755         This will generate a revhistory element which it will populate with
00756         revision nodes. Each revision has the revnumber, date and author-
00757         initial elements, and if a comment was supplied, the comment element.
00758 
00759         The date elements format depends on the users settings, so it will
00760         be in the same format as the revision history as viewed in the
00761         page info on the wiki.
00762 
00763         The authorinitials will be the UserName or if it was an anonymous
00764         edit, then it will be the hostname/ip-address.
00765 
00766         The revision history of included documents is NOT included at the
00767         moment due to technical difficulties.
00768         """
00769         _ = self.request.getText
00770         log = editlog.EditLog(self.request, rootpagename=self.title)
00771         user_cache = {}
00772 
00773         history = self.doc.createElement("revhistory")
00774 
00775         # read in the complete log of this page
00776         for line in log.reverse():
00777             if not line.action in ('SAVE', 'SAVENEW', 'SAVE/REVERT', 'SAVE/RENAME', ):
00778                 #Let's ignore adding of attachments
00779                 continue
00780             revision = self.doc.createElement("revision")
00781 
00782             # Revision number (without preceeding zeros)
00783             self._addTextElem(revision, "revnumber", line.rev.lstrip('0'))
00784 
00785             # Date of revision
00786             date_text = self.request.user.getFormattedDateTime(
00787                 wikiutil.version2timestamp(line.ed_time_usecs))
00788             self._addTextElem(revision, "date", date_text)
00789 
00790             # Author or revision
00791             if not (line.userid in user_cache):
00792                 user_cache[line.userid] = user.User(self.request, line.userid, auth_method="text_docbook:740")
00793             author = user_cache[line.userid]
00794             if author and author.name:
00795                 self._addTextElem(revision, "authorinitials", author.name)
00796             else:
00797                 self._addTextElem(revision, "authorinitials", line.hostname)
00798 
00799             # Comment from author of revision
00800             comment = line.comment
00801             if not comment:
00802                 if '/REVERT' in line.action:
00803                     comment = _("Revert to revision %(rev)d.") % {'rev': int(line.extra)}
00804                 elif '/RENAME' in line.action:
00805                     comment = _("Renamed from '%(oldpagename)s'.") % {'oldpagename': line.extra}
00806             if comment:
00807                 self._addTextElem(revision, "revremark", comment)
00808 
00809             history.appendChild(revision)
00810 
00811         if history.firstChild:
00812             #only add revision history is there is history to add
00813             targetNode.appendChild(history)

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter._addTextElem (   self,
  target,
  elemName,
  text 
) [private]
Creates an element of the name elemName and adds a text node to it
with the nodeValue of text. The new element is then added as a child
to the element target.

Definition at line 741 of file text_docbook.py.

00741 
00742     def _addTextElem(self, target, elemName, text):
00743         """
00744         Creates an element of the name elemName and adds a text node to it
00745         with the nodeValue of text. The new element is then added as a child
00746         to the element target.
00747         """
00748         newElement = self.doc.createElement(elemName)
00749         newElement.appendChild(self.doc.createTextNode(text))
00750         target.appendChild(newElement)
00751 

Here is the caller graph for this function:

def MoinMoin.formatter.text_docbook.Formatter._addTitleElement (   self,
  titleTxt,
  targetNode = None 
) [private]

Definition at line 702 of file text_docbook.py.

00702 
00703     def _addTitleElement(self, titleTxt, targetNode=None):
00704         if not targetNode:
00705             targetNode = self.cur
00706         self._addTextElem(targetNode, "title", titleTxt)

Here is the call graph for this function:

Moin adds the url as the text to a link, if no text is specified.
Docbook does it when a docbook is rendered, so we don't want moin to
do it and so if the url is exactly the same as the text node inside
the ulink, we remove the text node.

Definition at line 729 of file text_docbook.py.

00729 
00730     def _cleanupUlinkNode(self):
00731         """
00732         Moin adds the url as the text to a link, if no text is specified.
00733         Docbook does it when a docbook is rendered, so we don't want moin to
00734         do it and so if the url is exactly the same as the text node inside
00735         the ulink, we remove the text node.
00736         """
00737         if self.cur.nodeName == "ulink" and len(self.cur.childNodes) == 1 \
00738                 and self.cur.firstChild.nodeType == Node.TEXT_NODE \
00739                 and self.cur.firstChild.nodeValue.strip() == self.cur.getAttribute('url').strip():
00740             self.cur.removeChild(self.cur.firstChild)

Here is the caller graph for this function:

Takes the CSS styling information and converts it to a dict

Definition at line 707 of file text_docbook.py.

00707 
00708     def _convertStylesToDict(self, styles):
00709         '''Takes the CSS styling information and converts it to a dict'''
00710         attrs = {}
00711         for s in styles.split(";"):
00712             if s.strip(' "') == "":
00713                 continue
00714             if ":" not in s:
00715                 continue
00716             (key, value) = s.split(":", 1)
00717             key = key.strip(' "')
00718             value = value.strip(' "')
00719 
00720             if key == 'vertical-align':
00721                 key = 'valign'
00722             elif key == 'text-align':
00723                 key = 'align'
00724             elif key == 'background-color':
00725                 key = 'bgcolor'
00726 
00727             attrs[key] = value
00728         return attrs

Here is the caller graph for this function:

def MoinMoin.formatter.text_docbook.Formatter._copyExternalNodes (   self,
  nodes,
  deep = 1,
  target = None,
  exclude = () 
) [private]

Util functions ##################################################.

Definition at line 634 of file text_docbook.py.

00634 
00635     def _copyExternalNodes(self, nodes, deep=1, target=None, exclude=()):
00636         if not target:
00637             target = self.cur
00638 
00639         for node in nodes:
00640             if node.nodeName in exclude:
00641                 pass
00642             elif target.nodeName == "para" and node.nodeName == "para":
00643                 self._copyExternalNodes(node.childNodes, target=target)
00644                 self.cur = target.parentNode
00645             else:
00646                 target.appendChild(self.doc.importNode(node, deep))

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.formatter.text_docbook.Formatter._emitComment (   self,
  text 
) [private]

Definition at line 647 of file text_docbook.py.

00647 
00648     def _emitComment(self, text):
00649         text = text.replace("--", "- -") # There cannot be "--" in XML comment
00650         self.cur.appendChild(self.doc.createComment(text))

Here is the caller graph for this function:

def MoinMoin.formatter.text_docbook.Formatter._handleFormatting (   self,
  name,
  on,
  attributes = () 
) [private]

Definition at line 672 of file text_docbook.py.

00672 
00673     def _handleFormatting(self, name, on, attributes=()):
00674         # We add all the elements we create to the list of elements that should not contain a section
00675         if name not in self.section_should_break:
00676             self.section_should_break.append(name)
00677         return self._handleNode(name, on, attributes)

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.formatter.text_docbook.Formatter._handleNode (   self,
  name,
  on,
  attributes = () 
) [private]

Definition at line 651 of file text_docbook.py.

00651 
00652     def _handleNode(self, name, on, attributes=()):
00653         if on:
00654             node = self.doc.createElement(name)
00655             self.cur.appendChild(node)
00656             if len(attributes) > 0:
00657                 for name, value in attributes:
00658                     node.setAttribute(name, value)
00659             self.cur = node
00660         else:
00661             """
00662                 Because we prevent para inside para, we might get extra "please
00663                 exit para" when we are no longer inside one.
00664 
00665                 TODO: Maybe rethink the para in para case
00666             """
00667             if name == "para" and self.cur.nodeName != "para":
00668                 return ""
00669 
00670             self.cur = self.cur.parentNode
00671         return ""

Here is the caller graph for this function:

def MoinMoin.formatter.text_docbook.Formatter._hasContent (   self,
  node 
) [private]

Definition at line 689 of file text_docbook.py.

00689 
00690     def _hasContent(self, node):
00691         if node.attributes and len(node.attributes):
00692             return True
00693         for child in node.childNodes:
00694             if child.nodeType == Node.TEXT_NODE and child.nodeValue.strip():
00695                 return True
00696             elif child.nodeType == Node.CDATA_SECTION_NODE and child.nodeValue.strip():
00697                 return True
00698 
00699             if self._hasContent(child):
00700                 return True
00701         return False

Here is the call graph for this function:

Here is the caller graph for this function:

Walks all parents and checks if one is of a preformatted type, which
   means the child would need to be preformatted == embedded in a cdata
   section

Definition at line 678 of file text_docbook.py.

00678 
00679     def _isInsidePreformatted(self):
00680         """Walks all parents and checks if one is of a preformatted type, which
00681            means the child would need to be preformatted == embedded in a cdata
00682            section"""
00683         n = self.cur
00684         while n:
00685             if n.nodeName in ("screen", "programlisting"):
00686                 return True
00687             n = n.parentNode
00688         return False

Here is the caller graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 378 of file text_docbook.py.

00378 
00379     def anchordef(self, name):
00380         self._handleNode("anchor", True, attributes=(('id', name), ))
00381         self._handleNode("anchor", False)
00382         return ""

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.anchorlink (   self,
  on,
  name = '',
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 383 of file text_docbook.py.

00383 
00384     def anchorlink(self, on, name='', **kw):
00385         linkid = kw.get('id', None)
00386         attrs = []
00387         if name != '':
00388             attrs.append(('endterm', name))
00389         if id is not None:
00390             attrs.append(('linkend', linkid))
00391         elif name != '':
00392             attrs.append(('linkend', name))
00393 
00394         return self._handleNode("link", on, attrs)

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.attachment_drawing (   self,
  url,
  text,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 430 of file text_docbook.py.

00430 
00431     def attachment_drawing(self, url, text, **kw):
00432         _ = self.request.getText
00433         pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
00434         fname = wikiutil.taintfilename(filename)
00435         drawing = fname
00436         fname = fname + ".png"
00437         filename = filename + ".png"
00438         fpath = AttachFile.getFilename(self.request, pagename, fname)
00439         if not os.path.exists(fpath):
00440             return self.text("[drawing:%s]" % url)
00441         else:
00442             src = AttachFile.getAttachUrl(pagename, filename, self.request, addts=1)
00443             return self.image(alt=drawing, src=src, html_class="drawing")

Here is the call graph for this function:

Figures out the absolute path to the image and then hands over to
the image function. Any title is also handed over, and an additional
title suggestion is made based on filename. The image function will
use the suggestion if no other text alternative is found.

If the file is not found, then a simple text will replace it.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 408 of file text_docbook.py.

00408 
00409     def attachment_image(self, url, **kw):
00410         """
00411         Figures out the absolute path to the image and then hands over to
00412         the image function. Any title is also handed over, and an additional
00413         title suggestion is made based on filename. The image function will
00414         use the suggestion if no other text alternative is found.
00415 
00416         If the file is not found, then a simple text will replace it.
00417         """
00418         _ = self.request.getText
00419         pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
00420         fname = wikiutil.taintfilename(filename)
00421         fpath = AttachFile.getFilename(self.request, pagename, fname)
00422         if not os.path.exists(fpath):
00423             return self.text("[attachment:%s]" % url)
00424         else:
00425             return self.image(
00426                 src=AttachFile.getAttachUrl(pagename, filename, self.request, addts=1),
00427                 attachment_title=url,
00428                 **kw)
00429 

Here is the call graph for this function:

def MoinMoin.formatter.FormatterBase.attachment_inlined (   self,
  url,
  text,
  kw 
) [inherited]

Reimplemented in MoinMoin.formatter.text_gedit.Formatter.

Definition at line 123 of file __init__.py.

00123 
00124     def attachment_inlined(self, url, text, **kw):
00125         from MoinMoin.action import AttachFile
00126         import os
00127         _ = self.request.getText
00128         pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
00129         fname = wikiutil.taintfilename(filename)
00130         fpath = AttachFile.getFilename(self.request, pagename, fname)
00131         ext = os.path.splitext(filename)[1]
00132         Parser = wikiutil.getParserForExtension(self.request.cfg, ext)
00133         if Parser is not None:
00134             try:
00135                 content = file(fpath, 'r').read()
00136                 # Try to decode text. It might return junk, but we don't
00137                 # have enough information with attachments.
00138                 content = wikiutil.decodeUnknownInput(content)
00139                 colorizer = Parser(content, self.request, filename=filename)
00140                 colorizer.format(self)
00141             except IOError:
00142                 pass
00143 
00144         return (self.attachment_link(1, url) +
00145                 self.text(text) +
00146                 self.attachment_link(0))

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.attachment_link (   self,
  on,
  url = None,
  kw 
)

Attachments ######################################################.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 397 of file text_docbook.py.

00397 
00398     def attachment_link(self, on, url=None, **kw):
00399         assert on in (0, 1, False, True) # make sure we get called the new way, not like the 1.5 api was
00400         # we do not output a "upload link" when outputting docbook
00401         if on:
00402             pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
00403             fname = wikiutil.taintfilename(filename)
00404             target = AttachFile.getAttachUrl(pagename, filename, self.request)
00405             return self.url(1, target, title="attachment:%s" % url)
00406         else:
00407             return self.url(0)

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.big (   self,
  on,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 825 of file text_docbook.py.

00825 
00826     def big(self, on, **kw):
00827         if on:
00828             self._emitComment('"~+bigger+~" is not applicable to DocBook')
00829         return ""

Here is the call graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 262 of file text_docbook.py.

00262 
00263     def bullet_list(self, on, **kw):
00264         return self._handleNode("itemizedlist", on)

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.code (   self,
  on,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 232 of file text_docbook.py.

00232 
00233     def code(self, on, **kw):
00234         # Let's prevent empty code
00235         if not on:
00236             if not self._hasContent(self.cur):
00237                 oldnode = self.cur
00238                 self.cur = oldnode.parentNode
00239                 self.cur.removeChild(oldnode)
00240                 return ""
00241         return self._handleFormatting("code", on)

Here is the call graph for this function:

def MoinMoin.formatter.FormatterBase.code_area (   self,
  on,
  code_id,
  kw 
) [inherited]

Definition at line 248 of file __init__.py.

00248 
00249     def code_area(self, on, code_id, **kw):
00250         raise NotImplementedError

def MoinMoin.formatter.text_docbook.Formatter.code_area (   self,
  on,
  code_id,
  code_type = None,
  show = 0,
  start = -1,
  step = -1,
  msg = None 
)

Code area #######################################################.

Creates a formatted code region using screen or programlisting,
depending on if a programming language was defined (code_type).

The code_id is not used for anything in this formatter, but is just
there to remain compatible with the HTML formatter's function.

Line numbering is supported natively by DocBook so if linenumbering
is requested the relevant attribute will be set.

Call once with on=1 to start the region, and a second time
with on=0 to end it.

Definition at line 500 of file text_docbook.py.

00500 
00501     def code_area(self, on, code_id, code_type=None, show=0, start=-1, step=-1, msg=None):
00502         """Creates a formatted code region using screen or programlisting,
00503         depending on if a programming language was defined (code_type).
00504 
00505         The code_id is not used for anything in this formatter, but is just
00506         there to remain compatible with the HTML formatter's function.
00507 
00508         Line numbering is supported natively by DocBook so if linenumbering
00509         is requested the relevant attribute will be set.
00510 
00511         Call once with on=1 to start the region, and a second time
00512         with on=0 to end it.
00513         """
00514 
00515         if not on:
00516             return self._handleNode(None, on)
00517 
00518         show = show and 'numbered' or 'unnumbered'
00519         if start < 1:
00520             start = 1
00521 
00522         programming_languages = {"ColorizedJava": "java",
00523                                  "ColorizedPython": "python",
00524                                  "ColorizedCPlusPlus": "c++",
00525                                  "ColorizedPascal": "pascal",
00526                                 }
00527 
00528         if code_type is None:
00529             attrs = (('linenumbering', show),
00530                      ('startinglinenumber', str(start)),
00531                      ('format', 'linespecific'),
00532                      )
00533             return self._handleNode("screen", on, attributes=attrs)
00534         else:
00535             if programming_languages.has_key(code_type):
00536                 code_type = programming_languages[code_type]
00537 
00538             attrs = (('linenumbering', show),
00539                      ('startinglinenumber', str(start)),
00540                      ('language', code_type),
00541                      ('format', 'linespecific'),
00542                      )
00543             return self._handleNode("programlisting", on, attributes=attrs)

Here is the call graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 544 of file text_docbook.py.

00544 
00545     def code_line(self, on):
00546         if on:
00547             self.cur.appendChild(self.doc.createTextNode('\n'))
00548         return ''

def MoinMoin.formatter.text_docbook.Formatter.code_token (   self,
  on,
  tok_type 
)
DocBook has some support for semantic annotation of code so the
known tokens will be mapped to DocBook entities.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 549 of file text_docbook.py.

00549 
00550     def code_token(self, on, tok_type):
00551         """
00552         DocBook has some support for semantic annotation of code so the
00553         known tokens will be mapped to DocBook entities.
00554         """
00555         toks_map = {'ID': 'methodname',
00556                     'Operator': '',
00557                     'Char': '',
00558                     'Comment': 'lineannotation',
00559                     'Number': '',
00560                     'String': 'phrase',
00561                     'SPChar': '',
00562                     'ResWord': 'token',
00563                     'ConsWord': 'symbol',
00564                     'Error': 'errortext',
00565                     'ResWord2': 'type',
00566                     'Special': '',
00567                     'Preprc': '',
00568                     'Text': '',
00569                    }
00570         if toks_map.has_key(tok_type) and toks_map[tok_type]:
00571             return self._handleFormatting(toks_map[tok_type], on)
00572         else:
            return ""

Here is the call graph for this function:

def MoinMoin.formatter.FormatterBase.comment (   self,
  text,
  kw 
) [inherited]

Reimplemented in MoinMoin.formatter.text_gedit.Formatter.

Definition at line 389 of file __init__.py.

00389 
00390     def comment(self, text, **kw):
00391         return ""

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 300 of file text_docbook.py.

00300 
00301     def definition_desc(self, on, **kw):
00302         if on:
00303             if self.cur.nodeName == "glossentry":
00304                 # Good, we can add it here.
00305                 self._handleNode("glossdef", on)
00306                 return ""
00307 
00308             # We are somewhere else, let's see...
00309             if self.cur.nodeName != "glosslist":
00310                 self._emitComment("Trying to add a definition, but we arent in a glosslist")
00311                 return ""
00312             if not self.cur.lastChild or self.cur.lastChild.nodeName != "glossentry":
00313                 self._emitComment("Trying to add a definition, but there is no entry")
00314                 return ""
00315 
00316             # Found it, calling again
00317             self.cur = self.cur.lastChild
00318             return self.definition_desc(on)
00319         else:
00320             if not self._hasContent(self.cur):
00321                 # Seems no valuable info was added
00322                 assert(self.cur.nodeName == "glossdef")
00323                 toRemove = self.cur
00324                 self.cur = toRemove.parentNode
00325                 self.cur.removeChild(toRemove)
00326 
00327             while self.cur.nodeName != "glosslist":
00328                 self.cur = self.cur.parentNode
00329         return ""

Here is the call graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 281 of file text_docbook.py.

00281 
00282     def definition_list(self, on, **kw):
00283         return self._handleNode("glosslist", on)

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.definition_term (   self,
  on,
  compact = 0,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 284 of file text_docbook.py.

00284 
00285     def definition_term(self, on, compact=0, **kw):
00286         if on:
00287             self._handleNode("glossentry", on)
00288             self._handleNode("glossterm", on)
00289         else:
00290             if self._hasContent(self.cur):
00291                 self._handleNode("glossterm", on)
00292                 self._handleNode("glossentry", on)
00293             else:
00294                 # No term info :(
00295                 term = self.cur
00296                 entry = term.parentNode
00297                 self.cur = entry.parentNode
00298                 self.cur.removeChild(entry)
00299         return ""

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.div (   self,
  on,
  kw 
)
A div cannot really be supported in DocBook as it carries no
semantic meaning, but the special cases can be handled when the class
of the div carries the information.

A dictionary is used for mapping between class names and the
corresponding DocBook element.

A MoinMoin comment is represented in DocBook by the remark element.

The rest of the known classes are the admonitions in DocBook:
warning, caution, important, note and hint

Note: The remark entity can only contain inline elements, so it is
      very likely that the use of a comment div will produce invalid
      DocBook.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 855 of file text_docbook.py.

00855 
00856     def div(self, on, **kw):
00857         """A div cannot really be supported in DocBook as it carries no
00858         semantic meaning, but the special cases can be handled when the class
00859         of the div carries the information.
00860 
00861         A dictionary is used for mapping between class names and the
00862         corresponding DocBook element.
00863 
00864         A MoinMoin comment is represented in DocBook by the remark element.
00865 
00866         The rest of the known classes are the admonitions in DocBook:
00867         warning, caution, important, note and hint
00868 
00869         Note: The remark entity can only contain inline elements, so it is
00870               very likely that the use of a comment div will produce invalid
00871               DocBook.
00872         """
00873         # Map your styles to docbook elements.
00874         # Even though comment is right now the only one that needs to be
00875         # mapped, having two different ways is more complicated than having
00876         # a single common way. Code clarity and generality first, especially
00877         # since we might want to do more div to docbook mappings in the future.
00878         class_to_docbook = {"warning":   "warning",
00879                             "caution":   "caution",
00880                             "important": "important",
00881                             "note":      "note",
00882                             "tip":       "tip",
00883                             "comment":   "remark"}
00884 
00885         if on and kw.get('css_class'):
00886             css_classes = kw.get('css_class').split()
00887             for style in class_to_docbook.keys():
00888                 if style in css_classes:
00889                     return self._handleNode(class_to_docbook[style], on)
00890 
00891         elif not on:
00892             if self.cur.nodeName in class_to_docbook.values():
00893                 return self._handleNode(self.cur.nodeName, on)
00894 
00895         return ""

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.emphasis (   self,
  on,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 211 of file text_docbook.py.

00211 
00212     def emphasis(self, on, **kw):
00213         return self._handleFormatting("emphasis", on)

Here is the call graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 98 of file text_docbook.py.

00098 
00099     def endContent(self):
00100         if self.include_kludge:
00101             return self.endDocument()
00102         return ""

Here is the call graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 103 of file text_docbook.py.

00103 
00104     def endDocument(self):
00105         from xml.dom.ext import PrettyPrint, Print
00106         import StringIO
00107 
00108         f = StringIO.StringIO()
00109         Print(self.doc, f)
00110         txt = f.getvalue()
00111         f.close()
00112 
00113         self.cur = None
00114         return txt

def MoinMoin.formatter.FormatterBase.escapedText (   self,
  on,
  kw 
) [inherited]
This allows emitting text as-is, anything special will
    be escaped (at least in HTML, some text output format
    would possibly do nothing here)

Reimplemented in MoinMoin.formatter.text_html.Formatter, and MoinMoin.formatter.dom_xml.Formatter.

Definition at line 382 of file __init__.py.

00382 
00383     def escapedText(self, on, **kw):
00384         """ This allows emitting text as-is, anything special will
00385             be escaped (at least in HTML, some text output format
00386             would possibly do nothing here)
00387         """
00388         return ""

def MoinMoin.formatter.text_docbook.Formatter.heading (   self,
  on,
  depth,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 145 of file text_docbook.py.

00145 
00146     def heading(self, on, depth, **kw):
00147         while self.cur.nodeName in self.section_should_break:
00148             self.cur = self.cur.parentNode
00149 
00150         if on:
00151             # try to go to higher level if needed
00152             if depth <= self.curdepth:
00153                 # number of levels we want to go higher
00154                 numberOfLevels = self.curdepth - depth + 1
00155                 for dummy in range(numberOfLevels):
00156                     # find first non section node
00157                     while not self.cur.nodeName in self._can_contain_section:
00158                         self.cur = self.cur.parentNode
00159 
00160                     if self.cur.nodeName == "section":
00161                         self.cur = self.cur.parentNode
00162 
00163             section = self.doc.createElement("section")
00164             self.cur.appendChild(section)
00165             self.cur = section
00166 
00167             title = self.doc.createElement("title")
00168             self.cur.appendChild(title)
00169             self.cur = title
00170             self.curdepth = depth
00171         else:
00172             self.cur = self.cur.parentNode
00173 
00174         return ""

def MoinMoin.formatter.text_docbook.Formatter.highlight (   self,
  on,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 217 of file text_docbook.py.

00217 
00218     def highlight(self, on, **kw):
00219         return self._handleFormatting("emphasis", on, (('role', 'highlight'), ))

Here is the call graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 494 of file text_docbook.py.

00494 
00495     def icon(self, type):
00496         return '' # self.request.theme.make_icon(type)
00497 

def MoinMoin.formatter.text_docbook.Formatter.image (   self,
  src = None,
  kw 
)

Images and Smileys ##############################################.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 446 of file text_docbook.py.

00446 
00447     def image(self, src=None, **kw):
00448         if src:
00449             kw['src'] = src
00450         media = self.doc.createElement('inlinemediaobject')
00451 
00452         imagewrap = self.doc.createElement('imageobject')
00453         media.appendChild(imagewrap)
00454 
00455         image = self.doc.createElement('imagedata')
00456         if kw.has_key('src'):
00457             src = kw['src']
00458             if src.startswith("/"):
00459                 # convert to absolute path:
00460                 src = self.request.url_root + src
00461             image.setAttribute('fileref', src)
00462         if kw.has_key('width'):
00463             image.setAttribute('width', str(kw['width']))
00464         if kw.has_key('height'):
00465             image.setAttribute('depth', str(kw['height']))
00466         imagewrap.appendChild(image)
00467 
00468         # Look for any suitable title, order is important.
00469         title = ''
00470         for a in ('title', 'html_title', 'alt', 'html_alt', 'attachment_title'):
00471             if kw.has_key(a):
00472                 title = kw[a]
00473                 break
00474         if title:
00475             txtcontainer = self.doc.createElement('textobject')
00476             self._addTextElem(txtcontainer, "phrase", title)
00477             media.appendChild(txtcontainer)
00478 
00479         self.cur.appendChild(media)
00480         return ""

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.interwikilink (   self,
  on,
  interwiki = '',
  pagename = '',
  kw 
)
calls pagelink() for internal interwikilinks
    to make sure they get counted for self.pagelinks.
    IMPORTANT: on and off must be called with same parameters, see
       also the text_html formatter.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 349 of file text_docbook.py.

00349 
00350     def interwikilink(self, on, interwiki='', pagename='', **kw):
00351         if not on:
00352             return self.url(on, **kw)
00353 
00354         wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_interwiki(self.request, interwiki, pagename)
00355         wikiurl = wikiutil.mapURL(self.request, wikiurl)
00356         href = wikiutil.join_wiki(wikiurl, wikitail)
00357         if kw.has_key("anchor"):
00358             href="%s#%s"%(href, kw['anchor'])
00359 
00360         if pagename == self.page.page_name:
00361             kw['is_self']=True
00362 
00363         return self.url(on, href, **kw)

Here is the call graph for this function:

def MoinMoin.formatter.FormatterBase.lang (   self,
  on,
  lang_name 
) [inherited]
def MoinMoin.formatter.FormatterBase.line_anchordef (   self,
  lineno 
) [inherited]

Reimplemented in MoinMoin.formatter.text_html.Formatter, MoinMoin.formatter.dom_xml.Formatter, and MoinMoin.formatter.text_gedit.Formatter.

Definition at line 150 of file __init__.py.

00150 
00151     def line_anchordef(self, lineno):
00152         return ""

def MoinMoin.formatter.FormatterBase.line_anchorlink (   self,
  on,
  lineno = 0 
) [inherited]

Reimplemented in MoinMoin.formatter.text_html.Formatter, and MoinMoin.formatter.text_gedit.Formatter.

Definition at line 156 of file __init__.py.

00156 
00157     def line_anchorlink(self, on, lineno=0):
00158         return ""

def MoinMoin.formatter.text_docbook.Formatter.linebreak (   self,
  preformatted = 1 
)
If preformatted, it will simply output a linebreak.
If we are in a paragraph, we will close it, and open another one.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 191 of file text_docbook.py.

00191 
00192     def linebreak(self, preformatted=1):
00193         """
00194         If preformatted, it will simply output a linebreak.
00195         If we are in a paragraph, we will close it, and open another one.
00196         """
00197         if preformatted:
00198             self.text('\\n')
00199         elif self.cur.nodeName == "para":
00200             self.paragraph(0)
00201             self.paragraph(1)
00202         else:
00203             self._emitComment("Warning: Probably not emitting right sort of linebreak")
00204             self.text('\n')
00205         return ""

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.listitem (   self,
  on,
  style = None,
  kw 
)

Definition at line 265 of file text_docbook.py.

00265 
00266     def listitem(self, on, style=None, **kw):
00267         if self.cur.nodeName == "glosslist" or self.cur.nodeName == "glossentry":
00268             return self.definition_desc(on)
00269         if on and self.cur.nodeName == "listitem":
00270             """If we are inside a listitem, and someone wants to create a new one, it
00271             means they forgot to close the old one, and we need to do it for them."""
00272             self.listitem(0)
00273 
00274         args = []
00275         if on and style:
00276             styles = self._convertStylesToDict(style)
00277             if styles.has_key('list-style-type'):
00278                 args.append(('override', styles['list-style-type']))
00279 
00280         return self._handleNode("listitem", on, attributes=args)

Here is the call graph for this function:

def MoinMoin.formatter.FormatterBase.listitem (   self,
  on,
  kw 
) [inherited]

Reimplemented in MoinMoin.formatter.text_html.Formatter, MoinMoin.formatter.dom_xml.Formatter, MoinMoin.formatter.text_plain.Formatter, MoinMoin.formatter.text_xml.Formatter, and MoinMoin.formatter.groups.Formatter.

Definition at line 279 of file __init__.py.

00279 
00280     def listitem(self, on, **kw):
00281         raise NotImplementedError

Here is the caller graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.macro (   self,
  macro_obj,
  name,
  args,
  markup = None 
)

Macro ###########################################################.

As far as the DocBook formatter is conserned there are three
kinds of macros: Bad, Handled and Unknown.

The Bad ones are the ones that are known not to work, and are on its
blacklist. They will be ignored and an XML comment will be written
noting that the macro is not supported.

Handled macros are such macros that code is written to handle them.
For example for the FootNote macro it means that instead of executing
the macro, a DocBook footnote entity is created, with the relevant
pieces of information filles in.

The Unknown are handled by executing the macro and capturing any
textual output. There shouldn't be any textual output since macros
should call formatter methods. This is unfortunately not always true,
so the output it is then fed in to an xml parser and the
resulting nodes copied to the DocBook-dom tree. If the output is not
valid xml then a comment is written in the DocBook that the macro
should be fixed.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 575 of file text_docbook.py.

00575 
00576     def macro(self, macro_obj, name, args, markup=None):
00577         """As far as the DocBook formatter is conserned there are three
00578         kinds of macros: Bad, Handled and Unknown.
00579 
00580         The Bad ones are the ones that are known not to work, and are on its
00581         blacklist. They will be ignored and an XML comment will be written
00582         noting that the macro is not supported.
00583 
00584         Handled macros are such macros that code is written to handle them.
00585         For example for the FootNote macro it means that instead of executing
00586         the macro, a DocBook footnote entity is created, with the relevant
00587         pieces of information filles in.
00588 
00589         The Unknown are handled by executing the macro and capturing any
00590         textual output. There shouldn't be any textual output since macros
00591         should call formatter methods. This is unfortunately not always true,
00592         so the output it is then fed in to an xml parser and the
00593         resulting nodes copied to the DocBook-dom tree. If the output is not
00594         valid xml then a comment is written in the DocBook that the macro
00595         should be fixed.
00596 
00597         """
00598         # Another alternative would be to feed the output to rawHTML or even
00599         # combining these two approaches. The _best_ alternative would be to
00600         # fix the macros.
00601         excludes=("articleinfo", "title")
00602 
00603         if name in self.blacklisted_macros:
00604             self._emitComment("The macro %s doesn't work with the DocBook formatter." % name)
00605 
00606         elif name == "FootNote":
00607             footnote = self.doc.createElement('footnote')
00608             self._addTextElem(footnote, "para", str(args))
00609             self.cur.appendChild(footnote)
00610 
00611         elif name == "Include":
00612             was_in_para = self.cur.nodeName == "para"
00613             if was_in_para:
00614                 self.paragraph(0)
00615             text = FormatterBase.macro(self, macro_obj, name, args)
00616             if text.strip():
00617                 self._copyExternalNodes(Sax.FromXml(text).documentElement.childNodes, exclude=excludes)
00618             if was_in_para:
00619                 self.paragraph(1)
00620 
00621         else:
00622             text = FormatterBase.macro(self, macro_obj, name, args)
00623             if text:
00624                 from xml.parsers.expat import ExpatError
00625                 try:
00626                     xml_dom = Sax.FromXml(text).documentElement.childNodes
00627                     self._copyExternalNodes(xml_dom, exclude=excludes)
00628                 except ExpatError:
00629                     self._emitComment("The macro %s caused an error and should be blacklisted. It returned the data '%s' which caused the docbook-formatter to choke. Please file a bug." % (name, text))
00630 
00631         return u""

Here is the call graph for this function:

def MoinMoin.formatter.FormatterBase.make_id_unique (   self,
  id 
) [inherited]
Take an ID and make it unique in the current namespace.

Definition at line 406 of file __init__.py.

00406 
00407     def make_id_unique(self, id):
00408         '''
00409         Take an ID and make it unique in the current namespace.
00410         '''
00411         ns = self.request.uid_generator.include_id
00412         if not ns is None:
00413             ns = self.sanitize_to_id(ns)
00414         id = self.sanitize_to_id(id)
00415         id = self.request.uid_generator(id, ns)
00416         return id

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.formatter.FormatterBase.nowikiword (   self,
  text 
) [inherited]

Reimplemented in MoinMoin.formatter.text_gedit.Formatter.

Definition at line 184 of file __init__.py.

00184 
00185     def nowikiword(self, text):
00186         return self.text(text)

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.number_list (   self,
  on,
  type = None,
  start = None,
  kw 
)

Lists ###########################################################.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 248 of file text_docbook.py.

00248 
00249     def number_list(self, on, type=None, start=None, **kw):
00250         docbook_ol_types = {'1': "arabic",
00251                             'a': "loweralpha",
00252                             'A': "upperalpha",
00253                             'i': "lowerroman",
00254                             'I': "upperroman"}
00255 
00256         if type and docbook_ol_types.has_key(type):
00257             attrs = [("numeration", docbook_ol_types[type])]
00258         else:
00259             attrs = []
00260 
00261         return self._handleNode('orderedlist', on, attrs)

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.pagelink (   self,
  on,
  pagename = '',
  page = None,
  kw 
)

Links ########################################################### TODO: Fix anchors to documents which are included.

Needs probably to be a postprocessing rule. Could be done by having the anchors have the "linkend" value of PageName::anchor. Then at post process the following would be done for all urls:

  • get all ulinks with an anchor part in their url
  • get the ulink's PageName::anchor -part by removing baseurl part
  • if any of our <anchor> elements have the same PageName::anchor value as our <ulink>, then replace the ulink with a link element. Note: This would the case when someone wants to link to a section on the original webpage impossible. The link would instead point within the docbook page and not to the webpage.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 345 of file text_docbook.py.

00345 
00346     def pagelink(self, on, pagename='', page=None, **kw):
00347         FormatterBase.pagelink(self, on, pagename, page, **kw)
00348         return self.interwikilink(on, 'Self', pagename, **kw)

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.paragraph (   self,
  on,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 175 of file text_docbook.py.

00175 
00176     def paragraph(self, on, **kw):
00177         FormatterBase.paragraph(self, on)
00178 
00179         # Let's prevent empty paras
00180         if not on:
00181             if not self._hasContent(self.cur):
00182                 oldnode = self.cur
00183                 self.cur = oldnode.parentNode
00184                 self.cur.removeChild(oldnode)
00185                 return ""
00186 
00187         # Let's prevent para inside para
00188         if on and self.cur.nodeName == "para":
00189             return ""
00190         return self._handleNode("para", on)

Here is the call graph for this function:

def MoinMoin.formatter.FormatterBase.parser (   self,
  parser_name,
  lines 
) [inherited]
parser_name MUST be valid!
    writes out the result instead of returning it!

Reimplemented in MoinMoin.formatter.dom_xml.Formatter, and MoinMoin.formatter.text_gedit.Formatter.

Definition at line 331 of file __init__.py.

00331 
00332     def parser(self, parser_name, lines):
00333         """ parser_name MUST be valid!
00334             writes out the result instead of returning it!
00335         """
00336         # attention: this is copied into text_python!
00337         parser = wikiutil.searchAndImportPlugin(self.request.cfg, "parser", parser_name)
00338         args = None
00339         if lines:
00340             args = self._get_bang_args(lines[0])
00341             logging.debug("formatter.parser: parser args %r" % args)
00342             if args is not None:
00343                 lines = lines[1:]
00344         if lines and not lines[0]:
00345             lines = lines[1:]
00346         if lines and not lines[-1].strip():
00347             lines = lines[:-1]
00348         p = parser('\n'.join(lines), self.request, format_args=args)
00349         p.format(self)
00350         del p
00351         return ''

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 242 of file text_docbook.py.

00242 
00243     def preformatted(self, on, **kw):
00244         return self._handleFormatting("screen", on)
00245 

Here is the call graph for this function:

def MoinMoin.formatter.FormatterBase.qualify_id (   self,
  id 
) [inherited]
Take an ID and return a string that is qualified by
the current namespace; this default implementation
is suitable if the dot ('.') is valid in IDs for your
formatter.

Definition at line 417 of file __init__.py.

00417 
00418     def qualify_id(self, id):
00419         '''
00420         Take an ID and return a string that is qualified by
00421         the current namespace; this default implementation
00422         is suitable if the dot ('.') is valid in IDs for your
00423         formatter.
00424         '''
00425         ns = self.request.uid_generator.include_id
00426         if not ns is None:
00427             ns = self.sanitize_to_id(ns)
00428             return '%s.%s' % (ns, id)
00429         return id

Here is the call graph for this function:

Here is the caller graph for this function:

This allows emitting pre-formatted HTML markup, and should be
    used wisely (i.e. very seldom).

    Using this event while generating content results in unwanted
    effects, like loss of markup or insertion of CDATA sections
    when output goes to XML formats.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 830 of file text_docbook.py.

00830 
00831     def rawHTML(self, markup):
00832         if markup.strip() == "":
00833             return ""
00834 
00835         if "<" not in markup and ">" not in markup:
00836             # Seems there are no tags.
00837             # Let's get all the "entity references".
00838             cleaned = markup
00839             import re
00840             entities = re.compile("&(?P<e>[a-zA-Z]+);").findall(cleaned)
00841             from htmlentitydefs import name2codepoint
00842             for ent in entities:
00843                 if name2codepoint.has_key(ent):
00844                     cleaned = cleaned.replace("&%s;" % ent, unichr(name2codepoint[ent]))
00845 
00846             # Then we replace all escaped unicodes.
00847             escapedunicodes = re.compile("&#(?P<h>[0-9]+);").findall(markup)
00848             for uni in escapedunicodes:
00849                 cleaned = cleaned.replace("&#%s;" % uni, unichr(int(uni)))
00850 
00851             self.text(cleaned)
00852 
00853         self._emitComment("RAW HTML: "+markup)
00854         return ""

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.rule (   self,
  size = 0,
  kw 
)

Not supported ###################################################.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 816 of file text_docbook.py.

00816 
00817     def rule(self, size=0, **kw):
00818         self._emitComment('rule (<hr>) is not applicable to DocBook')
00819         return ""

Here is the call graph for this function:

def MoinMoin.formatter.FormatterBase.sanitize_to_id (   self,
  text 
) [inherited]
Take 'text' and return something that is a valid ID
for this formatter.
The default returns the first non-space character of the string.

Because of the way this is used, it must be idempotent,
i.e. calling it on an already sanitized id must yield the
original id.

Reimplemented in MoinMoin.formatter.text_html.Formatter.

Definition at line 394 of file __init__.py.

00394 
00395     def sanitize_to_id(self, text):
00396         '''
00397         Take 'text' and return something that is a valid ID
00398         for this formatter.
00399         The default returns the first non-space character of the string.
00400 
00401         Because of the way this is used, it must be idempotent,
00402         i.e. calling it on an already sanitized id must yield the
00403         original id.
00404         '''
00405         return text.strip()[:1]

Here is the caller graph for this function:

def MoinMoin.formatter.FormatterBase.set_highlight_re (   self,
  hi_re = None 
) [inherited]
set the highlighting regular expression (e.g. for search terms)

@param hi_re: either a valid re as str/unicode (you may want to use
      re.escape before passing generic strings!) or a compiled
      re object. raises re.error for invalid re.

Definition at line 43 of file __init__.py.

00043 
00044     def set_highlight_re(self, hi_re=None):
00045         """ set the highlighting regular expression (e.g. for search terms)
00046 
00047         @param hi_re: either a valid re as str/unicode (you may want to use
00048                       re.escape before passing generic strings!) or a compiled
00049                       re object. raises re.error for invalid re.
00050         """
00051         if isinstance(hi_re, (str, unicode)):
00052             hi_re = re.compile(hi_re, re.U + re.IGNORECASE)
00053         self._highlight_re = hi_re

def MoinMoin.formatter.FormatterBase.setPage (   self,
  page 
) [inherited]

Reimplemented in MoinMoin.formatter.dom_xml.Formatter.

Definition at line 57 of file __init__.py.

00057 
00058     def setPage(self, page):
00059         self.page = page

def MoinMoin.formatter.text_docbook.Formatter.small (   self,
  on,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 820 of file text_docbook.py.

00820 
00821     def small(self, on, **kw):
00822         if on:
00823             self._emitComment('"~-smaller-~" is not applicable to DocBook')
00824         return ""

Here is the call graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 491 of file text_docbook.py.

00491 
00492     def smiley(self, text):
00493         return self.request.theme.make_icon(text)

def MoinMoin.formatter.text_docbook.Formatter.span (   self,
  on,
  kw 
)
A span cannot really be supported in DocBook as it carries no
semantic meaning, but the special case of a comment can be handled.

A comment is represented in DocBook by the remark element.

A comment span is recognized by the fact that it has the class
"comment". Other cases of div use are ignored.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 896 of file text_docbook.py.

00896 
00897     def span(self, on, **kw):
00898         """A span cannot really be supported in DocBook as it carries no
00899         semantic meaning, but the special case of a comment can be handled.
00900 
00901         A comment is represented in DocBook by the remark element.
00902 
00903         A comment span is recognized by the fact that it has the class
00904         "comment". Other cases of div use are ignored.
00905         """
00906         css_class = kw.get('css_class')
00907         if on and css_class and 'comment' in css_class.split():
00908             self._handleFormatting("remark", on)
00909         if not on and self.cur.nodeName == "remark":
00910             self._handleFormatting("remark", on)
00911         return ""
00912 
00913 

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.startContent (   self,
  content_id = "content",
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 93 of file text_docbook.py.

00093 
00094     def startContent(self, content_id="content", **kw):
00095         if self.include_kludge and not self.cur:
00096             return self.startDocument("OnlyAnIdiotWouldCreateSuchaPage")
00097         return ""

Here is the call graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 74 of file text_docbook.py.

00074 
00075     def startDocument(self, pagename):
00076         self.doc = dom.createDocument(None, self.doctype, dom.createDocumentType(
00077             self.doctype, "-//OASIS//DTD DocBook XML V4.4//EN",
00078             "http://www.docbook.org/xml/4.4/docbookx.dtd"))
00079 
00080         self.title = pagename
00081         self.root = self.doc.documentElement
00082 
00083         if not self.include_kludge and self.doctype == "article":
00084             info = self.doc.createElement("articleinfo")
00085             self.root.appendChild(info)
00086             self._addTitleElement(self.title, targetNode=info)
00087             self._addRevisionHistory(targetNode=info)
00088         else:
00089             self._addTitleElement(self.title, targetNode=self.root)
00090 
00091         self.cur = self.root
00092         return ""

def MoinMoin.formatter.text_docbook.Formatter.strike (   self,
  on,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 226 of file text_docbook.py.

00226 
00227     def strike(self, on, **kw):
00228         # does not yield <strike> using the HTML XSLT files here ...
00229         # but seems to be correct
00230         return self._handleFormatting("emphasis", on,
00231                                       (('role', 'strikethrough'), ))

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.strong (   self,
  on,
  kw 
)

Inline ##########################################################.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 208 of file text_docbook.py.

00208 
00209     def strong(self, on, **kw):
00210         return self._handleFormatting("emphasis", on, (('role', 'strong'), ))

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.sub (   self,
  on,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 223 of file text_docbook.py.

00223 
00224     def sub(self, on, **kw):
00225         return self._handleFormatting("subscript", on)

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.sup (   self,
  on,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 220 of file text_docbook.py.

00220 
00221     def sup(self, on, **kw):
00222         return self._handleFormatting("superscript", on)

Here is the call graph for this function:

def MoinMoin.formatter.FormatterBase.sysmsg (   self,
  on,
  kw 
) [inherited]
Emit a system message (embed it into the page).

    Normally used to indicate disabled options, or invalid markup.

Reimplemented in MoinMoin.formatter.text_html.Formatter, MoinMoin.formatter.dom_xml.Formatter, MoinMoin.formatter.text_xml.Formatter, and MoinMoin.formatter.text_plain.Formatter.

Definition at line 60 of file __init__.py.

00060 
00061     def sysmsg(self, on, **kw):
00062         """ Emit a system message (embed it into the page).
00063 
00064             Normally used to indicate disabled options, or invalid markup.
00065         """
00066         return ""

def MoinMoin.formatter.text_docbook.Formatter.table (   self,
  on,
  attrs = (),
  kw 
)

Tables ##########################################################.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 916 of file text_docbook.py.

00916 
00917     def table(self, on, attrs=(), **kw):
00918         if(on):
00919             if attrs:
00920                 self.curtable = Table(self, self.doc, self.cur, dict(attrs))
00921             else:
00922                 self.curtable = Table(self, self.doc, self.cur)
00923             self.cur = self.curtable.tableNode
00924         else:
00925             self.cur = self.curtable.finalizeTable()
00926             self.curtable = None
00927         return ""

def MoinMoin.formatter.text_docbook.Formatter.table_cell (   self,
  on,
  attrs = (),
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 936 of file text_docbook.py.

00936 
00937     def table_cell(self, on, attrs=(), **kw):
00938         if(on):
00939             if attrs:
00940                 self.cur = self.curtable.addCell(dict(attrs))
00941             else:
00942                 self.cur = self.curtable.addCell()
00943         return ""

def MoinMoin.formatter.text_docbook.Formatter.table_row (   self,
  on,
  attrs = (),
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 928 of file text_docbook.py.

00928 
00929     def table_row(self, on, attrs=(), **kw):
00930         if(on):
00931             if attrs:
00932                 self.curtable.addRow(dict(attrs))
00933             else:
00934                 self.cur = self.curtable.addRow()
00935         return ""

def MoinMoin.formatter.text_docbook.Formatter.text (   self,
  text,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 115 of file text_docbook.py.

00115 
00116     def text(self, text, **kw):
00117         if text == "\\n":
00118             srcText = "\n"
00119         else:
00120             srcText = text
00121 
00122         if srcText and self._isInsidePreformatted():
00123 
00124             if self.cur.lastChild is not None and self.cur.lastChild.nodeType == Node.CDATA_SECTION_NODE:
00125                 # We can add it to a previous CDATA section
00126                 self.cur.lastChild.nodeValue = self.cur.lastChild.nodeValue + srcText
00127             else:
00128                 # We create a new cdata section
00129                 self.cur.appendChild(self.doc.createCDATASection(srcText))
00130 
00131         elif self.cur.nodeName in self.wrap_text_in_para:
00132             """
00133             If we already wrapped one text item in a para, we should add to that para
00134             and not create a new one. Another question is if we should add a space?
00135             """
00136             if self.cur.lastChild is not None and self.cur.lastChild.nodeName == 'para':
00137                 self.cur.lastChild.appendChild(self.doc.createTextNode(srcText))
00138             else:
00139                 self.paragraph(1)
00140                 self.text(text)
00141                 self.paragraph(0)
00142         else:
00143             self.cur.appendChild(self.doc.createTextNode(srcText))
00144         return ""

Here is the call graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 481 of file text_docbook.py.

00481 
00482     def transclusion(self, on, **kw):
00483         # TODO, see text_html formatter
00484         self._emitComment('transclusion is not implemented in DocBook formatter')
00485         return ""

Here is the call graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 486 of file text_docbook.py.

00486 
00487     def transclusion_param(self, **kw):
00488         # TODO, see text_html formatter
00489         self._emitComment('transclusion parameters are not implemented in DocBook formatter')
00490         return ""

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.underline (   self,
  on,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 214 of file text_docbook.py.

00214 
00215     def underline(self, on, **kw):
00216         return self._handleFormatting("emphasis", on, (('role', 'underline'), ))

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Formatter.url (   self,
  on,
  url = None,
  css = None,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 364 of file text_docbook.py.

00364 
00365     def url(self, on, url=None, css=None, **kw):
00366         if url and url.startswith("/"):
00367             # convert to absolute path:
00368             url = "%s%s"%(self.request.base_url, url)
00369 
00370         if not on:
00371             self._cleanupUlinkNode()
00372 
00373         if kw.has_key("anchor") and kw.has_key("is_self") and kw["is_self"]:
00374             #handle the case where we are pointing to somewhere insidee our own document
00375             return self._handleNode("link", on, attributes=(('linkend', kw["anchor"]), ))
00376         else:
00377             return self._handleNode("ulink", on, attributes=(('url', url), ))

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

tuple MoinMoin.formatter.text_docbook.Formatter._can_contain_section = ("section", "appendix", "article", "chapter", "patintro", "preface") [static, private]

Definition at line 52 of file text_docbook.py.

tuple MoinMoin.formatter.text_docbook.Formatter.blacklisted_macros = ('TableOfContents', 'ShowSmileys', 'Navigation') [static]

Definition at line 45 of file text_docbook.py.

Definition at line 72 of file text_docbook.py.

Definition at line 71 of file text_docbook.py.

Definition at line 919 of file text_docbook.py.

Definition at line 75 of file text_docbook.py.

Definition at line 70 of file text_docbook.py.

string MoinMoin.formatter.FormatterBase.hardspace = ' ' [static, inherited]

Definition at line 38 of file __init__.py.

Definition at line 66 of file text_docbook.py.

Reimplemented in MoinMoin.formatter.dom_xml.Formatter.

Definition at line 58 of file __init__.py.

Definition at line 37 of file __init__.py.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 56 of file text_docbook.py.

Definition at line 80 of file text_docbook.py.

Definition at line 43 of file text_docbook.py.

Definition at line 79 of file text_docbook.py.

tuple MoinMoin.formatter.text_docbook.Formatter.wrap_text_in_para = ('listitem', 'glossdef', 'article', 'chapter', 'tip', 'warning', 'note', 'caution', 'important') [static]

Definition at line 49 of file text_docbook.py.


The documentation for this class was generated from the following file: