rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
el = etree.SubElement(self.current_element, 'text:span',
el = SubElement(self.current_element, 'text:span',
def visit_emphasis(self, node): el = etree.SubElement(self.current_element, 'text:span', attrib={'text:style-name': 'rststyle-emphasis'}) self.set_current_element(el)
el = etree.SubElement(self.current_element, 'text:list', attrib={
el = SubElement(self.current_element, 'text:list', attrib={
def visit_enumerated_list(self, node): #ipshell('At visit_enumerated_list') #import pdb; pdb.set_trace() #print '(visit_enumerated_list) node: %s' % node.astext() el = etree.SubElement(self.current_element, 'text:list', attrib={ 'text:style-name': 'rststyle-enumlist', }) self.set_current_element(el) self.paragraph_styl...
el = etree.SubElement(self.current_element, 'text:list-item')
el = SubElement(self.current_element, 'text:list-item')
def visit_list_item(self, node): #import pdb; pdb.set_trace() #ipshell('At visit_document') #print '(visit_list_item) node: %s' % node.astext() el = etree.SubElement(self.current_element, 'text:list-item') self.set_current_element(el)
el1 = etree.SubElement(el, 'text:span',
el1 = SubElement(el, 'text:span',
def visit_field_name(self, node): #ipshell('At visit_field_name') #self.trace_visit_node(node) el = self.append_child('text:p', attrib={ 'text:style-name': 'rststyle-textbody'}) el1 = etree.SubElement(el, 'text:span', attrib={'text:style-name': 'rststyle-strong'}) el1.text = node.astext()
el1 = etree.SubElement(self.current_element, 'text:p',
el1 = SubElement(self.current_element, 'text:p',
def visit_image(self, node): #ipshell('At visit_image') #self.trace_visit_node(node) # Capture the image file. if 'uri' in node.attributes: source = node.attributes['uri'] if not self.check_file_exists(source): print 'Error: Cannot find image file %s.' % (source, ) return else: return filename = os.path.split(source)[1...
el1 = etree.SubElement(self.automatic_styles,
el1 = SubElement(self.automatic_styles,
def generate_figure(self, node, source, destination): caption = None for node1 in node.parent.children: if node1.tagname == 'caption': caption = node1.astext() self.image_count += 1 style_name = 'rstframestyle%d' % self.image_count if 'scale' in node.attributes: try: scale = int(node.attributes['scale']) if scale < 1 o...
el2 = etree.SubElement(el1,
el2 = SubElement(el1,
def generate_figure(self, node, source, destination): caption = None for node1 in node.parent.children: if node1.tagname == 'caption': caption = node1.astext() self.image_count += 1 style_name = 'rstframestyle%d' % self.image_count if 'scale' in node.attributes: try: scale = int(node.attributes['scale']) if scale < 1 o...
el1 = etree.SubElement(self.current_element, 'text:p', attrib=attrib)
el1 = SubElement(self.current_element, 'text:p', attrib=attrib)
def generate_figure(self, node, source, destination): caption = None for node1 in node.parent.children: if node1.tagname == 'caption': caption = node1.astext() self.image_count += 1 style_name = 'rstframestyle%d' % self.image_count if 'scale' in node.attributes: try: scale = int(node.attributes['scale']) if scale < 1 o...
el1 = etree.SubElement(el1, 'draw:frame', attrib=attrib)
el1 = SubElement(el1, 'draw:frame', attrib=attrib)
def generate_figure(self, node, source, destination): caption = None for node1 in node.parent.children: if node1.tagname == 'caption': caption = node1.astext() self.image_count += 1 style_name = 'rstframestyle%d' % self.image_count if 'scale' in node.attributes: try: scale = int(node.attributes['scale']) if scale < 1 o...
el1 = etree.SubElement(el1, 'draw:text-box', attrib=attrib)
el1 = SubElement(el1, 'draw:text-box', attrib=attrib)
def generate_figure(self, node, source, destination): caption = None for node1 in node.parent.children: if node1.tagname == 'caption': caption = node1.astext() self.image_count += 1 style_name = 'rstframestyle%d' % self.image_count if 'scale' in node.attributes: try: scale = int(node.attributes['scale']) if scale < 1 o...
el1 = etree.SubElement(el1, 'text:p', attrib=attrib)
el1 = SubElement(el1, 'text:p', attrib=attrib)
def generate_figure(self, node, source, destination): caption = None for node1 in node.parent.children: if node1.tagname == 'caption': caption = node1.astext() self.image_count += 1 style_name = 'rstframestyle%d' % self.image_count if 'scale' in node.attributes: try: scale = int(node.attributes['scale']) if scale < 1 o...
el1 = etree.SubElement(self.automatic_styles,
el1 = SubElement(self.automatic_styles,
def generate_image(self, node, source, destination, current_element): self.image_count += 1 style_name = 'rstframestyle%d' % self.image_count # Add the style. attrib = { 'style:name': style_name, 'style:family': 'graphic', 'style:parent-style-name': 'Graphics', } el1 = etree.SubElement(self.automatic_styles, 'style:sty...
el2 = etree.SubElement(el1,
el2 = SubElement(el1,
def generate_image(self, node, source, destination, current_element): self.image_count += 1 style_name = 'rstframestyle%d' % self.image_count # Add the style. attrib = { 'style:name': style_name, 'style:family': 'graphic', 'style:parent-style-name': 'Graphics', } el1 = etree.SubElement(self.automatic_styles, 'style:sty...
el1 = etree.SubElement(current_element, 'draw:frame', attrib=attrib) el2 = etree.SubElement(el1, 'draw:image', attrib={
el1 = SubElement(current_element, 'draw:frame', attrib=attrib) el2 = SubElement(el1, 'draw:image', attrib={
def generate_image(self, node, source, destination, current_element): self.image_count += 1 style_name = 'rstframestyle%d' % self.image_count # Add the style. attrib = { 'style:name': style_name, 'style:family': 'graphic', 'style:parent-style-name': 'Graphics', } el1 = etree.SubElement(self.automatic_styles, 'style:sty...
el = etree.SubElement(self.current_element, 'text:span',
el = SubElement(self.current_element, 'text:span',
def visit_literal(self, node): #ipshell('At visit_literal') el = etree.SubElement(self.current_element, 'text:span', attrib={'text:style-name': 'rststyle-inlineliteral'}) self.set_current_element(el)
el1 = etree.SubElement(el, 'text:s', attrib={
el1 = SubElement(el, 'text:s', attrib={
def visit_literal_block(self, node): #ipshell('At visit_literal_block') lines = node.astext().split('\n') for line in lines: padcount = self.calculate_code_block_padding(line) line = line.lstrip(' \t') el = self.append_child('text:p', attrib={ 'text:style-name': 'rststyle-codeblock', }) if padcount > 0: el1 = etree.Sub...
el = etree.SubElement(self.automatic_styles, 'style:style', attrib={
el = SubElement(self.automatic_styles, 'style:style', attrib={
def visit_option_list(self, node): #self.document.reporter.debug_flag = 1 #self.document.reporter.attach_observer(self.show_message) table_name = 'rststyle-tableoption' # # Generate automatic styles if not self.optiontablestyles_generated: self.optiontablestyles_generated = True el = etree.SubElement(self.automatic_sty...
el1 = etree.SubElement(el, 'style:table-properties', attrib={
el1 = SubElement(el, 'style:table-properties', attrib={
def visit_option_list(self, node): #self.document.reporter.debug_flag = 1 #self.document.reporter.attach_observer(self.show_message) table_name = 'rststyle-tableoption' # # Generate automatic styles if not self.optiontablestyles_generated: self.optiontablestyles_generated = True el = etree.SubElement(self.automatic_sty...
el1 = etree.SubElement(el, 'style:table-column-properties', attrib={
el1 = SubElement(el, 'style:table-column-properties', attrib={
def visit_option_list(self, node): #self.document.reporter.debug_flag = 1 #self.document.reporter.attach_observer(self.show_message) table_name = 'rststyle-tableoption' # # Generate automatic styles if not self.optiontablestyles_generated: self.optiontablestyles_generated = True el = etree.SubElement(self.automatic_sty...
el1 = etree.SubElement(el, 'style:table-cell-properties', attrib={
el1 = SubElement(el, 'style:table-cell-properties', attrib={
def visit_option_list(self, node): #self.document.reporter.debug_flag = 1 #self.document.reporter.attach_observer(self.show_message) table_name = 'rststyle-tableoption' # # Generate automatic styles if not self.optiontablestyles_generated: self.optiontablestyles_generated = True el = etree.SubElement(self.automatic_sty...
el2 = etree.SubElement(el1, 'style:background-image') el = etree.SubElement(self.automatic_styles, 'style:style', attrib={
el2 = SubElement(el1, 'style:background-image') el = SubElement(self.automatic_styles, 'style:style', attrib={
def visit_option_list(self, node): #self.document.reporter.debug_flag = 1 #self.document.reporter.attach_observer(self.show_message) table_name = 'rststyle-tableoption' # # Generate automatic styles if not self.optiontablestyles_generated: self.optiontablestyles_generated = True el = etree.SubElement(self.automatic_sty...
el1 = etree.SubElement(el, 'table:table-column', attrib={
el1 = SubElement(el, 'table:table-column', attrib={
def visit_option_list(self, node): #self.document.reporter.debug_flag = 1 #self.document.reporter.attach_observer(self.show_message) table_name = 'rststyle-tableoption' # # Generate automatic styles if not self.optiontablestyles_generated: self.optiontablestyles_generated = True el = etree.SubElement(self.automatic_sty...
el1 = etree.SubElement(el, 'table:table-header-rows') el2 = etree.SubElement(el1, 'table:table-row') el3 = etree.SubElement(el2, 'table:table-cell', attrib={
el1 = SubElement(el, 'table:table-header-rows') el2 = SubElement(el1, 'table:table-row') el3 = SubElement(el2, 'table:table-cell', attrib={
def visit_option_list(self, node): #self.document.reporter.debug_flag = 1 #self.document.reporter.attach_observer(self.show_message) table_name = 'rststyle-tableoption' # # Generate automatic styles if not self.optiontablestyles_generated: self.optiontablestyles_generated = True el = etree.SubElement(self.automatic_sty...
el4 = etree.SubElement(el3, 'text:p', attrib={
el4 = SubElement(el3, 'text:p', attrib={
def visit_option_list(self, node): #self.document.reporter.debug_flag = 1 #self.document.reporter.attach_observer(self.show_message) table_name = 'rststyle-tableoption' # # Generate automatic styles if not self.optiontablestyles_generated: self.optiontablestyles_generated = True el = etree.SubElement(self.automatic_sty...
el3 = etree.SubElement(el2, 'table:table-cell', attrib={
el3 = SubElement(el2, 'table:table-cell', attrib={
def visit_option_list(self, node): #self.document.reporter.debug_flag = 1 #self.document.reporter.attach_observer(self.show_message) table_name = 'rststyle-tableoption' # # Generate automatic styles if not self.optiontablestyles_generated: self.optiontablestyles_generated = True el = etree.SubElement(self.automatic_sty...
el1 = etree.SubElement(el, 'text:p', attrib={
el1 = SubElement(el, 'text:p', attrib={
def visit_description(self, node): el = self.append_child('table:table-cell', attrib={ 'table:style-name': 'Table%d.B2' % self.table_count, 'office:value-type': 'string', }) el1 = etree.SubElement(el, 'text:p', attrib={ 'text:style-name': 'Table_20_Contents'}) el1.text = node.astext() raise nodes.SkipChildren()
el1 = etree.SubElement(el, 'text:span',
el1 = SubElement(el, 'text:span',
def visit_revision(self, node): el = self.append_child('text:p', attrib={ 'text:style-name': 'rststyle-textbody'}) el1 = etree.SubElement(el, 'text:span', attrib={'text:style-name': 'rststyle-strong'}) el1.text = 'Revision: ' el1.tail = node.astext()
el = etree.SubElement(self.current_element, 'text:span',
el = SubElement(self.current_element, 'text:span',
def visit_strong(self, node): #ipshell('At visit_strong') el = etree.SubElement(self.current_element, 'text:span', attrib={'text:style-name': 'rststyle-strong'}) self.set_current_element(el)
el1 = etree.SubElement(self.automatic_styles, 'style:style', attrib={
el1 = SubElement(self.automatic_styles, 'style:style', attrib={
def visit_table(self, node): #self.trace_visit_node(node) #ipshell('At visit_table') self.table_count += 1 table_name = '%s%d' % (TableStylePrefix, self.table_count, ) el1 = etree.SubElement(self.automatic_styles, 'style:style', attrib={ 'style:name': '%s' % table_name, 'style:family': 'table', }) el1_1 = etree.SubElem...
el1_1 = etree.SubElement(el1, 'style:table-properties', attrib={
el1_1 = SubElement(el1, 'style:table-properties', attrib={
def visit_table(self, node): #self.trace_visit_node(node) #ipshell('At visit_table') self.table_count += 1 table_name = '%s%d' % (TableStylePrefix, self.table_count, ) el1 = etree.SubElement(self.automatic_styles, 'style:style', attrib={ 'style:name': '%s' % table_name, 'style:family': 'table', }) el1_1 = etree.SubElem...
el2 = etree.SubElement(self.automatic_styles, 'style:style', attrib={
el2 = SubElement(self.automatic_styles, 'style:style', attrib={
def visit_table(self, node): #self.trace_visit_node(node) #ipshell('At visit_table') self.table_count += 1 table_name = '%s%d' % (TableStylePrefix, self.table_count, ) el1 = etree.SubElement(self.automatic_styles, 'style:style', attrib={ 'style:name': '%s' % table_name, 'style:family': 'table', }) el1_1 = etree.SubElem...
el2_1 = etree.SubElement(el2, 'style:table-cell-properties', attrib={
el2_1 = SubElement(el2, 'style:table-cell-properties', attrib={
def visit_table(self, node): #self.trace_visit_node(node) #ipshell('At visit_table') self.table_count += 1 table_name = '%s%d' % (TableStylePrefix, self.table_count, ) el1 = etree.SubElement(self.automatic_styles, 'style:style', attrib={ 'style:name': '%s' % table_name, 'style:family': 'table', }) el1_1 = etree.SubElem...
el3 = etree.SubElement(self.current_element, 'table:table', attrib={
el3 = SubElement(self.current_element, 'table:table', attrib={
def visit_table(self, node): #self.trace_visit_node(node) #ipshell('At visit_table') self.table_count += 1 table_name = '%s%d' % (TableStylePrefix, self.table_count, ) el1 = etree.SubElement(self.automatic_styles, 'style:style', attrib={ 'style:name': '%s' % table_name, 'style:family': 'table', }) el1_1 = etree.SubElem...
el1 = etree.SubElement(self.automatic_styles, 'style:style', attrib={
el1 = SubElement(self.automatic_styles, 'style:style', attrib={
def visit_colspec(self, node): #self.trace_visit_node(node) #ipshell('At visit_colspec') self.column_count += 1 table_name = '%s%d' % (TableStylePrefix, self.table_count, ) colspec_name = '%s%d.%s' % ( TableStylePrefix, self.table_count, chr(self.column_count),) colwidth = node['colwidth'] el1 = etree.SubElement(self.a...
el1_1 = etree.SubElement(el1, 'style:table-column-properties', attrib={
el1_1 = SubElement(el1, 'style:table-column-properties', attrib={
def visit_colspec(self, node): #self.trace_visit_node(node) #ipshell('At visit_colspec') self.column_count += 1 table_name = '%s%d' % (TableStylePrefix, self.table_count, ) colspec_name = '%s%d.%s' % ( TableStylePrefix, self.table_count, chr(self.column_count),) colwidth = node['colwidth'] el1 = etree.SubElement(self.a...
el1 = etree.SubElement(self.current_element, 'text:h', attrib = {
el1 = SubElement(self.current_element, 'text:h', attrib = {
def visit_title(self, node, move_ids=1): #ipshell('At visit_title') if isinstance(node.parent, docutils.nodes.section): section_level = self.section_level if section_level > 5: print 'Warning: Heading/section levels greater than 3 not supported.' print ' Reducing to heading level 3 for heading:' print ' "%s"' % n...
el1 = etree.SubElement(el, 'text:span',
el1 = SubElement(el, 'text:span',
def visit_topic(self, node): #ipshell('At visit_topic') #import pdb; pdb.set_trace() if 'classes' in node.attributes: if 'contents' in node.attributes['classes']: el = self.append_child('text:p', attrib={ 'text:style-name': 'rststyle-horizontalline'}) el = self.append_child('text:p', attrib={ 'text:style-name': 'rststy...
el1 = etree.SubElement(root, 'meta-generator')
el1 = etree.SubElement(root, 'meta:generator')
def create_meta(self): root = etree.Element('office:document-meta', attrib=META_NAMESPACE_DICT) doc = etree.ElementTree(root) root = etree.SubElement(root, 'office:meta') el1 = etree.SubElement(root, 'meta-generator') el1.text = 'Docutils/rst2odf.py/%s' % (VERSION, ) s1 = os.environ.get('USER', '') el1 = etree.SubEleme...
el1.text = text.decode('latin-1').encode('utf-8')
text = text.decode('latin-1').encode('utf-8') el1.text = text self.title = text
def visit_title(self, node, move_ids=1): #ipshell('At visit_title') if isinstance(node.parent, docutils.nodes.section): section_level = self.section_level if section_level > 5: print 'Warning: Heading/section levels greater than 3 not supported.' print ' Reducing to heading level 3 for heading:' print ' "%s"' % n...
'text:style-name': 'rststyle-textbody'})
'text:style-name': 'rststyle-centeredtextbody'})
def visit_topic(self, node): #ipshell('At visit_topic') #import pdb; pdb.set_trace() if 'classes' in node.attributes: if 'contents' in node.attributes['classes']: el = self.append_child('text:p', attrib={ 'text:style-name': 'rststyle-horizontalline'}) el = self.append_child('text:p', attrib={ 'text:style-name': 'rststy...
int(value) return value
return int(value)
def validate_threshold(setting, value, option_parser, config_parser=None, config_section=None): try: int(value) return value except ValueError: try: return option_parser.thresholds[value.lower()] except (KeyError, AttributeError): raise (LookupError('unknown threshold: %r.' % value), None, sys.exc_info[2])
state_machine.insert_input(['`[[%s]]`_' % content[0]], 'MoinDirectives')
from docutils.nodes import reference if content[0].startswith('[['): macro = content[0] else: macro = '[[%s]]' % content[0] ref = reference(macro, refuri = macro) ref['name'] = macro return [ref]
def macro(self, name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): if len(content): state_machine.insert_input(['`[[%s]]`_' % content[0]], 'MoinDirectives') return
pub.set_reader('restructuredtext', None, 'restructuredtext')
pub.set_reader('standalone', None, 'restructuredtext')
def render(self): ''' Render the source to HTML ''' # format with strings pub = docutils.core.Publisher() pub.set_reader('restructuredtext', None, 'restructuredtext') pub.set_writer('html')
self.head.append(self.starttag(node, 'meta', **node.attributes))
self.head.append(self.emptytag(node, 'meta', **node.attributes))
def visit_meta(self, node): self.head.append(self.starttag(node, 'meta', **node.attributes))
text = text.replace(uchar,latex_equivalents[uchar])
text = text.replace(uchar,self.latex_equivalents[uchar])
def unicode_to_latex(self,text): # see LaTeX codec # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252124 # Only some special chracters are translated, for documents with many # utf-8 chars one should use the LaTeX unicode package. for uchar in self.latex_equivalents.keys(): text = text.replace(uchar,latex_eq...
(re.compile(r'\$' r'Date: (\d\d\d\d)/(\d\d)/(\d\d) [\d:]+ \$', re.IGNORECASE), r'\1-\2-\3'),
(re.compile(r'\$' r'Date: (\d\d\d\d)[-/](\d\d)[-/](\d\d) [\d:]+' r'[^$]* \$', re.IGNORECASE), r'\1-\2-\3'),
def check_compound_biblio_field(self, field, name): if len(field[-1]) > 1: field[-1] += self.document.reporter.warning( 'Cannot extract compound bibliographic field "%s".' % name, base_node=field) return None if not isinstance(field[-1][0], nodes.paragraph): field[-1] += self.document.reporter.warning( 'Cannot extract ...
encodings = [self.encoding, 'utf-8'] try: encodings.append(locale.nl_langinfo(locale.CODESET)) except: pass try: encodings.append(locale.getlocale()[1]) except: pass try: encodings.append(locale.getdefaultlocale()[1]) except: pass encodings.append('latin-1')
encodings = [self.encoding] if not self.encoding: encodings.append('utf-8') try: encodings.append(locale.nl_langinfo(locale.CODESET)) except: pass try: encodings.append(locale.getlocale()[1]) except: pass try: encodings.append(locale.getdefaultlocale()[1]) except: pass encodings.append('latin-1')
def decode(self, data): """ Decode a string, `data`, heuristically. Raise UnicodeError if unsuccessful.
opts = '-%s, --%s' % (shortopt, longopt),
opts = '-%s, --%s' % (shortopt, longopt)
def usage(): print usage_header for longopt, shortopt, description in options: if longopt[-1:] == '=': opts = '-%s arg, --%sarg' % (shortopt, longopt) else: opts = '-%s, --%s' % (shortopt, longopt), print '%-15s' % opts, if len(opts) > 14: print '%-16s' % '\n', while len(description) > 60: limit = description.rindex(' ...
notename = node['id']
def visit_footnote(self, node): if self.use_latex_footnotes: num,text = node.astext().split(None,1) num = self.encode(num.strip()) self.body.append('\\footnotetext['+num+']') self.body.append('{'+self.encode(text)+'}') raise nodes.SkipNode else: notename = node['id'] self.body.append('\\begin{figure}[b]') self.body.app...
self.body.append('\\hypertarget{%s}' % notename)
self.body.append('\\hypertarget{%s}' % node['id'])
def visit_footnote(self, node): if self.use_latex_footnotes: num,text = node.astext().split(None,1) num = self.encode(num.strip()) self.body.append('\\footnotetext['+num+']') self.body.append('{'+self.encode(text)+'}') raise nodes.SkipNode else: notename = node['id'] self.body.append('\\begin{figure}[b]') self.body.app...
self.body.append('\\hypertarget{%s}{' % node['name'])
self.body.append('\\hypertarget{%s}{' % node['id'])
def visit_target(self, node): if not (node.has_key('refuri') or node.has_key('refid') or node.has_key('refname')): self.body.append('\\hypertarget{%s}{' % node['name']) self.context.append('}') else: self.context.append('')
(l,node.astext(),node.parent['id']))
(l,text,node.parent['id']))
def depart_title(self, node): self.body.append(self.context.pop()) if isinstance(node.parent, nodes.sidebar): return # BUG level depends on style. elif node.parent.hasattr('id') and not self.use_latex_toc: # pdflatex allows level 0 to 3 # ToC would be the only on level 0 so i choose to decrement the rest. # "Table of c...
self.context.append('\\end{center}\n')
self.context.append('% HACK: latex chokes: -- perhaps a missing item.\n' '\\begin{list}{ }{' '\\setlength{\\topsep}{0pt}' '\\setlength{\\itemsep}{-1cm}}' '\\item \\item \\end{list}\n' '\\end{center}\n')
def visit_title(self, node): """Only 3 section levels are supported by LaTeX article (AFAIR).""" if isinstance(node.parent, nodes.topic): # section titles before the table of contents. if node.parent.hasattr('id'): self.body.append('\\hypertarget{%s}{}' % node.parent['id']) self.body.append('\\begin{center}\n') self.co...
try: return self.data[i] except TypeError: assert i.step is None, 'cannot handle slice with stride'
if isinstance(i, _SliceType): assert i.step in (None, 1), 'cannot handle slice with stride'
def __getitem__(self, i): try: return self.data[i] except TypeError: assert i.step is None, 'cannot handle slice with stride' return self.__class__(self.data[i.start:i.stop], items=self.items[i.start:i.stop], parent=self, parent_offset=i.start)
try: self.data[i] = item if self.parent: self.parent[i + self.parent_offset] = item except TypeError: assert i.step is None, 'cannot handle slice with stride'
if isinstance(i, _SliceType): assert i.step in (None, 1), 'cannot handle slice with stride'
def __setitem__(self, i, item): try: self.data[i] = item if self.parent: self.parent[i + self.parent_offset] = item except TypeError: assert i.step is None, 'cannot handle slice with stride' if not isinstance(item, ViewList): raise TypeError('assigning non-ViewList to ViewList slice') self.data[i.start:i.stop] = item.d...
class literal_block(General, TextElement): pass class doctest_block(General, TextElement): pass class line_block(General, TextElement): pass
class literal_block(General, FixedTextElement): pass class doctest_block(General, FixedTextElement): pass class line_block(General, FixedTextElement): pass
def astext(self): return self.get('delimiter', ' ') + TextElement.astext(self)
class comment(Special, Invisible, PreBibliographic, TextElement): pass
class comment(Special, Invisible, PreBibliographic, FixedTextElement): pass
def astext(self): return self.get('delimiter', ' ') + TextElement.astext(self)
return '%s (%s) %s' % (self['type'], self['level'], Element.astext(self))
return '%s/%s (%s) %s' % (self['type'], self['level'], self['source'], Element.astext(self))
def astext(self): return '%s (%s) %s' % (self['type'], self['level'], Element.astext(self))
class raw(Special, Inline, PreBibliographic, TextElement):
class raw(Special, Inline, PreBibliographic, FixedTextElement):
def copy(self): return self.__class__(self.transform, self.stage, self.details, **self.attributes)
attention author authors
address attention author authors
def astext(self): return self.get('alt', '')
self.error()
if self.debug: self.error()
def run(self, input_lines, input_offset=0, context=None, input_source=None): """ Run the state machine on `input_lines`. Return results (a list).
msgnode += self.reporter.severe('Duplicate ID: "%s".' % id)
msg = self.reporter.severe('Duplicate ID: "%s".' % id) if msgnode != None: msgnode += msg
def set_id(self, node, msgnode=None): if node.has_key('id'): id = node['id'] if self.ids.has_key(id) and self.ids[id] is not node: msgnode += self.reporter.severe('Duplicate ID: "%s".' % id) else: if node.has_key('name'): id = make_id(node['name']) else: id = '' while not id or self.ids.has_key(id): id = 'id%s' % self....
msgnode += self.reporter.system_message(
msg = self.reporter.system_message(
def set_duplicate_name_id(self, node, id, name, msgnode, explicit): old_id = self.nameids[name] old_explicit = self.nametypes[name] self.nametypes[name] = old_explicit or explicit if explicit: if old_explicit: level = 2 if old_id is not None: old_node = self.ids[old_id] if node.has_key('refuri'): refuri = node['refuri'...
msgnode += self.reporter.info(
msg = self.reporter.info(
def set_duplicate_name_id(self, node, id, name, msgnode, explicit): old_id = self.nameids[name] old_explicit = self.nametypes[name] self.nametypes[name] = old_explicit or explicit if explicit: if old_explicit: level = 2 if old_id is not None: old_node = self.ids[old_id] if node.has_key('refuri'): refuri = node['refuri'...
msgnode += self.reporter.error(
msg = self.reporter.error(
def note_substitution_def(self, subdef, def_name, msgnode=None): name = subdef['name'] = whitespace_normalize_name(def_name) if self.substitution_defs.has_key(name): msgnode += self.reporter.error( 'Duplicate substitution definition name: "%s".' % name, base_node=subdef) oldnode = self.substitution_defs[name] dupname(o...
'old': {'datestamp': '%Y-%m-%d %H:%M UTC', 'generator': 1, 'no_random': 1, 'python_home': 'http://www.python.org', 'source_link': 1,
'old': {u'datestamp': u'%Y-%m-%d %H:%M UTC', u'generator': 1, u'no_random': 1, u'python_home': u'http://www.python.org', u'source_link': 1,
def fixpath(path): return os.path.abspath(os.path.join(*(path.split('/'))))
'stylesheet_path': fixpath('data/stylesheets/pep.css'), 'template': fixpath('data/pep-html-template')}, 'one': {'datestamp': '%Y-%m-%d %H:%M UTC', 'generator': 1, 'no_random': 1, 'python_home': 'http://www.python.org',
u'stylesheet_path': fixpath(u'data/stylesheets/pep.css'), 'template': fixpath(u'data/pep-html-template')}, 'one': {u'datestamp': u'%Y-%m-%d %H:%M UTC', u'generator': 1, u'no_random': 1, u'python_home': u'http://www.python.org',
def fixpath(path): return os.path.abspath(os.path.join(*(path.split('/'))))
'source_link': 1,
u'source_link': 1,
def fixpath(path): return os.path.abspath(os.path.join(*(path.split('/'))))
'stylesheet_path': fixpath('data/stylesheets/pep.css'), 'tab_width': 8, 'template': fixpath('data/pep-html-template'), 'trim_footnote_reference_space': 1}, 'two': {'footnote_references': 'superscript', 'generator': 0,
u'stylesheet_path': fixpath(u'data/stylesheets/pep.css'), u'tab_width': 8, u'template': fixpath(u'data/pep-html-template'), u'trim_footnote_reference_space': 1}, 'two': {u'footnote_references': u'superscript', u'generator': 0,
def fixpath(path): return os.path.abspath(os.path.join(*(path.split('/'))))
'stylesheet': None, 'stylesheet_path': fixpath('data/test.css'),
u'stylesheet': None, u'stylesheet_path': fixpath(u'data/test.css'),
def fixpath(path): return os.path.abspath(os.path.join(*(path.split('/'))))
'list': {'expose_internals': ['a', 'b', 'c', 'd', 'e']}, 'list2': {'expose_internals': ['a', 'b', 'c', 'd', 'e', 'f']}, 'error': {'error_encoding': 'ascii', 'error_encoding_error_handler': 'strict'},
'list': {u'expose_internals': [u'a', u'b', u'c', u'd', u'e']}, 'list2': {u'expose_internals': [u'a', u'b', u'c', u'd', u'e', u'f']}, 'error': {u'error_encoding': u'ascii', u'error_encoding_error_handler': u'strict'},
def fixpath(path): return os.path.abspath(os.path.join(*(path.split('/'))))
<document source="<stdin>"> <system_message level="3" line="1" source="<stdin>" type="ERROR">
<document source="test data"> <system_message level="3" line="1" source="test data" type="ERROR">
def suite(): s = DocutilsTestSupport.ParserTestSuite() s.generateTests(totest) return s
invalid option value: (option: "align"; value: u'top')
invalid option value: (option: "align"; value: 'top')
def suite(): s = DocutilsTestSupport.ParserTestSuite() s.generateTests(totest) return s
include_graphics_options = ""
include_graphics_options = []
def visit_image(self, node): attrs = node.attributes # Add image URI to dependency list, assuming that it's # referring to a local file. self.settings.record_dependencies.add(attrs['uri']) pre = [] # in reverse order post = [] include_graphics_options = "" inline = isinstance(node.parent, nodes.T...
include_graphics_options = '[width=%s]' % attrs['width']
include_graphics_options.append('width=%s' % ( self.latex_image_length(attrs['width']), )) if attrs.has_key('height'): include_graphics_options.append('height=%s' % ( self.latex_image_length(attrs['height']), ))
def visit_image(self, node): attrs = node.attributes # Add image URI to dependency list, assuming that it's # referring to a local file. self.settings.record_dependencies.add(attrs['uri']) pre = [] # in reverse order post = [] include_graphics_options = "" inline = isinstance(node.parent, nodes.T...
include_graphics_options, attrs['uri'] ) )
options, attrs['uri'] ) )
def visit_image(self, node): attrs = node.attributes # Add image URI to dependency list, assuming that it's # referring to a local file. self.settings.record_dependencies.add(attrs['uri']) pre = [] # in reverse order post = [] include_graphics_options = "" inline = isinstance(node.parent, nodes.T...
'fo:border-left': '0.002cm solid
'fo:border-left': '0.035cm solid
def visit_option_list(self, node): #self.document.reporter.debug_flag = 1 #self.document.reporter.attach_observer(self.show_message) table_name = 'rststyle-tableoption' # # Generate automatic styles if not self.optiontablestyles_generated: self.optiontablestyles_generated = True el = etree.SubElement(self.automatic_sty...
'fo:border-top': '0.002cm solid 'fo:border-bottom': '0.002cm solid
'fo:border-top': '0.035cm solid 'fo:border-bottom': '0.035cm solid
def visit_option_list(self, node): #self.document.reporter.debug_flag = 1 #self.document.reporter.attach_observer(self.show_message) table_name = 'rststyle-tableoption' # # Generate automatic styles if not self.optiontablestyles_generated: self.optiontablestyles_generated = True el = etree.SubElement(self.automatic_sty...
'fo:border': '0.002cm solid
'fo:border': '0.035cm solid
def visit_option_list(self, node): #self.document.reporter.debug_flag = 1 #self.document.reporter.attach_observer(self.show_message) table_name = 'rststyle-tableoption' # # Generate automatic styles if not self.optiontablestyles_generated: self.optiontablestyles_generated = True el = etree.SubElement(self.automatic_sty...
'fo:border-bottom': '0.002cm solid
'fo:border-bottom': '0.035cm solid
def visit_option_list(self, node): #self.document.reporter.debug_flag = 1 #self.document.reporter.attach_observer(self.show_message) table_name = 'rststyle-tableoption' # # Generate automatic styles if not self.optiontablestyles_generated: self.optiontablestyles_generated = True el = etree.SubElement(self.automatic_sty...
'fo:border-left': '0.002cm solid 'fo:border-right': '0.002cm solid
'fo:border-left': '0.035cm solid 'fo:border-right': '0.035cm solid
def visit_option_list(self, node): #self.document.reporter.debug_flag = 1 #self.document.reporter.attach_observer(self.show_message) table_name = 'rststyle-tableoption' # # Generate automatic styles if not self.optiontablestyles_generated: self.optiontablestyles_generated = True el = etree.SubElement(self.automatic_sty...
table_name = 'Table%d' % self.table_count
table_name = '%s%d' % (TableStylePrefix, self.table_count, )
def visit_table(self, node): #self.trace_visit_node(node) #ipshell('At visit_table') self.table_count += 1 table_name = 'Table%d' % self.table_count el1 = etree.SubElement(self.automatic_styles, 'style:style', attrib={ 'style:name': '%s' % table_name, 'style:family': 'table', }) el1_1 = etree.SubElement(el1, 'style:tab...
el2 = etree.SubElement(self.current_element, 'table:table', attrib={
el2 = etree.SubElement(self.automatic_styles, 'style:style', attrib={ 'style:name': '%s.A1' % table_name, 'style:family': 'table-cell', }) line_style1 = '0.%03dcm solid el2_1 = etree.SubElement(el2, 'style:table-cell-properties', attrib={ 'fo:padding': '0.049cm', 'fo:border-left': line_style1, 'fo:border-right': line_s...
def visit_table(self, node): #self.trace_visit_node(node) #ipshell('At visit_table') self.table_count += 1 table_name = 'Table%d' % self.table_count el1 = etree.SubElement(self.automatic_styles, 'style:style', attrib={ 'style:name': '%s' % table_name, 'style:family': 'table', }) el1_1 = etree.SubElement(el1, 'style:tab...
self.set_current_element(el2)
self.set_current_element(el3)
def visit_table(self, node): #self.trace_visit_node(node) #ipshell('At visit_table') self.table_count += 1 table_name = 'Table%d' % self.table_count el1 = etree.SubElement(self.automatic_styles, 'style:style', attrib={ 'style:name': '%s' % table_name, 'style:family': 'table', }) el1_1 = etree.SubElement(el1, 'style:tab...
table_name = 'Table%d' % (self.table_count, ) colspec_name = 'Table%d.%s' % (self.table_count, chr(self.column_count),)
table_name = '%s%d' % (TableStylePrefix, self.table_count, ) colspec_name = '%s%d.%s' % ( TableStylePrefix, self.table_count, chr(self.column_count),)
def visit_colspec(self, node): #self.trace_visit_node(node) #ipshell('At visit_colspec') self.column_count += 1 table_name = 'Table%d' % (self.table_count, ) colspec_name = 'Table%d.%s' % (self.table_count, chr(self.column_count),) colwidth = node['colwidth'] el1 = etree.SubElement(self.automatic_styles, 'style:style',...
'style:family': 'table-column' })
'style:family': 'table-column', })
def visit_colspec(self, node): #self.trace_visit_node(node) #ipshell('At visit_colspec') self.column_count += 1 table_name = 'Table%d' % (self.table_count, ) colspec_name = 'Table%d.%s' % (self.table_count, chr(self.column_count),) colwidth = node['colwidth'] el1 = etree.SubElement(self.automatic_styles, 'style:style',...
'table:style-name': colspec_name })
'table:style-name': colspec_name, })
def visit_colspec(self, node): #self.trace_visit_node(node) #ipshell('At visit_colspec') self.column_count += 1 table_name = 'Table%d' % (self.table_count, ) colspec_name = 'Table%d.%s' % (self.table_count, chr(self.column_count),) colwidth = node['colwidth'] el1 = etree.SubElement(self.automatic_styles, 'style:style',...
table_name = 'Table%d' % (self.table_count, )
table_name = '%s%d' % (TableStylePrefix, self.table_count, )
def visit_entry(self, node): #self.trace_visit_node(node) #ipshell('At visit_entry') table_name = 'Table%d' % (self.table_count, ) self.column_count += 1 colspec_name = 'Table%d.%s' % (self.table_count, chr(self.column_count),) el1 = self.append_child('table:table-cell', attrib={ 'table:style-name': colspec_name, 'offi...
colspec_name = 'Table%d.%s' % (self.table_count, chr(self.column_count),)
colspec_name = '%s%d.%s' % ( TableStylePrefix, self.table_count, chr(self.column_count),) cellspec_name = '%s%d.A1' % ( TableStylePrefix, self.table_count,)
def visit_entry(self, node): #self.trace_visit_node(node) #ipshell('At visit_entry') table_name = 'Table%d' % (self.table_count, ) self.column_count += 1 colspec_name = 'Table%d.%s' % (self.table_count, chr(self.column_count),) el1 = self.append_child('table:table-cell', attrib={ 'table:style-name': colspec_name, 'offi...
'table:style-name': colspec_name, 'office:value-type': 'string'})
'table:style-name': cellspec_name, 'office:value-type': 'string', })
def visit_entry(self, node): #self.trace_visit_node(node) #ipshell('At visit_entry') table_name = 'Table%d' % (self.table_count, ) self.column_count += 1 colspec_name = 'Table%d.%s' % (self.table_count, chr(self.column_count),) el1 = self.append_child('table:table-cell', attrib={ 'table:style-name': colspec_name, 'offi...
def visit_admonition(self, node, name):
def visit_admonition(self, node, name=''):
def visit_admonition(self, node, name): self.body.append('\\begin{center}\\begin{sffamily}\n') self.body.append('\\fbox{\\parbox{\\admonitionwidth}{\n') self.body.append('\\textbf{\\large '+ self.language.labels[name] + '}\n'); self.body.append('\\vspace{2mm}\n')
self.body.append('\\textbf{\\large '+ self.language.labels[name] + '}\n');
if name: self.body.append('\\textbf{\\large '+ self.language.labels[name] + '}\n');
def visit_admonition(self, node, name): self.body.append('\\begin{center}\\begin{sffamily}\n') self.body.append('\\fbox{\\parbox{\\admonitionwidth}{\n') self.body.append('\\textbf{\\large '+ self.language.labels[name] + '}\n'); self.body.append('\\vspace{2mm}\n')
def depart_admonition(self):
def depart_admonition(self, node=None):
def depart_admonition(self): self.body.append('}}\n') # end parbox fbox self.body.append('\\end{sffamily}\n\\end{center}\n');
string = string.replace('<p>', '') string = string.replace('</p>', '') string = string.replace('\n', '') string = re.sub('> ', '>', string)
replacements = {'<p>': '', '</p>': '', '\n': '', '> ': '>'} for src, dst in replacements.items(): string = string.replace(src, dst)
def rst_write(self, string): if self.strip_paragraph: string = string.replace('<p>', '') string = string.replace('</p>', '') string = string.replace('\n', '') string = re.sub('> ', '>', string) # Everything seems to have a space ending the text block. We want to # get rid of this if len(string) and string[-1] == ' ': s...
if len(string) and string[-1] == ' ':
if string and string[-1] == ' ':
def rst_write(self, string): if self.strip_paragraph: string = string.replace('<p>', '') string = string.replace('</p>', '') string = string.replace('\n', '') string = re.sub('> ', '>', string) # Everything seems to have a space ending the text block. We want to # get rid of this if len(string) and string[-1] == ' ': s...
if (node['refuri'].find('wiki:') != -1) or \ (node['refuri'].find('attachment:') != -1): target = node['refuri']
refuri = node['refuri'] if [i for i in moin_link_schemes if refuri.lstrip().startswith(i)]: target = refuri
def visit_reference(self, node): target = None if 'refuri' in node.attributes: if (node['refuri'].find('wiki:') != -1) or \ (node['refuri'].find('attachment:') != -1): target = node['refuri'] elif ('name' in node.attributes and fully_normalize_name(node['name']) == node['refuri']): target = ':%s:' % (node['name']) # Th...
fully_normalize_name(node['name']) == node['refuri']):
fully_normalize_name(node['name']) == refuri):
def visit_reference(self, node): target = None if 'refuri' in node.attributes: if (node['refuri'].find('wiki:') != -1) or \ (node['refuri'].find('attachment:') != -1): target = node['refuri'] elif ('name' in node.attributes and fully_normalize_name(node['name']) == node['refuri']): target = ':%s:' % (node['name']) # Th...
elif ':' not in node['refuri']: target = ':%s:' % (node['refuri'])
elif ':' not in refuri: target = ':%s:' % (refuri)
def visit_reference(self, node): target = None if 'refuri' in node.attributes: if (node['refuri'].find('wiki:') != -1) or \ (node['refuri'].find('attachment:') != -1): target = node['refuri'] elif ('name' in node.attributes and fully_normalize_name(node['name']) == node['refuri']): target = ':%s:' % (node['name']) # Th...
node_text = node.astext().replace('\n', ' ') self.wikiparser.raw = '[%s %s]' % (target, node_text) self.wikiparser.format(self.formatter)
if target.startswith('inline:'): self.wikiparser.raw = target self.wikiparser.format(self.formatter) else: node_text = node.astext().replace('\n', ' ') self.wikiparser.raw = '[%s %s]' % (target, node_text) self.wikiparser.format(self.formatter)
def visit_reference(self, node): target = None if 'refuri' in node.attributes: if (node['refuri'].find('wiki:') != -1) or \ (node['refuri'].find('attachment:') != -1): target = node['refuri'] elif ('name' in node.attributes and fully_normalize_name(node['name']) == node['refuri']): target = ':%s:' % (node['name']) # Th...
def visit_image(self, node): if node['uri'].lstrip().startswith('inline:'): self.strip_paragraph = 1 self.wikiparser.raw = node['uri'] self.wikiparser.format(self.formatter) self.strip_paragraph = 0 raise docutils.nodes.SkipNode return html4css1.HTMLTranslator.visit_image(self, node)
def depart_warning(self, node): self.request.write(self.formatter.highlight(0))