Back to index

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

List of all members.

Public Member Functions

def __init__
def setPage
def sysmsg
def startDocument
def endDocument
def lang
def pagelink
def interwikilink
def macro
def parser
def url
def attachment_link
def attachment_image
def attachment_drawing
def attachment_inlined
def rule
def icon
def smiley
def strong
def emphasis
def highlight
def number_list
def bullet_list
def listitem
def sup
def sub
def strike
def code
def preformatted
def paragraph
def linebreak
def heading
def table
def table_row
def table_cell
def anchordef
def anchorlink
def line_anchordef
def underline
def definition_list
def definition_term
def definition_desc
def image
def transclusion
def transclusion_param
def escapedText
def small
def big
def code_area
def code_line
def code_token
def set_highlight_re
def startContent
def endContent
def attachment_drawing
def attachment_inlined
def line_anchorlink
def nowikiword
def text
def code_area
def div
def span
def rawHTML
def comment
def sanitize_to_id
def make_id_unique
def qualify_id

Public Attributes

 document
 position
 tag_stack
 page
 in_pre
 request
 pagelinks
 in_p

Static Public Attributes

string hardspace = ' '
list format_tags = ['b', 'em', 'highlight', 'sup', 'sub', 'strike', 'code', 'u']
list need_p = []
list no_p_after
dictionary close_on_open
dictionary close_on_close

Private Member Functions

def _open_tag
def _close_tag
def _add_tag
def _text
def _set_tag
def _check_p
def _check_attrs

Detailed Description

This defines the output interface used all over the rest of the code.

    Note that no other means should be used to generate _content_ output,
    while navigational elements (HTML page header/footer) and the like
    can be printed directly without violating output abstraction.

Definition at line 19 of file dom_xml.py.


Constructor & Destructor Documentation

