Python docutils.nodes.SkipNode() Examples
The following are 30
code examples of docutils.nodes.SkipNode().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
docutils.nodes
, or try the search function
.
Example #1
Source File: manpage.py From deepWordBug with Apache License 2.0 | 6 votes |
def visit_title(self, node): if isinstance(node.parent, nodes.topic): self.body.append(self.defs['topic-title'][0]) elif isinstance(node.parent, nodes.sidebar): self.body.append(self.defs['sidebar-title'][0]) elif isinstance(node.parent, nodes.admonition): self.body.append('.IP "') elif self.section_level == 0: self._docinfo['title'] = node.astext() # document title for .TH self._docinfo['title_upper'] = node.astext().upper() raise nodes.SkipNode elif self.section_level == 1: self.body.append('.SH %s\n' % self.deunicode(node.astext().upper())) raise nodes.SkipNode else: self.body.append('.SS ')
Example #2
Source File: manpage.py From faces with GNU General Public License v2.0 | 6 votes |
def visit_title(self, node): if isinstance(node.parent, nodes.topic): self.body.append(self.defs['topic-title'][0]) elif isinstance(node.parent, nodes.sidebar): self.body.append(self.defs['sidebar-title'][0]) elif isinstance(node.parent, nodes.admonition): self.body.append('.IP "') elif self.section_level == 0: self._docinfo['title'] = node.astext() # document title for .TH self._docinfo['title_upper'] = node.astext().upper() raise nodes.SkipNode elif self.section_level == 1: self.body.append('.SH %s\n' % self.deunicode(node.astext().upper())) raise nodes.SkipNode else: self.body.append('.SS ')
Example #3
Source File: docutils_xml.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 6 votes |
def visit_raw(self, node): if 'xml' not in node.get('format', '').split(): # skip other raw content? # raise nodes.SkipNode self.default_visit(node) return # wrap in <raw> element self.default_visit(node) # or not? xml_string = node.astext() self.output.append(xml_string) self.default_departure(node) # or not? # Check validity of raw XML: if isinstance(xml_string, unicode) and sys.version_info < (3,): xml_string = xml_string.encode('utf8') try: self.xmlparser.parse(StringIO(xml_string)) except xml.sax._exceptions.SAXParseException, error: col_num = self.the_handle.locator.getColumnNumber() line_num = self.the_handle.locator.getLineNumber() srcline = node.line if not isinstance(node.parent, nodes.TextElement): srcline += 2 # directive content start line msg = 'Invalid raw XML in column %d, line offset %d:\n%s' % ( col_num, line_num, node.astext()) self.warn(msg, source=node.source, line=srcline+line_num-1)
Example #4
Source File: manpage.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 6 votes |
def visit_title(self, node): if isinstance(node.parent, nodes.topic): self.body.append(self.defs['topic-title'][0]) elif isinstance(node.parent, nodes.sidebar): self.body.append(self.defs['sidebar-title'][0]) elif isinstance(node.parent, nodes.admonition): self.body.append('.IP "') elif self.section_level == 0: self._docinfo['title'] = node.astext() # document title for .TH self._docinfo['title_upper'] = node.astext().upper() raise nodes.SkipNode elif self.section_level == 1: self.body.append('.SH %s\n' % self.deunicode(node.astext().upper())) raise nodes.SkipNode else: self.body.append('.SS ')
Example #5
Source File: manpage.py From bash-lambda-layer with MIT License | 6 votes |
def visit_title(self, node): if isinstance(node.parent, nodes.topic): self.body.append(self.defs['topic-title'][0]) elif isinstance(node.parent, nodes.sidebar): self.body.append(self.defs['sidebar-title'][0]) elif isinstance(node.parent, nodes.admonition): self.body.append('.IP "') elif self.section_level == 0: self._docinfo['title'] = node.astext() # document title for .TH self._docinfo['title_upper'] = node.astext().upper() raise nodes.SkipNode elif self.section_level == 1: self.body.append('.SH %s\n' % self.deunicode(node.astext().upper())) raise nodes.SkipNode else: self.body.append('.SS ')
Example #6
Source File: __init__.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def visit_raw(self, node): if not 'latex' in node.get('format', '').split(): raise nodes.SkipNode if not self.is_inline(node): self.out.append('\n') if node['classes']: self.visit_inline(node) # append "as-is" skipping any LaTeX-encoding self.verbatim = True
Example #7
Source File: __init__.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def visit_reference(self, node): # We need to escape #, \, and % if we use the URL in a command. special_chars = {ord('#'): r'\#', ord('%'): r'\%', ord('\\'): r'\\', } # external reference (URL) if 'refuri' in node: href = str(node['refuri']).translate(special_chars) # problematic chars double caret and unbalanced braces: if href.find('^^') != -1 or self.has_unbalanced_braces(href): self.error( 'External link "%s" not supported by LaTeX.\n' ' (Must not contain "^^" or unbalanced braces.)' % href) if node['refuri'] == node.astext(): self.out.append(r'\url{%s}' % href) raise nodes.SkipNode self.out.append(r'\href{%s}{' % href) return # internal reference if 'refid' in node: href = node['refid'] elif 'refname' in node: href = self.document.nameids[node['refname']] else: raise AssertionError('Unknown reference.') if not self.is_inline(node): self.out.append('\n') self.out.append('\\hyperref[%s]{' % href) if self._reference_label: self.out.append('\\%s{%s}}' % (self._reference_label, href.replace('#', ''))) raise nodes.SkipNode
Example #8
Source File: __init__.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def visit_docinfo_item(self, node, name): if name == 'author': self.pdfauthor.append(self.attval(node.astext())) if self.use_latex_docinfo: if name in ('author', 'organization', 'contact', 'address'): # We attach these to the last author. If any of them precedes # the first author, put them in a separate "author" group # (in lack of better semantics). if name == 'author' or not self.author_stack: self.author_stack.append([]) if name == 'address': # newlines are meaningful self.insert_newline = True text = self.encode(node.astext()) self.insert_newline = False else: text = self.attval(node.astext()) self.author_stack[-1].append(text) raise nodes.SkipNode elif name == 'date': self.date.append(self.attval(node.astext())) raise nodes.SkipNode self.out.append('\\textbf{%s}: &\n\t' % self.language_label(name)) if name == 'address': self.insert_newline = True self.out.append('{\\raggedright\n') self.context.append(' } \\\\\n') else: self.context.append(' \\\\\n')
Example #9
Source File: manpage.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def visit_field_name(self, node): if self._in_docinfo: self._field_name = node.astext() raise nodes.SkipNode else: self.body.append(self.defs['field_name'][0])
Example #10
Source File: _html_base.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def ignore_node(self, node): # ignore nodes that are never complex (can contain only inline nodes) raise nodes.SkipNode # Paragraphs and text
Example #11
Source File: textwriter.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def visit_title(self, node): if isinstance(node.parent, nodes.Admonition): self.add_text(node.astext()+': ') raise nodes.SkipNode self.new_state(0)
Example #12
Source File: __init__.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def visit_literal(self, node): # special case: "code" role classes = node.get('classes', []) if 'code' in classes: # filter 'code' from class arguments node['classes'] = [cls for cls in classes if cls != 'code'] self.body.append(self.starttag(node, 'code', '')) return self.body.append( self.starttag(node, 'tt', '', CLASS='docutils literal')) text = node.astext() for token in self.words_and_spaces.findall(text): if token.strip(): # Protect text like "--an-option" and the regular expression # ``[+]?(\d+(\.\d*)?|\.\d+)`` from bad line wrapping if self.in_word_wrap_point.search(token): self.body.append('<span class="pre">%s</span>' % self.encode(token)) else: self.body.append(self.encode(token)) elif token in ('\n', ' '): # Allow breaks at whitespace: self.body.append(token) else: # Protect runs of multiple spaces; the last space can wrap: self.body.append(' ' * (len(token) - 1) + ' ') self.body.append('</tt>') # Content already processed: raise nodes.SkipNode # add newline after opening tag, don't use <code> for code
Example #13
Source File: _html_base.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def ignore_node(self, node): # ignore nodes that are never complex (can contain only inline nodes) raise nodes.SkipNode # Paragraphs and text
Example #14
Source File: manpage.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def depart_subtitle(self, node): # document subtitle calls SkipNode self.body.append(self.defs['strong'][1]+'\n.PP\n')
Example #15
Source File: manpage.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def visit_system_message(self, node): # TODO add report_level #if node['level'] < self.document.reporter['writer'].report_level: # Level is too low to display: # raise nodes.SkipNode attr = {} backref_text = '' if node.hasattr('id'): attr['name'] = node['id'] if node.hasattr('line'): line = ', line %s' % node['line'] else: line = '' self.body.append('.IP "System Message: %s/%s (%s:%s)"\n' % (node['type'], node['level'], node['source'], line))
Example #16
Source File: manpage.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def depart_subtitle(self, node): # document subtitle calls SkipNode self.body.append(self.defs['strong'][1]+'\n.PP\n')
Example #17
Source File: manpage.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def visit_label(self, node): # footnote and citation if (isinstance(node.parent, nodes.footnote) or isinstance(node.parent, nodes.citation)): raise nodes.SkipNode self.document.reporter.warning('"unsupported "label"', base_node=node) self.body.append('[')
Example #18
Source File: manpage.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def visit_label(self, node): # footnote and citation if (isinstance(node.parent, nodes.footnote) or isinstance(node.parent, nodes.citation)): raise nodes.SkipNode self.document.reporter.warning('"unsupported "label"', base_node=node) self.body.append('[')
Example #19
Source File: __init__.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def label_delim(self, node, bracket, superscript): if isinstance(node.parent, nodes.footnote): raise nodes.SkipNode else: assert isinstance(node.parent, nodes.citation) if not self._use_latex_citations: self.out.append(bracket)
Example #20
Source File: __init__.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def visit_literal(self, node): # special case: "code" role classes = node.get('classes', []) if 'code' in classes: # filter 'code' from class arguments node['classes'] = [cls for cls in classes if cls != 'code'] self.body.append(self.starttag(node, 'code', '')) return self.body.append( self.starttag(node, 'tt', '', CLASS='docutils literal')) text = node.astext() for token in self.words_and_spaces.findall(text): if token.strip(): # Protect text like "--an-option" and the regular expression # ``[+]?(\d+(\.\d*)?|\.\d+)`` from bad line wrapping if self.in_word_wrap_point.search(token): self.body.append('<span class="pre">%s</span>' % self.encode(token)) else: self.body.append(self.encode(token)) elif token in ('\n', ' '): # Allow breaks at whitespace: self.body.append(token) else: # Protect runs of multiple spaces; the last space can wrap: self.body.append(' ' * (len(token) - 1) + ' ') self.body.append('</tt>') # Content already processed: raise nodes.SkipNode # add newline after opening tag, don't use <code> for code
Example #21
Source File: __init__.py From bash-lambda-layer with MIT License | 5 votes |
def visit_reference(self, node): # We need to escape #, \, and % if we use the URL in a command. special_chars = {ord('#'): r'\#', ord('%'): r'\%', ord('\\'): r'\\', } # external reference (URL) if 'refuri' in node: href = str(node['refuri']).translate(special_chars) # problematic chars double caret and unbalanced braces: if href.find('^^') != -1 or self.has_unbalanced_braces(href): self.error( 'External link "%s" not supported by LaTeX.\n' ' (Must not contain "^^" or unbalanced braces.)' % href) if node['refuri'] == node.astext(): self.out.append(r'\url{%s}' % href) raise nodes.SkipNode self.out.append(r'\href{%s}{' % href) return # internal reference if 'refid' in node: href = node['refid'] elif 'refname' in node: href = self.document.nameids[node['refname']] else: raise AssertionError('Unknown reference.') if not self.is_inline(node): self.out.append('\n') self.out.append('\\hyperref[%s]{' % href) if self._reference_label: self.out.append('\\%s{%s}}' % (self._reference_label, href.replace('#', ''))) raise nodes.SkipNode
Example #22
Source File: __init__.py From bash-lambda-layer with MIT License | 5 votes |
def visit_raw(self, node): if not 'latex' in node.get('format', '').split(): raise nodes.SkipNode if not self.is_inline(node): self.out.append('\n') if node['classes']: self.visit_inline(node) # append "as-is" skipping any LaTeX-encoding self.verbatim = True
Example #23
Source File: __init__.py From bash-lambda-layer with MIT License | 5 votes |
def visit_docinfo_item(self, node, name): if name == 'author': self.pdfauthor.append(self.attval(node.astext())) if self.use_latex_docinfo: if name in ('author', 'organization', 'contact', 'address'): # We attach these to the last author. If any of them precedes # the first author, put them in a separate "author" group # (in lack of better semantics). if name == 'author' or not self.author_stack: self.author_stack.append([]) if name == 'address': # newlines are meaningful self.insert_newline = True text = self.encode(node.astext()) self.insert_newline = False else: text = self.attval(node.astext()) self.author_stack[-1].append(text) raise nodes.SkipNode elif name == 'date': self.date.append(self.attval(node.astext())) raise nodes.SkipNode self.out.append('\\textbf{%s}: &\n\t' % self.language_label(name)) if name == 'address': self.insert_newline = True self.out.append('{\\raggedright\n') self.context.append(' } \\\\\n') else: self.context.append(' \\\\\n')
Example #24
Source File: _html_base.py From bash-lambda-layer with MIT License | 5 votes |
def ignore_node(self, node): # ignore nodes that are never complex (can contain only inline nodes) raise nodes.SkipNode # Paragraphs and text
Example #25
Source File: docutils_xml.py From bash-lambda-layer with MIT License | 5 votes |
def visit_raw(self, node): if 'xml' not in node.get('format', '').split(): # skip other raw content? # raise nodes.SkipNode self.default_visit(node) return # wrap in <raw> element self.default_visit(node) # or not? xml_string = node.astext() self.output.append(xml_string) self.default_departure(node) # or not? # Check validity of raw XML: if isinstance(xml_string, str) and sys.version_info < (3,): xml_string = xml_string.encode('utf8') try: self.xmlparser.parse(StringIO(xml_string)) except xml.sax._exceptions.SAXParseException as error: col_num = self.the_handle.locator.getColumnNumber() line_num = self.the_handle.locator.getLineNumber() srcline = node.line if not isinstance(node.parent, nodes.TextElement): srcline += 2 # directive content start line msg = 'Invalid raw XML in column %d, line offset %d:\n%s' % ( col_num, line_num, node.astext()) self.warn(msg, source=node.source, line=srcline+line_num-1) raise nodes.SkipNode # content already processed
Example #26
Source File: manpage.py From bash-lambda-layer with MIT License | 5 votes |
def visit_system_message(self, node): # TODO add report_level #if node['level'] < self.document.reporter['writer'].report_level: # Level is too low to display: # raise nodes.SkipNode attr = {} backref_text = '' if node.hasattr('id'): attr['name'] = node['id'] if node.hasattr('line'): line = ', line %s' % node['line'] else: line = '' self.body.append('.IP "System Message: %s/%s (%s:%s)"\n' % (node['type'], node['level'], node['source'], line))
Example #27
Source File: manpage.py From bash-lambda-layer with MIT License | 5 votes |
def visit_label(self, node): # footnote and citation if (isinstance(node.parent, nodes.footnote) or isinstance(node.parent, nodes.citation)): raise nodes.SkipNode self.document.reporter.warning('"unsupported "label"', base_node=node) self.body.append('[')
Example #28
Source File: manpage.py From bash-lambda-layer with MIT License | 5 votes |
def visit_field_name(self, node): if self._in_docinfo: self._field_name = node.astext() raise nodes.SkipNode else: self.body.append(self.defs['field_name'][0])
Example #29
Source File: __init__.py From bash-lambda-layer with MIT License | 5 votes |
def visit_literal(self, node): # special case: "code" role classes = node.get('classes', []) if 'code' in classes: # filter 'code' from class arguments node['classes'] = [cls for cls in classes if cls != 'code'] self.body.append(self.starttag(node, 'code', '')) return self.body.append( self.starttag(node, 'tt', '', CLASS='docutils literal')) text = node.astext() for token in self.words_and_spaces.findall(text): if token.strip(): # Protect text like "--an-option" and the regular expression # ``[+]?(\d+(\.\d*)?|\.\d+)`` from bad line wrapping if self.in_word_wrap_point.search(token): self.body.append('<span class="pre">%s</span>' % self.encode(token)) else: self.body.append(self.encode(token)) elif token in ('\n', ' '): # Allow breaks at whitespace: self.body.append(token) else: # Protect runs of multiple spaces; the last space can wrap: self.body.append(' ' * (len(token) - 1) + ' ') self.body.append('</tt>') # Content already processed: raise nodes.SkipNode # add newline after opening tag, don't use <code> for code
Example #30
Source File: textwriter.py From bash-lambda-layer with MIT License | 5 votes |
def visit_label(self, node): raise nodes.SkipNode # XXX: option list could use some better styling