rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
elif latex_docinfo and name == 'author': | elif name == 'author': | def visit_docinfo_item(self, node, name): # should we stick to latex or docutils. # latex article has its own handling of date and author latex_docinfo = 0 if name == 'abstract': # NOTE tableofcontents before or after ? # eg after: see visit_topic # NOTE this limits abstract to text. self.body.append('\\begin{abstract... |
self.docinfo.append('\\textbf{:%s:} &\n\t' % name) | self.docinfo.append('\\textbf{%s} &\n\t' % name) | def visit_docinfo_item(self, node, name): # should we stick to latex or docutils. # latex article has its own handling of date and author latex_docinfo = 0 if name == 'abstract': # NOTE tableofcontents before or after ? # eg after: see visit_topic # NOTE this limits abstract to text. self.body.append('\\begin{abstract... |
pass | if self.docinfo: self.docinfo.append('%s \\\\\n' % node.astext()) raise nodes.SkipNode | def visit_field_body(self, node): ##self.body.append('%[visit_field_body]\n') pass |
self.body.append('\\textbf{:') | if self.docinfo: self.docinfo.append('\\textbf{%s} &\n\t' % node.astext()) raise nodes.SkipNode else: self.body.append('\\textbf{') | def visit_field_name(self, node): self.body.append('\\textbf{:') |
self.body.append(':}') | if not self.docinfo: self.body.append(':}') | def depart_field_name(self, node): self.body.append(':}') |
self.update_section_numbers(self.document, "", 1) | self.update_section_numbers(self.document) | def transform(self): self.maxdepth = self.startnode.details.get('depth', sys.maxint) self.startnode.parent.remove(self.startnode) self.update_section_numbers(self.document, "", 1) |
def update_section_numbers(self, node, prefix, depth): cur_index = 1 | def update_section_numbers(self, node, prefix=(), depth=0): depth += 1 sectnum = 1 | def update_section_numbers(self, node, prefix, depth): cur_index = 1 for child in node: if isinstance(child, nodes.section): number_str = "%s%d." % (prefix, cur_index) title = child[0] child['autonum_origtitle'] = copy_and_filter(self.document, title) child['autonum_prefix'] = prefix if isinstance(title[0], nodes.Text)... |
number_str = "%s%d." % (prefix, cur_index) | numbers = prefix + (str(sectnum),) | def update_section_numbers(self, node, prefix, depth): cur_index = 1 for child in node: if isinstance(child, nodes.section): number_str = "%s%d." % (prefix, cur_index) title = child[0] child['autonum_origtitle'] = copy_and_filter(self.document, title) child['autonum_prefix'] = prefix if isinstance(title[0], nodes.Text)... |
child['autonum_origtitle'] = copy_and_filter(self.document, title) child['autonum_prefix'] = prefix if isinstance(title[0], nodes.Text): title[0].data = number_str + " " + title[0].data else: title.insert(0, nodes.Text(number_str + " ")) | generated = nodes.generated( '', '.'.join(numbers) + u'\u00a0' * 3, CLASS='sectnum') title.insert(0, generated) title['auto'] = 1 | def update_section_numbers(self, node, prefix, depth): cur_index = 1 for child in node: if isinstance(child, nodes.section): number_str = "%s%d." % (prefix, cur_index) title = child[0] child['autonum_origtitle'] = copy_and_filter(self.document, title) child['autonum_prefix'] = prefix if isinstance(title[0], nodes.Text)... |
self.update_section_numbers(child, number_str, depth+1) cur_index += 1 | self.update_section_numbers(child, numbers, depth) sectnum += 1 | def update_section_numbers(self, node, prefix, depth): cur_index = 1 for child in node: if isinstance(child, nodes.section): number_str = "%s%d." % (prefix, cur_index) title = child[0] child['autonum_origtitle'] = copy_and_filter(self.document, title) child['autonum_prefix'] = prefix if isinstance(title[0], nodes.Text)... |
entrytext = section.get('autonum_origtitle', '') if entrytext: autonum = 1 autonum_prefix = section.get('autonum_prefix') else: entrytext = copy_and_filter(self.document, title) | auto = title.get('auto') entrytext = self.copy_and_filter(title) | def build_contents(self, node, level=0): level += 1 sections = [] i = len(node) - 1 while i >= 0 and isinstance(node[i], nodes.section): sections.append(node[i]) i -= 1 sections.reverse() entries = [] autonum = 0 depth = self.startnode.details.get('depth', sys.maxint) for section in sections: title = section[0] |
if autonum: entries = nodes.enumerated_list('', enumtype='arabic', prefix=autonum_prefix, suffix='.', *entries) else: entries = nodes.bullet_list('', *entries) return entries | contents = nodes.bullet_list('', *entries) if auto: contents.set_class('auto-toc') return contents else: return [] | def build_contents(self, node, level=0): level += 1 sections = [] i = len(node) - 1 while i >= 0 and isinstance(node[i], nodes.section): sections.append(node[i]) i -= 1 sections.reverse() entries = [] autonum = 0 depth = self.startnode.details.get('depth', sys.maxint) for section in sections: title = section[0] |
def copy_and_filter(document, node): """Return a copy of a title, with references, images, etc. removed.""" visitor = ContentsFilter(document) node.walkabout(visitor) return visitor.get_entry_text() | def copy_and_filter(self, node): """Return a copy of a title, with references, images, etc. removed.""" visitor = ContentsFilter(self.document) node.walkabout(visitor) return visitor.get_entry_text() | def copy_and_filter(document, node): """Return a copy of a title, with references, images, etc. removed.""" visitor = ContentsFilter(document) node.walkabout(visitor) return visitor.get_entry_text() |
' width="100%" border="0">\n' | ' width="100%%" border="0">\n' | def fixfile(inpath, input_lines, outfile): from email.Utils import parseaddr basename = os.path.basename(inpath) infile = iter(input_lines) # convert plain text pep to minimal XHTML markup print >> outfile, DTD print >> outfile, '<html>' print >> outfile, '<head>' # head header = [] pep = "" title = "" for line in infi... |
self.assert_(isinstance(doctree_pickled, str)) | self.assert_(isinstance(doctree_pickled, StringType)) | def test_publish_pickle(self): """Test publishing a document tree with pickling and unpickling.""" # Produce the document tree. doctree = core.publish_doctree( source=test_document, reader_name='standalone', parser_name='restructuredtext', settings_overrides={'_disable_config': 1}) self.assert_(isinstance(doctree, nod... |
if not self.state_machine.match_titles: blocktext = context[0] + '\n' + self.state_machine.line msg = self.reporter.severe( 'Unexpected section title.', nodes.literal_block(blocktext, blocktext), line=lineno) self.parent += msg return [], next_state, [] | def underline(self, match, context, next_state): """Section title.""" lineno = self.state_machine.abs_line_number() if not self.state_machine.match_titles: blocktext = context[0] + '\n' + self.state_machine.line msg = self.reporter.severe( 'Unexpected section title.', nodes.literal_block(blocktext, blocktext), line=lin... | |
msg = self.reporter.info( 'Possible title underline, too short for the title.\n' "Treating it as ordinary text because it's so short.", line=lineno) self.parent += msg | if self.state_machine.match_titles: msg = self.reporter.info( 'Possible title underline, too short for the title.\n' "Treating it as ordinary text because it's so short.", line=lineno) self.parent += msg | def underline(self, match, context, next_state): """Section title.""" lineno = self.state_machine.abs_line_number() if not self.state_machine.match_titles: blocktext = context[0] + '\n' + self.state_machine.line msg = self.reporter.severe( 'Unexpected section title.', nodes.literal_block(blocktext, blocktext), line=lin... |
text = text.replace('\n', '\mbox{}\\\\') | text = text.replace('\n', '\mbox{}\\\\{}') | def encode(self, text, attval=None): """ Encode special characters in ``text`` and return it. |
parent_id = node.parent.get('id',None) if parent_id: href = self.section_filename + ' | if len(node.parent['ids'])>0: href = self.section_filename + ' | def visit_title(self, node): name,href = self.encode(node.astext()),'' |
document = pub.reader.read(pub.source, pub.parser, pub.settings) pub.apply_transforms(document) output = pub.writer.write(document, pub.destination) | pub.document = pub.reader.read(pub.source, pub.parser, pub.settings) pub.apply_transforms() output = pub.writer.write(pub.document, pub.destination) pub.writer.assemble_parts() | def write_contents_file(filenames, options): """ Creates .hhc (HTML Help Contents file). Uses a custom docutils.writer.Writer to extract section names and links from reStructuredText source files. File created is `options.hhc_file`. """ contents = [] status('creating contents file (%s...) \n' % options.hhc_file, opti... |
self.body.append(self.starttag(node, 'a', '[', href=href, CLASS='citation-reference')) | self.body.append(self.starttag(node, 'a', '[', CLASS='citation-reference', **(href and {'href': href} or {}))) | def visit_citation_reference(self, node): href = '' if node.has_key('refid'): href = '#' + node['refid'] elif node.has_key('refname'): href = '#' + self.document.nameids[node['refname']] self.body.append(self.starttag(node, 'a', '[', href=href, CLASS='citation-reference')) |
self.body.append(self.starttag(node, 'a', suffix, href=href, CLASS='footnote-reference')) | self.body.append(self.starttag(node, 'a', suffix, CLASS='footnote-reference', **(href and {'href': href} or {}))) | def visit_footnote_reference(self, node): href = '' if node.has_key('refid'): href = '#' + node['refid'] elif node.has_key('refname'): href = '#' + self.document.nameids[node['refname']] format = self.settings.footnote_references if format == 'brackets': suffix = '[' self.context.append(']') elif format == 'superscript... |
self.body.append(self.starttag(node, 'a', '', href=href, CLASS='reference')) | self.body.append(self.starttag(node, 'a', '', CLASS='reference', **(href and {'href': href} or {}))) | def visit_reference(self, node): if isinstance(node.parent, nodes.TextElement): self.context.append('') else: self.body.append('<p>') self.context.append('</p>\n') if node.has_key('refuri'): href = node['refuri'] elif node.has_key('refid'): href = '#' + node['refid'] elif node.has_key('refname'): href = '#' + self.docu... |
def __init__(self, options, source=None, source_path=None): self.options = options """An option values object with "input_encoding" and "output_encoding" | def __init__(self, settings, source=None, source_path=None): self.settings = settings """A settings object with "input_encoding" and "output_encoding" | def __init__(self, options, source=None, source_path=None): self.options = options """An option values object with "input_encoding" and "output_encoding" attributes (typically a `docutils.optik.Values` object).""" |
encodings = [self.options.input_encoding, 'utf-8'] | encodings = [self.settings.input_encoding, 'utf-8'] | def decode(self, data): """ Decode a string, `data`, heuristically. Raise UnicodeError if unsuccessful. |
def __init__(self, options, destination=None, destination_path=None): self.options = options """An option values object with "input_encoding" and "output_encoding" | def __init__(self, settings, destination=None, destination_path=None): self.settings = settings """A settings object with "input_encoding" and "output_encoding" | def __init__(self, options, destination=None, destination_path=None): self.options = options """An option values object with "input_encoding" and "output_encoding" attributes (typically a `docutils.optik.Values` object).""" |
def __init__(self, options, source=None, source_path=None, autoclose=1): | def __init__(self, settings, source=None, source_path=None, autoclose=1): | def __init__(self, options, source=None, source_path=None, autoclose=1): """ :Parameters: - `source`: either a file-like object (which is read directly), or `None` (which implies `sys.stdin` if no `source_path` given). - `source_path`: a path to a file, which is opened and then read. - `autoclose`: close automatically ... |
Input.__init__(self, options, source, source_path) | Input.__init__(self, settings, source, source_path) | def __init__(self, options, source=None, source_path=None, autoclose=1): """ :Parameters: - `source`: either a file-like object (which is read directly), or `None` (which implies `sys.stdin` if no `source_path` given). - `source_path`: a path to a file, which is opened and then read. - `autoclose`: close automatically ... |
def __init__(self, options, destination=None, destination_path=None, | def __init__(self, settings, destination=None, destination_path=None, | def __init__(self, options, destination=None, destination_path=None, autoclose=1): """ :Parameters: - `destination`: either a file-like object (which is written directly) or `None` (which implies `sys.stdout` if no `destination_path` given). - `destination_path`: a path to a file, which is opened and then written. - `a... |
Output.__init__(self, options, destination, destination_path) | Output.__init__(self, settings, destination, destination_path) | def __init__(self, options, destination=None, destination_path=None, autoclose=1): """ :Parameters: - `destination`: either a file-like object (which is written directly) or `None` (which implies `sys.stdout` if no `destination_path` given). - `destination_path`: a path to a file, which is opened and then written. - `a... |
output = data.encode(self.options.output_encoding) | output = data.encode(self.settings.output_encoding) | def write(self, data): """Encode `data`, write it to a single file, and return it.""" output = data.encode(self.options.output_encoding) if not self.opened: self.open() self.destination.write(output) if self.autoclose: self.close() return output |
if self.options.input_encoding.lower() == 'unicode': | if self.settings.input_encoding \ and self.settings.input_encoding.lower() == 'unicode': | def read(self, reader): """Decode and return the source string.""" if self.options.input_encoding.lower() == 'unicode': return self.source else: return self.decode(self.source) |
if self.options.output_encoding.lower() == 'unicode': | if self.settings.output_encoding \ and self.settings.output_encoding.lower() == 'unicode': | def write(self, data): """Encode `data`, store it in `self.destination`, and return it.""" if self.options.output_encoding.lower() == 'unicode': self.destination = data else: self.destination = data.encode(self.options.output_encoding) return self.destination |
self.destination = data.encode(self.options.output_encoding) | self.destination = data.encode(self.settings.output_encoding) | def write(self, data): """Encode `data`, store it in `self.destination`, and return it.""" if self.options.output_encoding.lower() == 'unicode': self.destination = data else: self.destination = data.encode(self.options.output_encoding) return self.destination |
if self.compound_enumerators: pref = "" if self.section_prefix_for_enumerators and self.section_level: for i in range(self.section_level): pref += '%d.' % self._section_number[i] pref = pref[:-1] + self.section_enumerator_separator enum_prefix += pref for counter in self._enumeration_counters: enum_prefix += counter + ... | def visit_enumerated_list(self, node): # We create our own enumeration list environment. # This allows to set the style and starting value # and unlimited nesting. self._enum_cnt += 1 | |
os.path.join(base_path, dictionary[option])) | os.path.abspath(os.path.join(base_path, dictionary[option]))) | def make_paths_absolute(dictionary, base_path=None): """ Interpret filesystem path settings relative to the `base_path` given. """ if base_path is None: base_path = os.getcwd() for option in relative_path_options: if dictionary.has_key(option) and dictionary[option]: dictionary[option] = os.path.normpath( os.path.join(... |
if self.active_table.is_open(): self.body.append('\n{\\ttfamily \\raggedright \\noindent\n') else: self.body.append('\\begin{ttfamily}') self.body.append('\\begin{flushleft}\n') | self.body.append('\n{\\vspace{1ex}\\ttfamily \\raggedright \\noindent\n') | def visit_literal_block(self, node): """ Render a literal-block. |
if self.active_table.is_open(): self.body.append('\n}\n') else: self.body.append('\n') self.body.append('\\end{flushleft}') self.body.append('\\end{ttfamily}\n') | self.body.append('\n}\n') | def depart_literal_block(self, node): if self.verbatim: self.body.append('\n\\end{verbatim}\n') self.verbatim = 0 else: if self.active_table.is_open(): self.body.append('\n}\n') else: self.body.append('\n') self.body.append('\\end{flushleft}') self.body.append('\\end{ttfamily}\n') self.insert_none_breaking_blanks = 0 s... |
if isinstance(text, str): | if isinstance(text, types.StringType): | def _munge_whitespace(self, text): """_munge_whitespace(text : string) -> string |
elif isinstance(text, unicode): | elif isinstance(text, types.UnicodeType): | def _munge_whitespace(self, text): """_munge_whitespace(text : string) -> string |
def record(self): self.recordfile(self.output, self.destination) | def record(self): self.recordfile(self.output, self.destination) | |
XML_DECL = '<?xml version="1.0" encoding="UTF-8"?>\n' DOCTYPE_DECL = """<!DOCTYPE %s PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd">\n""" | XML_DECL = '<?xml version="1.0" encoding="%s"?>\n' DOCTYPE_DECL = """<!DOCTYPE %s PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd">\n""" | def record(self): self.recordfile(self.output, self.destination) |
if self.doctype not in ('article','book','chapter'): raise ValueError('doctype must be one of: %s, %s, %s (got %s)' \ % ('article','book','chapter', self.doctype,)) | def __init__(self, document): nodes.NodeVisitor.__init__(self, document) self.language = languages.get_language(document.options.language_code) # doctype may be: article, book, or chapter self.doctype = document.options.doctype if self.doctype not in ('article','book','chapter'): raise ValueError('doctype must be one o... | |
self.XML_DECL, | self.XML_DECL % (document.options.output_encoding,), | def __init__(self, document): nodes.NodeVisitor.__init__(self, document) self.language = languages.get_language(document.options.language_code) # doctype may be: article, book, or chapter self.doctype = document.options.doctype if self.doctype not in ('article','book','chapter'): raise ValueError('doctype must be one o... |
self.biblio = {} | def __init__(self, document): nodes.NodeVisitor.__init__(self, document) self.language = languages.get_language(document.options.language_code) # doctype may be: article, book, or chapter self.doctype = document.options.doctype if self.doctype not in ('article','book','chapter'): raise ValueError('doctype must be one o... | |
self.footnotes = {} self.footnote_map = {} self.docinfo = [] | def __init__(self, document): nodes.NodeVisitor.__init__(self, document) self.language = languages.get_language(document.options.language_code) # doctype may be: article, book, or chapter self.doctype = document.options.doctype if self.doctype not in ('article','book','chapter'): raise ValueError('doctype must be one o... | |
+ self.docinfo | def astext(self): # TODO: include {doctype}info elements return ''.join(self.doc_header #+ [self.getDocInfo()] + self.body + self.doc_footer) | |
visit_author = depart_author = lambda self,node: None visit_authors = depart_authors = lambda self,node: None | def visit_author(self, node): raise nodes.SkipNode def visit_authors(self, node): raise nodes.SkipNode | def depart_attention(self, node): self.body.append('</note>\n') |
visit_citation = depart_citation = lambda self, node: None | def visit_citation(self, node): self.visit_footnote(node) def depart_citation(self, node): self.depart_footnote(node) | def depart_caution(self, node): self.body.append('</caution>\n') |
visit_citation_reference = depart_citation_reference = lambda self, node: None | def visit_citation_reference(self, node): self.visit_footnote_reference(node) def depart_citation_reference(self, node): pass | def depart_caution(self, node): self.body.append('</caution>\n') |
raise nodes.SkipNode visit_copyright = depart_copyright = lambda self,node: None | raise nodes.SkipNode def visit_copyright(self, node): raise nodes.SkipNode | def visit_contact(self, node): # TODO: map to {doctype}info/author/email # (if other needed parts of author are present) raise nodes.SkipNode |
pass | docinfo = ['<%sinfo>\n' % self.doctype] authors = [] author = '' contact = '' date = '' legalnotice = '' orgname = '' releaseinfo = '' revision,version = '','' for n in node: if isinstance(n, nodes.author): author = n.astext() elif isinstance(n, nodes.authors): for a in n: authors.append(a.astext()) elif isinstance(n... | def visit_docinfo(self, node): pass |
pass | self.rearrange_footnotes() | def depart_document(self, node): pass |
atts['nameend'] = self.colnames[self.entry_level + node['morecols']] | atts['nameend'] = self.colnames[self.entry_level \ + node['morecols']] | def visit_entry(self, node): tagname = 'entry' atts = {} if node.has_key('morerows'): atts['morerows'] = node['morerows'] if node.has_key('morecols'): atts['namest'] = self.colnames[self.entry_level] atts['nameend'] = self.colnames[self.entry_level + node['morecols']] self.entry_level += 1 # for tracking what namest ... |
pass self.body.append(self.starttag(node, 'footnote', **atts)) | atts['label'] = node[0].astext() self.footnotes[node['id']].append( self.starttag(node, 'footnote', **atts)) self._body = self.body self.body = self.footnotes[node['id']] | def visit_footnote(self, node): atts = {'id': node['id']} if isinstance(node[0], nodes.label): # FIXME: this fails with the second auto-sequence # symbol (after "#") #atts['label'] = node[0].astext() pass self.body.append(self.starttag(node, 'footnote', **atts)) |
self.body.append('</footnote>\n') | self.footnotes[node['id']].append('</footnote>\n') self.body = self._body self._body = None | def depart_footnote(self, node): self.body.append('</footnote>\n') |
linkend = node['refid'] | refid = node['refid'] | def visit_footnote_reference(self, node): if node.has_key('refid'): linkend = node['refid'] else: linkend = self.document.nameids[node['refname']] self.body.append(self.emptytag(node, 'footnoteref', linkend=linkend)) # so footnote reference doesn't show up twice, like: [1] 1 raise nodes.SkipNode |
linkend = self.document.nameids[node['refname']] self.body.append(self.emptytag(node, 'footnoteref', linkend=linkend)) | refid = self.document.nameids[node['refname']] refs = self.footnote_map.get(refid, []) refs.append((node['id'], self.body, len(self.body),)) self.footnote_map[refid] = refs self.body.append('<!-- REPLACE WITH FOOTNOTE -->') | def visit_footnote_reference(self, node): if node.has_key('refid'): linkend = node['refid'] else: linkend = self.document.nameids[node['refname']] self.body.append(self.emptytag(node, 'footnoteref', linkend=linkend)) # so footnote reference doesn't show up twice, like: [1] 1 raise nodes.SkipNode |
self.biblio['orgname'] = node.astext() | def visit_organization(self, node): self.biblio['orgname'] = node.astext() raise nodes.SkipNode | |
visit_revision = depart_revision = lambda self,node: None | def visit_revision(self, node): raise nodes.SkipNode | def depart_reference(self, node): self.body.append('</%s>' % (self.context.pop(),)) |
visit_status = depart_status = lambda self,node: None | def visit_status(self, node): raise nodes.SkipNode | def depart_section(self, node): self.section -= 1 if self.section == 0 and self.doctype == 'book': self.body.append('</chapter>\n') else: self.body.append('</section>\n') |
self.assert_('\xe4\xf6\xfc& 'äöü€', writer_name='html4css1', settings_overrides={'output_encoding': 'latin1'})) | self.assert_(core.publish_string( 'äöü€', writer_name='html4css1', settings_overrides={ 'output_encoding': 'latin1', 'stylesheet': None}).find( '\xe4\xf6\xfc& | def test_xmlcharrefreplace(self): # Test that xmlcharrefreplace is the default output encoding # error handler. self.assert_('\xe4\xf6\xfc€' in core.publish_string( 'äöü€', writer_name='html4css1', settings_overrides={'output_encoding': 'latin1'})) |
text = text.replace("<", '{$<$}') text = text.replace(">", '{$>$}') | text = text.replace("|", '{\\textbar}') text = text.replace("<", '{\\textless}') text = text.replace(">", '{\\textgreater}') | def encode(self, text): """ Encode special characters in `text` & return. # $ % & ~ _ ^ \ { } Escaping with a backslash does not help with backslashes, ~ and ^. |
text = text.replace("^", '{\\ensuremath{^\\wedge}}') | text = text.replace("^", '{\\textasciicircum}') | def encode(self, text): """ Encode special characters in `text` & return. # $ % & ~ _ ^ \ { } Escaping with a backslash does not help with backslashes, ~ and ^. |
text = text.replace("~", '{\\~{ }}') | text = text.replace("~", '{\\textasciitilde}') | def encode(self, text): """ Encode special characters in `text` & return. # $ % & ~ _ ^ \ { } Escaping with a backslash does not help with backslashes, ~ and ^. |
self.body.append(self.starttag(node, 'table', CLASS='footnote', frame="void", rules="none")) self.body.append('<col class="label" />\n' '<col />\n' '<tbody valign="top">\n' '<tr><td>\n') | self.body.append('\\footnote{') | def visit_footnote(self, node): self.body.append(self.starttag(node, 'table', CLASS='footnote', frame="void", rules="none")) self.body.append('<col class="label" />\n' '<col />\n' '<tbody valign="top">\n' '<tr><td>\n') |
self.body.append('</td></tr>\n' '</tbody>\n</table>\n') | self.body.append('}') | def depart_footnote(self, node): self.body.append('</td></tr>\n' '</tbody>\n</table>\n') |
href = '' if node.has_key('refid'): href = ' elif node.has_key('refname'): href = ' self.body.append(self.starttag(node, 'a', '', href=href, CLASS='footnote-reference')) | pass | def visit_footnote_reference(self, node): href = '' if node.has_key('refid'): href = '#' + node['refid'] elif node.has_key('refname'): href = '#' + self.document.nameids[node['refname']] self.body.append(self.starttag(node, 'a', '', href=href, CLASS='footnote-reference')) |
self.body.append('</a>') | pass | def depart_footnote_reference(self, node): self.body.append('</a>') |
if node['cols'] != 4: raise nodes.SkipNode | self.pep_table = node['cols'] == 4 | def visit_tgroup(self, node): if node['cols'] != 4: raise nodes.SkipNode self.entry = 0 |
if self.entry == 2: | if self.pep_table and self.entry == 2: | def visit_colspec(self, node): self.entry += 1 if self.entry == 2: node['class'] = 'num' |
stylesheet = self.get_stylesheet_reference(os.getcwd()) | stylesheet = self.get_stylesheet_reference( os.path.join(os.getcwd(), 'dummy')) | def __init__(self, document): nodes.NodeVisitor.__init__(self, document) self.settings = settings = document.settings lcode = settings.language_code self.language = languages.get_language(lcode) self.head_prefix = [ self.doctype, self.html_head % (lcode, lcode), self.content_type % settings.output_encoding, self.genera... |
config_section = 'moin writer' | config_section = 'MoinMoin writer' | def html_escape_unicode(node): # Find Python function that does this for me. string.encode('ascii', # 'xmlcharrefreplace') only 2.3 and above. for i in node: if ord(i) > 127: node = node.replace(i, '&#%d;' % (ord(i))) return node |
self.old_write = self.request.write self.request.write = self.rst_write | self.original_write, self.request.write = self.request.write, self.capture_wiki_formatting | def __init__(self, document, formatter, request, parser, writer): html4css1.HTMLTranslator.__init__(self, document) self.formatter = formatter self.request = request # We supply our own request.write so that the html is added to the # html4css1 body list instead of printed to stdout by the default # MoinTranslator writ... |
self.wikiparser.request.write = self.rst_write self.strip_paragraph = 0 self.writer = writer | def __init__(self, document, formatter, request, parser, writer): html4css1.HTMLTranslator.__init__(self, document) self.formatter = formatter self.request = request # We supply our own request.write so that the html is added to the # html4css1 body list instead of printed to stdout by the default # MoinTranslator writ... | |
self.request.write = self.old_write | self.request.write = self.original_write | def astext(self): self.request.write = self.old_write return html4css1.HTMLTranslator.astext(self) |
def rst_write(self, string): if self.strip_paragraph: replacement = {'<p>': '', '</p>': '', '\n': '', '> ': '>'} for src, dst in replacement.items(): string = string.replace(src, dst) if string and string[-1] == ' ': string = string[:-1] self.body.append(string) | def process_inline(self, node, uri_string): """ Process the "inline:" link scheme. This can either ome from visit_reference or from visit_image. The uri_string changes depending on the caller. The uri is passed to MoinMoin to handle the inline link. If it is an image, the src line is extracted and passed to the html4cs... | def astext(self): self.request.write = self.old_write return html4css1.HTMLTranslator.astext(self) |
target = None moin_link_schemes = ['wiki:', 'attachment:', 'inline:', 'drawing:'] | moin_link_schemes = ['wiki:', 'attachment:', 'drawing:', '[[', 'inline:'] | def visit_reference(self, node): target = None # These are the special link schemes that MoinMoin supports. We let # MoinMoin handle these types. moin_link_schemes = ['wiki:', 'attachment:', 'inline:', 'drawing:'] # Do I need to lstrip? TODO: Find this out. Doesn't look like I need to # since I don't when assigning t... |
if [i for i in moin_link_schemes if refuri.lstrip().startswith(i)]: | if [scheme for scheme in moin_link_schemes if refuri.lstrip().startswith(scheme)]: | def visit_reference(self, node): target = None # These are the special link schemes that MoinMoin supports. We let # MoinMoin handle these types. moin_link_schemes = ['wiki:', 'attachment:', 'inline:', 'drawing:'] # Do I need to lstrip? TODO: Find this out. Doesn't look like I need to # since I don't when assigning t... |
self.strip_paragraph = 1 | def visit_reference(self, node): target = None # These are the special link schemes that MoinMoin supports. We let # MoinMoin handle these types. moin_link_schemes = ['wiki:', 'attachment:', 'inline:', 'drawing:'] # Do I need to lstrip? TODO: Find this out. Doesn't look like I need to # since I don't when assigning t... | |
self.wikiparser.raw = target | self.process_inline(node, 'refuri') elif target.startswith('[[') and target.endswith(']]'): self.process_wiki_target(target) else: node_text = node.astext().replace('\n', ' ') self.wikiparser.raw = '[%s %s]' % (target, node_text) | def visit_reference(self, node): target = None # These are the special link schemes that MoinMoin supports. We let # MoinMoin handle these types. moin_link_schemes = ['wiki:', 'attachment:', 'inline:', 'drawing:'] # Do I need to lstrip? TODO: Find this out. Doesn't look like I need to # since I don't when assigning t... |
else: node_text = node.astext().replace('\n', ' ') self.wikiparser.raw = '[%s %s]' % (target, node_text) self.wikiparser.format(self.formatter) self.strip_paragraph = 0 raise docutils.nodes.SkipNode return | href = re.search('href="([^"]+)"', self.wiki_text) if href: node['refuri'] = href.groups()[0] else: self.wiki_text = self.fixup_wiki_formatting(self.wiki_text) self.add_wiki_markup() | def visit_reference(self, node): target = None # These are the special link schemes that MoinMoin supports. We let # MoinMoin handle these types. moin_link_schemes = ['wiki:', 'attachment:', 'inline:', 'drawing:'] # Do I need to lstrip? TODO: Find this out. Doesn't look like I need to # since I don't when assigning t... |
def visit_emphasis(self, node): self.request.write(self.formatter.emphasis(1)) def depart_emphasis(self, node): self.request.write(self.formatter.emphasis(0)) def visit_strong(self, node): self.request.write(self.formatter.strong(1)) def depart_strong(self, node): self.request.write(self.formatter.strong(0)) def vi... | def visit_reference(self, node): target = None # These are the special link schemes that MoinMoin supports. We let # MoinMoin handle these types. moin_link_schemes = ['wiki:', 'attachment:', 'inline:', 'drawing:'] # Do I need to lstrip? TODO: Find this out. Doesn't look like I need to # since I don't when assigning t... | |
'Unable to open source file for reading (%s). Exiting.' | 'Unable to open source file for reading (%r). Exiting.' | def __init__(self, source=None, source_path=None, encoding=None, autoclose=1, handle_io_errors=1): """ :Parameters: - `source`: either a file-like object (which is read directly), or `None` (which implies `sys.stdin` if no `source_path` given). - `source_path`: a path to a file, which is opened and then read. - `autocl... |
'(%s). Exiting.' % source_path) | '(%r). Exiting.' % self.destination_path) | def open(self): try: self.destination = open(self.destination_path, 'w') except IOError, error: if not self.handle_io_errors: raise print >>sys.stderr, '%s: %s' % (error.__class__.__name__, error) print >>sys.stderr, ('Unable to open destination file for writing ' '(%s). Exiting.' % source_path) sys.exit(1) self.opene... |
self.body.append(self.starttag(node, 'blockquote')) | self.body.append('\n@QuotedDisplay {\n') self.kill_next_paragraph = True | def visit_block_quote(self, node): self.body.append(self.starttag(node, 'blockquote')) |
self.body.append('\n@CurveBox paint { red } { "/" blockquote }\n') | self.body.append('\n}\n') | def depart_block_quote(self, node): self.body.append('\n@CurveBox paint { red } { "/" blockquote }\n') |
self.body.append('@BulletList') | self.body.append('\n@') if self.kill_next_paragraph: self.kill_next_paragraph = False self.body.append('Raw') self.body.append('BulletList\n') | def visit_bullet_list(self, node): if self.topic_class == 'contents': # we let Lout generate contents, thank you sir raise nodes.SkipNode self.body.append('@BulletList') |
self.body.append('\n@EndList\n') self.kill_next_paragraph = True | self.body.append('\n@RawEndList\n') | def depart_bullet_list(self, node): self.body.append('\n@EndList\n') self.kill_next_paragraph = True |
self.body.append('\n@TaggedList\n') | self.body.append('\n@') if self.kill_next_paragraph: self.kill_next_paragraph = False self.body.append('Raw') self.body.append('TaggedList\n') | def visit_definition_list(self, node): self.body.append('\n@TaggedList\n') |
self.body.append('\n@EndList\n') self.kill_next_paragraph = True | self.body.append('\n@RawEndList\n') | def depart_definition_list(self, node): self.body.append('\n@EndList\n') self.kill_next_paragraph = True |
atts = {} | self.body.append('\n@') if self.kill_next_paragraph: self.kill_next_paragraph = False self.body.append('Raw') if node.get('prefix', '') == '(' and node.get('suffix', '') == ')': self.body.append('Paren') if not node.has_key('enumtype'): self.body.append('NumberedList\n') elif node['enumtype'] == 'arabic': self.body.app... | def visit_enumerated_list(self, node): """ The 'start' attribute does not conform to HTML 4.01's strict.dtd, but CSS1 doesn't help. CSS2 isn't widely enough supported yet to be usable. """ atts = {} if node.has_key('start'): atts['start'] = node['start'] if node.has_key('enumtype'): atts['class'] = node['enumtype'] sel... |
atts['start'] = node['start'] if node.has_key('enumtype'): atts['class'] = node['enumtype'] self.body.append(self.starttag(node, 'ol', **atts)) | self.body.append(' start { %s }\n' % node['start']) | def visit_enumerated_list(self, node): """ The 'start' attribute does not conform to HTML 4.01's strict.dtd, but CSS1 doesn't help. CSS2 isn't widely enough supported yet to be usable. """ atts = {} if node.has_key('start'): atts['start'] = node['start'] if node.has_key('enumtype'): atts['class'] = node['enumtype'] sel... |
self.body.append('\n@CurveBox paint { red } { "/" ol }\n') | self.body.append('\n@RawEndList\n') | def depart_enumerated_list(self, node): self.body.append('\n@CurveBox paint { red } { "/" ol }\n') #self.kill_next_paragraph = True |
self.body.append('\n@WideTaggedList\n') | self.body.append('\n@') if self.kill_next_paragraph: self.kill_next_paragraph = False self.body.append('Raw') self.body.append('WideTaggedList\n') | def visit_field_list(self, node): self.body.append('\n@WideTaggedList\n') return |
self.body.append('\n@EndList\n') self.kill_next_paragraph = True | self.body.append('\n@RawEndList\n') | def depart_field_list(self, node): self.body.append('\n@EndList\n') self.kill_next_paragraph = True |
self.body.append(node.astext()) | self.body.extend(['\n', node.astext(), '\n']) | def visit_raw(self, node): if node.get('format') == 'lout': self.body.append(node.astext()) # Keep non-Lout raw text out of output: raise nodes.SkipNode |
self.body.append('"%s" @ExternalLink { ' % node['refuri']) | self.body.append('{"%s"} @ExternalLink { ' % node['refuri']) | def visit_reference(self, node): if node.has_key('refuri'): self.body.append('"%s" @ExternalLink { ' % node['refuri']) return elif node.has_key('refid'): href = node['refid'] elif node.has_key('refname'): href = node['refid'] = self.document.nameids[node['refname']] self.body.append('%s @CrossLink { ' % href) |
if self.body and not self.preface: | if self.body and not (self.preface or self.introduction): | def visit_section(self, node): #print 'visit section level', self.section_level, node.__dict__ self.section_level += 1 if self.doctype == 'doc': pass elif self.doctype == 'book': if self.section_level == 1: if not (self.chapters or self.parts): # first one if self.body and not self.preface: # text before first chapter ... |
self.body.append('@RawDisplay @I { ') | self.body.append('@LLP @RawCentredDisplay @I { ') | def visit_subtitle(self, node): if isinstance(node.parent, nodes.sidebar): self.body.append('@RawDisplay @I { ') else: self.docinfo['subtitle'] = node.astext() raise nodes.SkipNode |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.