def MoinMoin.formatter.dom_xml.Formatter.__init__ (   self,
  request,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 66 of file dom_xml.py.

00066 
00067     def __init__(self, request, **kw):
00068         FormatterBase.__init__(self, request, **kw)
00069 
00070         self.document = minidom.Document()
00071         self.document.documentElement = self.document.createElement('xml')
00072         self.position = self.document.documentElement
00073         self.tag_stack = [('xml', {})]


Member Function Documentation

def MoinMoin.formatter.dom_xml.Formatter._add_tag (   self,
  tag,
  attrs 
) [private]
low level function: insert self closing tag right now
    does check_p

Definition at line 105 of file dom_xml.py.

00105 
00106     def _add_tag(self, tag, **attrs):
00107         """ low level function: insert self closing tag right now
00108             does check_p
00109         """
00110         self._check_p(tag)
00111         node = self.document.createElement(tag)
00112         for name, value in attrs.items():
00113             if value:
00114                 node.setAttribute(name, str(value))
00115         self.position.appendChild(node)
00116         return ''

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.formatter.dom_xml.Formatter._check_attrs (   self,
  attrs 
) [private]

Definition at line 306 of file dom_xml.py.

00306 
00307     def _check_attrs(self, attrs):
00308         result = {}
00309         for name, value in attrs.iteritems():
00310             result[str(name)] = value
00311         return result

Here is the caller graph for this function:

def MoinMoin.formatter.dom_xml.Formatter._check_p (   self,
  opening_tag = None 
) [private]

Definition at line 167 of file dom_xml.py.

00167 
00168     def _check_p(self, opening_tag=None):
00169         if (opening_tag is not None) and (opening_tag not in self.need_p):
00170             return
00171         for tag in self.tag_stack:
00172             if tag[0] in self.no_p_after:
00173                 return
00174         if self.in_p:
00175             return
00176         self._open_tag('p', type=str(opening_tag))

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.formatter.dom_xml.Formatter._close_tag (   self,
  tag 
) [private]
low level function: closes tag right now
    must be the last opened tag!!!

Definition at line 94 of file dom_xml.py.

00094 
00095     def _close_tag(self, tag):
00096         """ low level function: closes tag right now
00097             must be the last opened tag!!!
00098         """
00099         if tag == 'p':
00100             FormatterBase.paragraph(self, 0)
00101         if self.tag_stack[-1][0] != tag:
00102             raise ValueError, "closing of <%s> expected, but <%s> closed" % (self.tag_stack[-1][0], tag)
00103         self.position = self.position.parentNode
00104         return self.tag_stack.pop()

Here is the caller graph for this function:

def MoinMoin.formatter.dom_xml.Formatter._open_tag (   self,
  tag,
  attrs 
) [private]
low level function: opens tag right now

@param tag: tag name, string
@param attrs: attributes keywords, ascii or unicode

Definition at line 77 of file dom_xml.py.

00077 
00078     def _open_tag(self, tag, **attrs):
00079         """ low level function: opens tag right now
00080 
00081         @param tag: tag name, string
00082         @param attrs: attributes keywords, ascii or unicode
00083         """
00084         if tag == 'p':
00085             FormatterBase.paragraph(self, 1)
00086         self.tag_stack.append((tag, attrs))
00087         node = self.document.createElement(tag)
00088         for name, value in attrs.items():
00089             if value:
00090                 node.setAttribute(name, unicode(value))
00091         self.position.appendChild(node)
00092         self.position = node
00093         return ''

Here is the caller graph for this function:

def MoinMoin.formatter.dom_xml.Formatter._set_tag (   self,
  tag,
  on,
  attrs 
) [private]

Definition at line 123 of file dom_xml.py.

00123 
00124     def _set_tag(self, tag, on, **attrs):
00125         if on:
00126             close_on_open = self.close_on_open.get(tag, [])
00127             tags_to_reopen = []
00128             while True:
00129                 last_tag = self.tag_stack[-1][0]
00130                 if last_tag in close_on_open:
00131                     self._close_tag(last_tag)
00132                 elif last_tag in self.format_tags:
00133                     tags_to_reopen.append(self._close_tag(last_tag))
00134                 else:
00135                     break
00136             # XXX check if enclosing tag is ok
00137 
00138             if tag in self.need_p:
00139                 self._check_p(tag)
00140 
00141             self._open_tag(tag, **attrs)
00142             tags_to_reopen.reverse()
00143             for tag_name, args in tags_to_reopen:
00144                 self._open_tag(tag_name, **args)
00145         else:
00146             tags_to_reopen = []
00147             close_on_close = self.close_on_close.get(tag, [])
00148             # walk up
00149             while self.tag_stack:
00150                 # collect format tags
00151                 last_tag = self.tag_stack[-1][0]
00152                 if last_tag == tag:
00153                     break
00154                 elif last_tag in close_on_close:
00155                     self._close_tag(last_tag)
00156                 elif last_tag in self.format_tags:
00157                     tags_to_reopen.append(self._close_tag(last_tag))
00158                 else:
00159                     self.request.write("tag_stack: %r\n" % self.tag_stack)
00160                     self.request.write(self.document.documentElement.toprettyxml(" "))
00161                     raise ValueError, "closing of <%s> expected, but <%s> closed" % (last_tag, tag)
00162             self._close_tag(tag)
00163             tags_to_reopen.reverse()
00164             for tag_name, args in tags_to_reopen:
00165                 self._open_tag(tag_name, **args)
00166         return ''

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.formatter.dom_xml.Formatter._text (   self,
  text 
) [private]

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 117 of file dom_xml.py.

00117 
00118     def _text(self, text):
00119         if text.strip():
00120             self._check_p()
00121             self.position.appendChild(self.document.createTextNode(text))
00122         return ''

Here is the call graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 321 of file dom_xml.py.

00321 
00322     def anchordef(self, name):
00323         return self._add_tag('anchor', name=name)

Here is the call graph for this function:

def MoinMoin.formatter.dom_xml.Formatter.anchorlink (   self,
  on,
  name,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 324 of file dom_xml.py.

00324 
00325     def anchorlink(self, on, name, **kw):
00326         return self.url(on, "#" + name, **kw)

Here is the call graph for this function:

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

Definition at line 240 of file dom_xml.py.

00240 
00241     def attachment_drawing(self, url, **kw):
00242         kw['href'] = url
00243         kw['type'] = 'drawing'
00244         return self._add_tag('attachment', **kw)

Here is the call graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 235 of file dom_xml.py.

00235 
00236     def attachment_image(self, url, **kw):
00237         kw['href'] = url
00238         kw['type'] = 'image'
00239         return self._add_tag('attachment', **kw)

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:

Definition at line 245 of file dom_xml.py.

00245 
00246     def attachment_inlined(self, url, **kw):
00247         kw['href'] = url
00248         kw['type'] = 'inline'
00249         return self._add_tag('attachment', **kw)

Here is the call graph for this function:

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 227 of file dom_xml.py.

00227 
00228     def attachment_link(self, on, url=None, **kw):
00229         kw['href'] = url
00230         kw['type'] = 'link'
00231         if on:
00232             return self._set_tag('attachment', 1, **kw)
00233         else:
00234             return self._set_tag('attachment', 0, **kw)

Here is the call graph for this function:

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 372 of file dom_xml.py.

00372 
00373     def big(self, on, **kw):
00374         return self._set_tag('big', on)

Here is the call graph for this function:

def MoinMoin.formatter.dom_xml.Formatter.bullet_list (   self,
  on,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 271 of file dom_xml.py.

00271 
00272     def bullet_list(self, on, **kw):
00273         return self._set_tag('ul', on)

Here is the call graph for this function:

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 286 of file dom_xml.py.

00286 
00287     def code(self, on, **kw):
00288         return self._set_tag('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.dom_xml.Formatter.code_area (   self,
  on,
  code_id,
  code_type = 'code',
  show = 0,
  start = -1,
  step = -1,
  msg = None 
)

Definition at line 375 of file dom_xml.py.

00375 
00376     def code_area(self, on, code_id, code_type='code', show=0, start=-1, step=-1, msg=None):
00377         kw = {'id': code_id,
00378               'type': code_type,
00379               'show': show,
00380              }
00381         if start != -1:
00382             kw['start'] = start
00383         if step != -1:
00384             kw['step'] = step
00385         return self._set_tag('codearea', on, **kw)

Here is the call graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 386 of file dom_xml.py.

00386 
00387     def code_line(self, on):
00388         return self._set_tag('codeline', on)

Here is the call graph for this function:

def MoinMoin.formatter.dom_xml.Formatter.code_token (   self,
  on,
  tok_type 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 389 of file dom_xml.py.

00389 
00390     def code_token(self, on, tok_type):
00391         return self._set_tag('codetoken', on, type=tok_type)
00392 
00393 

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 347 of file dom_xml.py.

00347 
00348     def definition_desc(self, on, **kw):
00349         # self._langAttr() missing
00350         return self._set_tag('dd', on)

Here is the call graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 336 of file dom_xml.py.

00336 
00337     def definition_list(self, on, **kw):
00338         return self._set_tag('dl', on)

Here is the call graph for this function:

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 339 of file dom_xml.py.

00339 
00340     def definition_term(self, on, compact=0, **kw):
00341         # XXX may be not correct
00342         # self._langAttr() missing
00343         if compact and on:
00344             return self._set_tag('dt compact', on)
00345         else:
00346             return self._set_tag('dt', on)

Here is the call graph for this function:

def MoinMoin.formatter.FormatterBase.div (   self,
  on,
  kw 
) [inherited]
open/close a blocklevel division 

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

Definition at line 354 of file __init__.py.

00354 
00355     def div(self, on, **kw):
00356         """ open/close a blocklevel division """
00357         return ""

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 262 of file dom_xml.py.

00262 
00263     def emphasis(self, on, **kw):
00264         return self._set_tag('em', on)

Here is the call graph for this function:

def MoinMoin.formatter.FormatterBase.endContent (   self) [inherited]

Reimplemented in MoinMoin.formatter.text_docbook.Formatter, and MoinMoin.macro.TableOfContents.TOCFormatter.

Definition at line 80 of file __init__.py.

00080 
00081     def endContent(self):
00082         if self.page:
00083             self.request.uid_generator.end()
00084         return ""

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 187 of file dom_xml.py.

00187 
00188     def endDocument(self):
00189         #return self.document.documentElement.toxml()
00190         return self.document.documentElement.toprettyxml("  ")

def MoinMoin.formatter.dom_xml.Formatter.escapedText (   self,
  on,
  kw 
)
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 from MoinMoin.formatter.FormatterBase.

Definition at line 366 of file dom_xml.py.

00366 
00367     def escapedText(self, text, **kw):
00368         return wikiutil.escape(text)

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 303 of file dom_xml.py.

00303 
00304     def heading(self, on, depth, **kw):
00305         return self._set_tag('h%d' %depth, on, **kw)

Here is the call graph for this function:

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 265 of file dom_xml.py.

00265 
00266     def highlight(self, on, **kw):
00267         return self._set_tag('highlight', on)

Here is the call graph for this function:

def MoinMoin.formatter.dom_xml.Formatter.icon (   self,
  type 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 253 of file dom_xml.py.

00253 
00254     def icon(self, type):
00255         return self._add_tag('icon', type=type)

Here is the call graph for this function:

def MoinMoin.formatter.dom_xml.Formatter.image (   self,
  src = None,
  kw 
)
Take HTML <IMG> tag attributes in `attr`.

    Attribute names have to be lowercase!

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 351 of file dom_xml.py.

00351 
00352     def image(self, src=None, **kw):
00353         """ Take HTML <IMG> tag attributes in `attr`.
00354 
00355             Attribute names have to be lowercase!
00356         """
00357         if src:
00358             kw['src'] = src
00359         return self._add_tag('img', **kw)

Here is the call graph for this function:

def MoinMoin.formatter.dom_xml.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 201 of file dom_xml.py.

00201 
00202     def interwikilink(self, on, interwiki='', pagename='', **kw):
00203         kw['wiki'] = interwiki
00204         kw['pagename'] = pagename
00205         return self._set_tag('interwiki', on, **kw)

Here is the call graph for this function:

def MoinMoin.formatter.dom_xml.Formatter.lang (   self,
  on,
  lang_name 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 191 of file dom_xml.py.

00191 
00192     def lang(self, on, lang_name):
00193         return self._set_tag('lang', on, value=lang_name)

Here is the call graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 327 of file dom_xml.py.

00327 
00328     def line_anchordef(self, lineno):
00329         if line_anchors:
00330             return self.anchordef("line-%d" % lineno)
00331         else:
00332             return ''

Here is the call graph for this function:

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.dom_xml.Formatter.linebreak (   self,
  preformatted = 1 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 297 of file dom_xml.py.

00297 
00298     def linebreak(self, preformatted=1):
00299         if self.tag_stack[-1][0] == 'pre':
00300             return self.text('\n')
00301         else:
00302             return self._add_tag('br')

Here is the call graph for this function:

def MoinMoin.formatter.dom_xml.Formatter.listitem (   self,
  on,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 274 of file dom_xml.py.

00274 
00275     def listitem(self, on, **kw):
00276         return self._set_tag('li', on)

Here is the call graph for this function:

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 206 of file dom_xml.py.

00206 
00207     def macro(self, macro_obj, name, args, markup=None):
00208         # call the macro
00209         return self._add_tag('macro', name=name, args=(args or ''))

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.dom_xml.Formatter.number_list (   self,
  on,
  type = None,
  start = None,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 268 of file dom_xml.py.

00268 
00269     def number_list(self, on, type=None, start=None, **kw):
00270         return self._set_tag('ol', on, type=type, start=start)

Here is the call graph for this function:

def MoinMoin.formatter.dom_xml.Formatter.pagelink (   self,
  on,
  pagename = '',
  page = None,
  kw 
)
make a link to page <pagename>. Instead of supplying a pagename,
    it is also possible to give a live Page object, then page.page_name
    will be used.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 194 of file dom_xml.py.

00194 
00195     def pagelink(self, on, pagename='', page=None, **kw):
00196         FormatterBase.pagelink(self, pagename, page, **kw)
00197         if not pagename and page is not None:
00198             pagename = page.page_name
00199         kw['pagename'] = pagename
00200         return self._set_tag('pagelink', on, **kw)

Here is the call graph for this function:

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 293 of file dom_xml.py.

00293 
00294     def paragraph(self, on, **kw):
00295         FormatterBase.paragraph(self, on)
00296         return self._set_tag('p', on)

Here is the call graph for this function:

def MoinMoin.formatter.dom_xml.Formatter.parser (   self,
  parser_name,
  lines 
)
parser_name MUST be valid!
    writes out the result instead of returning it!

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 210 of file dom_xml.py.

00210 
00211     def parser(self, parser_name, lines):
00212         """ parser_name MUST be valid!
00213             writes out the result instead of returning it!
00214         """
00215         node = self.document.createElement('parser')
00216         node.setAttribute('name', parser_name)
00217         node.appendChild(self.document.createTextNode('\n'.join(lines)))
00218         return (self._set_tag('parser', True, name=parser_name) +
00219                 self.text('\n'.join(lines)) +
00220                 self._set_tag('parser', False))

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.formatter.dom_xml.Formatter.preformatted (   self,
  on,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 289 of file dom_xml.py.

00289 
00290     def preformatted(self, on, **kw):
00291         self.in_pre = on != 0
00292         return self._set_tag('pre', on)

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:

def MoinMoin.formatter.FormatterBase.rawHTML (   self,
  markup 
) [inherited]
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 in MoinMoin.formatter.text_html.Formatter, MoinMoin.formatter.text_docbook.Formatter, and MoinMoin.formatter.text_xml.Formatter.

Definition at line 362 of file __init__.py.

00362 
00363     def rawHTML(self, markup):
00364         """ This allows emitting pre-formatted HTML markup, and should be
00365             used wisely (i.e. very seldom).
00366 
00367             Using this event while generating content results in unwanted
00368             effects, like loss of markup or insertion of CDATA sections
00369             when output goes to XML formats.
00370         """
00371 
00372         import formatter, htmllib
00373         from MoinMoin.util import simpleIO
00374 
00375         # Regenerate plain text
00376         f = simpleIO()
00377         h = htmllib.HTMLParser(formatter.AbstractFormatter(formatter.DumbWriter(f)))
00378         h.feed(markup)
00379         h.close()
00380 
00381         return self.text(f.getvalue())

Here is the call graph for this function:

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 250 of file dom_xml.py.

00250 
00251     def rule(self, size=0, **kw):
00252         return self._add_tag('hr', size=str(size))

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 74 of file dom_xml.py.

00074 
00075     def setPage(self, page):
00076         self.page = page

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 369 of file dom_xml.py.

00369 
00370     def small(self, on, **kw):
00371         return self._set_tag('small', on)

Here is the call graph for this function:

def MoinMoin.formatter.dom_xml.Formatter.smiley (   self,
  type 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 256 of file dom_xml.py.

00256 
00257     def smiley(self, type):
00258         return self._add_tag('smiley', type=type)

Here is the call graph for this function:

def MoinMoin.formatter.FormatterBase.span (   self,
  on,
  kw 
) [inherited]
open/close a inline span 

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

Definition at line 358 of file __init__.py.

00358 
00359     def span(self, on, **kw):
00360         """ open/close a inline span """
00361         return ""

Here is the caller graph for this function:

def MoinMoin.formatter.FormatterBase.startContent (   self,
  content_id = "content",
  kw 
) [inherited]

Reimplemented in MoinMoin.formatter.text_docbook.Formatter, and MoinMoin.macro.TableOfContents.TOCFormatter.

Definition at line 75 of file __init__.py.

00075 
00076     def startContent(self, content_id="content", **kw):
00077         if self.page:
00078             self.request.uid_generator.begin(self.page.page_name)
00079         return ""

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 184 of file dom_xml.py.

00184 
00185     def startDocument(self, pagename):
00186         return ''

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 283 of file dom_xml.py.

00283 
00284     def strike(self, on, **kw):
00285         return self._set_tag('strike', on)

Here is the call graph for this function:

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 259 of file dom_xml.py.

00259 
00260     def strong(self, on, **kw):
00261         return self._set_tag('b', on)

Here is the call graph for this function:

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 280 of file dom_xml.py.

00280 
00281     def sub(self, on, **kw):
00282         return self._set_tag('sub', on)

Here is the call graph for this function:

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 277 of file dom_xml.py.

00277 
00278     def sup(self, on, **kw):
00279         return self._set_tag('sup', on)

Here is the call graph for this function:

def MoinMoin.formatter.dom_xml.Formatter.sysmsg (   self,
  on,
  kw 
)
Emit a system message (embed it into the page).

    Normally used to indicate disabled options, or invalid markup.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 177 of file dom_xml.py.

00177 
00178     def sysmsg(self, on, **kw):
00179         """ Emit a system message (embed it into the page).
00180 
00181             Normally used to indicate disabled options, or invalid markup.
00182         """
00183         return self._set_tag('sysmesg', on, **kw)

Here is the call graph for this function:

def MoinMoin.formatter.dom_xml.Formatter.table (   self,
  on,
  attrs = {},
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 312 of file dom_xml.py.

00312 
00313     def table(self, on, attrs={}, **kw):
00314         return self._set_tag('table', on, **self._check_attrs(attrs))

Here is the call graph for this function:

def MoinMoin.formatter.dom_xml.Formatter.table_cell (   self,
  on,
  attrs = {},
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 318 of file dom_xml.py.

00318 
00319     def table_cell(self, on, attrs={}, **kw):
00320         return self._set_tag('td', on, **self._check_attrs(attrs))

Here is the call graph for this function:

def MoinMoin.formatter.dom_xml.Formatter.table_row (   self,
  on,
  attrs = {},
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 315 of file dom_xml.py.

00315 
00316     def table_row(self, on, attrs={}, **kw):
00317         return self._set_tag('tr', on, **self._check_attrs(attrs))

Here is the call graph for this function:

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

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

Definition at line 189 of file __init__.py.

00189 
00190     def text(self, text, **kw):
00191         if not self._highlight_re:
00192             return self._text(text)
00193 
00194         result = []
00195         lastpos = 0
00196         match = self._highlight_re.search(text)
00197         while match and lastpos < len(text):
00198             # add the match we found
00199             result.append(self._text(text[lastpos:match.start()]))
00200             result.append(self.highlight(1))
00201             result.append(self._text(match.group(0)))
00202             result.append(self.highlight(0))
00203 
00204             # search for the next one
00205             lastpos = match.end() + (match.end() == lastpos)
00206             match = self._highlight_re.search(text, lastpos)
00207 
00208         result.append(self._text(text[lastpos:]))
00209         return ''.join(result)

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.formatter.dom_xml.Formatter.transclusion (   self,
  on,
  kw 
)

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 360 of file dom_xml.py.

00360 
00361     def transclusion(self, on, **kw):
00362         return self._set_tag('object', on, **kw)

Here is the call graph for this function:

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 363 of file dom_xml.py.

00363 
00364     def transclusion_param(self, **kw):
00365         return self._add_tag('param', **kw)

Here is the call graph for this function:

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 333 of file dom_xml.py.

00333 
00334     def underline(self, on, **kw):
00335         return self._set_tag('u', on)

Here is the call graph for this function:

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

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 221 of file dom_xml.py.

00221 
00222     def url(self, on, url='', css=None, **kw):
00223         kw['href'] = str(url)
00224         if css:
00225             kw['class'] = str(css)
00226         return self._set_tag('a', on, **kw)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Initial value:
{
        'table': ['td', 'tr'],
        'td': ['tr'], # XXX WTF? this doesn't look correct.
        'tr': ['td'],
        'ol': ['li'],
        'ul': ['li'],
        }

Definition at line 54 of file dom_xml.py.

Initial value:
{
        'h1': ['p'],
        'li': ['li'],
        'p': ['p'],
        #'pre': ['p'],
        }

Definition at line 43 of file dom_xml.py.

Definition at line 69 of file dom_xml.py.

list MoinMoin.formatter.dom_xml.Formatter.format_tags = ['b', 'em', 'highlight', 'sup', 'sub', 'strike', 'code', 'u'] [static]

Definition at line 30 of file dom_xml.py.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 26 of file dom_xml.py.

Definition at line 38 of file __init__.py.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 290 of file dom_xml.py.

Definition at line 33 of file dom_xml.py.

Initial value:
['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'ol', 'ul', 'pre',
                  'small', 'big', 'table', 'td', 'tr', 'dt',
                  'codearea', 'codeline', 'codetoken',
                  'sysmesg']

Definition at line 37 of file dom_xml.py.

Reimplemented from MoinMoin.formatter.FormatterBase.

Definition at line 75 of file dom_xml.py.

Definition at line 37 of file __init__.py.

Definition at line 71 of file dom_xml.py.

Definition at line 72 of file dom_xml.py.


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