def visit_image(self, node): olduri = node['uri'] # rewrite the URI if the environment knows about it if olduri in self.builder.images: node['uri'] = posixpath.join(self.builder.imgpath, self.builder.images[olduri]) BaseTranslator.visit_image(self, node)
def visit_field_list(self, node): fields = {} for n in node.children: if not n.children: continue child = n.children[0] rawsource = child.rawsource if rawsource.startswith("param "): index = rawsource.index("param ") if not child.children: continue # Strip leading escaped asterisks for vararg parameters in Google code style docstrings trimmed_name = re.sub(r'\\\*', '*', rawsource[index + 6:]) child.children[0] = Text(trimmed_name) fields[trimmed_name] = n if rawsource == "return": fields["return"] = n for n in node.children: if not n.children: continue child = n.children[0] rawsource = child.rawsource if rawsource.startswith("type "): index = rawsource.index("type ") name = re.sub(r'\\\*', '*', rawsource[index + 5:]) if name in fields: fields[name].type = n.children[1][0][0] node.children.remove(n) if rawsource == "rtype": if "return" in fields: fields["return"].type = n.children[1][0][0] node.children.remove(n) HTMLTranslator.visit_field_list(self, node)
def depart_title(self, node): # XXX Because we want to inject our link into the title, this is # largely copy-pasta'd from sphinx.html.writers.HtmlTranslator. close_tag = self.context[-1] if (self.permalink_text and self.builder.add_permalinks and node.parent.hasattr('ids') and node.parent['ids']): aname = node.parent['ids'][0] if close_tag.startswith('</a></h'): self.body.append('</a>') self.body.append(u'<a class="headerlink" href="#%s" ' % aname + u'title="%s">%s</a>' % ( _('Permalink to this headline'), self.permalink_text)) self.body.append(u'<a class="headerlink" href="%s#%s" ' % ( html.slide_path(self.builder), aname,) + u'title="%s">%s' % ( _('Slides'), self.builder.app.config.slide_html_slide_link_symbol)) if not close_tag.startswith('</a></h'): self.body.append('</a>') BaseTranslator.depart_title(self, node)
def __init__(self, document): HTMLTranslator.__init__(self, document) self.head_prefix = ['','','','',''] self.body_prefix = [] self.body_suffix = [] self.stylesheet = [] self.initial_header_level = 5
def visit_bullet_list(self, node): # type: (nodes.Node) -> None if len(node) == 1 and node[0].tagname == 'toctree': # avoid emitting empty <ul></ul> raise nodes.SkipNode self.generate_targets_for_listing(node) BaseTranslator.visit_bullet_list(self, node)
def visit_title(self, node): # type: (nodes.Node) -> None BaseTranslator.visit_title(self, node) self.add_secnumber(node) self.add_fignumber(node.parent) if isinstance(node.parent, nodes.table): self.body.append('<span class="caption-text">')
def visit_field_list(self, node): fields = {} for n in node.children: if len(n.children) == 0: continue child = n.children[0] rawsource = child.rawsource if rawsource.startswith("param "): index = rawsource.index("param ") if len(child.children) == 0: continue child.children[0] = Text(rawsource[index + 6:]) fields[rawsource[index + 6:]] = n if rawsource == "return": fields["return"] = n for n in node.children: if len(n.children) == 0: continue child = n.children[0] rawsource = child.rawsource if rawsource.startswith("type "): index = rawsource.index("type ") name = rawsource[index + 5:] if fields.has_key(name): fields[name].type = n.children[1][0][0] node.children.remove(n) if rawsource == "rtype": if fields.has_key("return"): fields["return"].type = n.children[1][0][0] node.children.remove(n) HTMLTranslator.visit_field_list(self, node)
def visit_caption(self, node): if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'): self.body.append('<div class="code-block-caption">') else: BaseTranslator.visit_caption(self, node) self.add_fignumber(node) self.body.append(self.starttag(node, 'span', '', CLASS='caption-text'))
def __init__(self, builder, *args, **kwds): BaseTranslator.__init__(self, *args, **kwds) self.highlighter = PygmentsBridge('html', builder.config.pygments_style) self.no_smarty = 0 self.builder = builder self.highlightlang = 'python' self.highlightlinenothreshold = sys.maxint
def __init__(self, document): HTMLTranslator.__init__(self, document) self.head = "" self.head_prefix = ['', '', '', '', ''] self.body_prefix = [] self.body_suffix = [] self.stylesheet = []
def __init__(self, document): document.settings.embed_stylesheet = False document.settings.xml_declaration = False HTMLTranslator.__init__(self, document) footer_html = render_theme_template(config['theme']['theme_dir'], 'footer.html', web_path=config['theme']['web_path']) head_html = render_theme_template(config['theme']['theme_dir'], 'head.html', web_path=config['theme']['web_path']) self.head.insert(0, head_html) self.body_suffix = [footer_html]
def visit_reference(self, node): BaseTranslator.visit_reference(self, node) if node.hasattr("reftitle"): # ugly hack to add a title attribute starttag = self.body[-1] if not starttag.startswith("<a "): return self.body[-1] = '<a title="%s"' % self.attval(node["reftitle"]) + starttag[2:]
def __init__(self, document): # Copied from epydoc.markup.restructuredtext._EpydocHTMLTranslator if self.settings is None: settings = OptionParser([HTMLWriter()]).get_default_values() self.__class__.settings = settings document.settings = self.settings HTMLTranslator.__init__(self, document)
def __init__(self, document): HTMLTranslator.__init__(self, document) self.head_prefix = ['','','','',''] self.body_prefix = [] self.body_suffix = [] self.stylesheet = [] def astext(self): return ''.join(self.body)
def __init__(self, builder, *args, **kwds): BaseTranslator.__init__(self, *args, **kwds) self.highlighter = PygmentsBridge('html', builder.config.pygments_style) self.no_smarty = 0 self.builder = builder self.highlightlang = builder.config.highlight_language self.highlightlinenothreshold = sys.maxint self.protect_literal_text = 0
def __init__(self, document): HTMLTranslator.__init__(self,document) #pdb.set_trace() #print('old self.stylesheet='+self.stylesheet) self.stylesheet = ['<link rel="stylesheet" href="%%CSS_REL_PATH%%" type="text/css" />\n'] navbarlist = ['<div id="sidebar">\n','<p>This is where<br>\n','the sidebar goes</p>\n','</div>\n'] self.body_prefix.append('<div id="content">\n') mytail = ['</div>\n'] + navbarlist self.body_suffix[0:0] = mytail
def visit_paragraph(self, node): if self.first_paragraph_as_text is None: # just paragraphs at the root of the document should be used. # warnings, blockquotes and similar aren't good descriptions. if node.parent.tagname.strip() == 'document': self.first_paragraph_as_text = \ ' '.join([i.strip() \ for i in node.astext().splitlines(False)]) HTMLTranslator.visit_paragraph(self, node)
def __init__(self, builder, *args, **kwds): BaseTranslator.__init__(self, *args, **kwds) self.highlighter = builder.highlighter self.no_smarty = 0 self.builder = builder self.highlightlang = builder.config.highlight_language self.highlightlinenothreshold = sys.maxint self.protect_literal_text = 0 self.add_permalinks = builder.config.html_add_permalinks
def visit_emphasis(self, node): # Generate a corrent index term anchor if 'term' in node.get('classes') and node.children: doc = self.document.copy() doc[:] = [node.children[0].copy()] self.body.append( self._linker.translate_indexterm(ParsedRstDocstring(doc))) raise SkipNode() HTMLTranslator.visit_emphasis(self, node)
def visit_reference(self, node): BaseTranslator.visit_reference(self, node) if node.hasattr('reftitle'): # ugly hack to add a title attribute starttag = self.body[-1] if not starttag.startswith('<a '): return self.body[-1] = '<a title="%s"' % self.attval(node['reftitle']) + \ starttag[2:] if node.hasattr('secnumber'): self.body.append('%s. ' % '.'.join(map(str, node['secnumber'])))
def depart_title(self, node): close_tag = self.context[-1] if self.builder.name != 'htmlhelp' and \ (close_tag.startswith('</h') or close_tag.startswith('</a></h')) and \ node.parent.hasattr('ids') and node.parent['ids']: aname = node.parent['ids'][0] # add permalink anchor self.body.append(u'<a class="headerlink" href="#%s" ' % aname + u'title="Permalink to this headline">\u00B6</a>') BaseTranslator.depart_title(self, node)
def visit_title(self, node, *args, **kwds): # if we have a section we do our own processing in order # to have ids in the hN-tags and not in additional a-tags if isinstance(node.parent, nodes.section): h_level = self.section_level + self.initial_header_level - 1 if node.parent.get('ids'): attrs = {'ids': node.parent['ids']} else: attrs = {} self.body.append(self.starttag(node, 'h%d' % h_level, '', **attrs)) self.context.append('</h%d>\n' % h_level) else: BaseTranslator.visit_title(self, node, *args, **kwds)
def __init__(self, document, docstring_linker, directory, docindex, context): self._linker = docstring_linker self._directory = directory self._docindex = docindex self._context = context # Set the document's settings. settings = OptionParser([HTMLWriter()]).get_default_values() document.settings = settings # Call the parent constructor. HTMLTranslator.__init__(self, document)
def depart_title(self, node): close_tag = self.context[-1] if (self.permalink_text and self.builder.add_permalinks and node.parent.hasattr('ids') and node.parent['ids']): aname = node.parent['ids'][0] # add permalink anchor # replacing anchors with confluence macro before = '<ac:structured-macro ac:name="anchor">' before += '<ac:parameter ac:name="">' after = '</ac:parameter></ac:structured-macro>' self.body.append(before + aname + after) BaseTranslator.depart_title(self, node)
def depart_caption(self, node): self.body.append('</span>') # append permalink if available if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'): self.add_permalink_ref(node.parent, _('Permalink to this code')) elif isinstance(node.parent, nodes.figure): self.add_permalink_ref(node.parent, _('Permalink to this image')) if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'): self.body.append('</div>\n') else: BaseTranslator.depart_caption(self, node)
def __init__(self, builder, *args, **kwds): BaseTranslator.__init__(self, *args, **kwds) self.highlighter = builder.highlighter self.no_smarty = 0 self.builder = builder self.highlightlang = builder.config.highlight_language self.highlightlinenothreshold = sys.maxint self.protect_literal_text = 0 self.permalink_text = builder.config.html_add_permalinks # support backwards-compatible setting to a bool if not isinstance(self.permalink_text, basestring): self.permalink_text = self.permalink_text and u'\u00B6' or '' self.permalink_text = self.encode(self.permalink_text) self.secnumber_suffix = builder.config.html_secnumber_suffix
def depart_title(self, node): close_tag = self.context[-1] if ( self.builder.add_header_links and (close_tag.startswith("</h") or close_tag.startswith("</a></h")) and node.parent.hasattr("ids") and node.parent["ids"] ): aname = node.parent["ids"][0] # add permalink anchor self.body.append( u'<a class="headerlink" href="#%s" ' % aname + u'title="%s">\u00B6</a>' % _("Permalink to this headline") ) BaseTranslator.depart_title(self, node)
def __init__(self, builder, *args, **kwds): BaseTranslator.__init__(self, *args, **kwds) self.highlighter = builder.highlighter self.no_smarty = 0 self.builder = builder self.highlightlang = builder.config.highlight_language self.highlightlinenothreshold = sys.maxsize self.protect_literal_text = 0 self.permalink_text = builder.config.html_add_permalinks # support backwards-compatible setting to a bool if not isinstance(self.permalink_text, str): self.permalink_text = self.permalink_text and "\u00B6" or "" self.permalink_text = self.encode(self.permalink_text) self.secnumber_suffix = builder.config.html_secnumber_suffix self.param_separator = "" self._table_row_index = 0
def __init__(self, document): # I don't believe we can embed any style content # the header, so always link to the stylesheet. document.settings.embed_stylesheet = 0 document.settings.base_section = int(document.settings.base_section) HTMLTranslator.__init__(self, document) # ht2html likes having a title, so add a default one self.headers = {'title': 'None'} stylesheet = utils.get_stylesheet_reference(document.settings, os.path.join(os.getcwd(),'dummy')) if stylesheet: self.headers['stylesheet']= stylesheet # using first author found for .ht 'Author' header self.has_author = 0
def visit_literal_block(self, node): if node.rawsource != node.astext(): # most probably a parsed-literal block -- don't highlight return BaseTranslator.visit_literal_block(self, node) lang = self.highlightlang linenos = node.rawsource.count('\n') >= \ self.highlightlinenothreshold - 1 highlight_args = node.get('highlight_args', {}) if 'language' in node: # code-block directives lang = node['language'] highlight_args['force'] = True if 'linenos' in node: linenos = node['linenos'] if lang is self.highlightlang_base: # only pass highlighter options for original language opts = self.highlightopts else: opts = {} def warner(msg): self.builder.warn(msg, (self.builder.current_docname, node.line)) highlighted = self.highlighter.highlight_block( node.rawsource, lang, opts=opts, warn=warner, linenos=linenos, **highlight_args) starttag = self.starttag(node, 'div', suffix='', CLASS='highlight-%s' % lang) self.body.append(starttag + highlighted + '</div>\n') raise nodes.SkipNode
def depart_caption(self, node): # type: (nodes.Node) -> None self.body.append('</span>') # append permalink if available if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'): self.add_permalink_ref(node.parent, _('Permalink to this code')) elif isinstance(node.parent, nodes.figure): image_nodes = node.parent.traverse(nodes.image) target_node = image_nodes and image_nodes[0] or node.parent self.add_permalink_ref(target_node, _('Permalink to this image')) elif node.parent.get('toctree'): self.add_permalink_ref(node.parent.parent, _('Permalink to this toctree')) if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'): self.body.append('</div>\n') else: BaseTranslator.depart_caption(self, node)
def depart_title(self, node): # type: (nodes.Node) -> None close_tag = self.context[-1] if (self.permalink_text and self.builder.add_permalinks and node.parent.hasattr('ids') and node.parent['ids']): # add permalink anchor if close_tag.startswith('</h'): self.add_permalink_ref(node.parent, _('Permalink to this headline')) elif close_tag.startswith('</a></h'): self.body.append(u'</a><a class="headerlink" href="#%s" ' % node.parent['ids'][0] + u'title="%s">%s' % ( _('Permalink to this headline'), self.permalink_text)) elif isinstance(node.parent, nodes.table): self.body.append('</span>') self.add_permalink_ref(node.parent, _('Permalink to this table')) elif isinstance(node.parent, nodes.table): self.body.append('</span>') BaseTranslator.depart_title(self, node)
def visit_image(self, node): olduri = node['uri'] # rewrite the URI if the environment knows about it if olduri in self.builder.images: node['uri'] = posixpath.join(self.builder.imgpath, self.builder.images[olduri]) if node['uri'].lower().endswith('svg') or \ node['uri'].lower().endswith('svgz'): atts = {'src': node['uri']} if 'width' in node: atts['width'] = node['width'] if 'height' in node: atts['height'] = node['height'] if 'alt' in node: atts['alt'] = node['alt'] if 'align' in node: self.body.append('<div align="%s" class="align-%s">' % (node['align'], node['align'])) self.context.append('</div>\n') else: self.context.append('') self.body.append(self.emptytag(node, 'img', '', **atts)) return if 'scale' in node: # Try to figure out image height and width. Docutils does that too, # but it tries the final file name, which does not necessarily exist # yet at the time the HTML file is written. if not ('width' in node and 'height' in node): size = get_image_size(os.path.join(self.builder.srcdir, olduri)) if size is None: self.builder.env.warn_node('Could not obtain image size. ' ':scale: option is ignored.', node) else: if 'width' not in node: node['width'] = str(size[0]) if 'height' not in node: node['height'] = str(size[1]) BaseTranslator.visit_image(self, node)
def __init__(self, builder, *args, **kwds): # type: (StandaloneHTMLBuilder, Any, Any) -> None BaseTranslator.__init__(self, *args, **kwds) self.highlighter = builder.highlighter self.no_smarty = 0 self.builder = builder self.highlightlang = self.highlightlang_base = \ builder.config.highlight_language self.highlightopts = builder.config.highlight_options self.highlightlinenothreshold = sys.maxsize self.docnames = [builder.current_docname] # for singlehtml builder self.protect_literal_text = 0 self.permalink_text = builder.config.html_add_permalinks # support backwards-compatible setting to a bool if not isinstance(self.permalink_text, string_types): self.permalink_text = self.permalink_text and u'\u00B6' or '' self.permalink_text = self.encode(self.permalink_text) self.secnumber_suffix = builder.config.html_secnumber_suffix self.param_separator = '' self.optional_param_level = 0 self._table_row_index = 0 self.required_params_left = 0
def depart_title(self, node): h_level = 0 close_tag = self.context[-1] close = close_tag.rfind('>') if close != -1: h_level = close_tag[close - 1] if (h_level and h_level.isdigit() and (close == close_tag.rfind('h%s>' % h_level) + 2) and self.permalink_text and self.builder.add_permalinks and node.parent.hasattr('ids') and node.parent['ids']): aname = node.parent['ids'][0] tags = [] open_tag = "<h%s>" % h_level # Walk back to find open_tag in body for i in reversed(range(len(self.body))): tags.append(self.body.pop()) if tags[-1] == open_tag: self.body.append(tags.pop()) tags.reverse() break # <h1>Manual Installation using Packages<a class="headerlink" href="#manual-installation-using-packages" # title="Permalink to this headline">¶</a></h1> # becomes # <h1><a class="headerlink" href="#manual-installation-using-packages" # title="Permalink to this headline"></a>Manual Installation using Packages</h1> if close_tag.startswith('</h'): self.body.append( u'<a class="headerlink" href="#%s" title="%s"></a>' % (aname, _('Perma-link to this heading'))) elif close_tag.startswith('</a></h'): self.body.append( u'</a><a class="headerlink" href="#%s" title="%s">' % (aname, _('Perma-link to this heading'))) self.body = self.body + tags BaseTranslator.depart_title(self, node)
def visit_literal_block(self, node): if node.rawsource != node.astext(): # most probably a parsed-literal block -- don't highlight return BaseTranslator.visit_literal_block(self, node) lang = self.highlightlang linenos = node.rawsource.count('\n') >= self.highlightlinenothreshold - 1 if node.has_key('language'): # code-block directives lang = node['language'] if node.has_key('linenos'): linenos = node['linenos'] self.body.append(self.highlighter.highlight_block(node.rawsource, lang, linenos)) raise nodes.SkipNode
def visit_image(self, node): olduri = node['uri'] # rewrite the URI if the environment knows about it if olduri in self.builder.images: node['uri'] = posixpath.join(self.builder.imgpath, self.builder.images[olduri]) if node.has_key('scale'): if Image and not (node.has_key('width') and node.has_key('height')): try: im = Image.open(os.path.join(self.builder.srcdir, olduri)) except (IOError, # Source image can't be found or opened UnicodeError): # PIL doesn't like Unicode paths. print olduri pass else: if not node.has_key('width'): node['width'] = str(im.size[0]) if not node.has_key('height'): node['height'] = str(im.size[1]) del im BaseTranslator.visit_image(self, node)
def visit_literal_block(self, node): if node.rawsource != node.astext(): # most probably a parsed-literal block -- don't highlight return BaseTranslator.visit_literal_block(self, node) lang = self.highlightlang linenos = node.rawsource.count('\n') >= self.highlightlinenothreshold - 1 if node.has_key('language'): # code-block directives lang = node['language'] if node.has_key('linenos'): linenos = node['linenos'] highlighted = self.highlighter.highlight_block(node.rawsource, lang, linenos) starttag = self.starttag(node, 'div', suffix='', CLASS='highlight-%s' % lang) self.body.append(starttag + highlighted + '</div>\n') raise nodes.SkipNode
def visit_problematic(self, node): # Don't insert hyperlinks to nowhere for e.g. unclosed asterisks if not self._is_text_wrapper(node): return HTMLTranslator.visit_problematic(self, node) directive, text = self._strip_markup(node.astext()) if directive and directive[1:-1] in ('exc', 'class'): self.body.append( self.starttag(node, 'a', '', href='psi_element://#typename#' + text)) self.body.append(text) self.body.append('</a>') else: self.body.append(text) raise nodes.SkipNode
def visit_problematic(self, node): """Don't insert hyperlinks to nowhere for e.g. unclosed asterisks.""" if not self._is_text_wrapper(node): return HTMLTranslator.visit_problematic(self, node) node_text = node.astext() m = re.match(r'(:\w+)?(:\S+:)?`(.+?)`', node_text) if m: _, directive, text = m.groups('') if directive[1:-1] == 'exc': self.body.append(self.starttag(node, 'a', '', href = 'psi_element://#typename#' + text)) self.body.append(text) self.body.append('</a>') else: self.body.append(text) else: self.body.append(node_text) raise nodes.SkipNode
def visit_title(self, node): """Only 6 section levels are supported by HTML.""" if isinstance(node.parent, nodes.topic): HTMLTranslator.visit_title(self, node) elif self.section_level == 0: HTMLTranslator.visit_title(self, node) # document title title = node.astext() self.headers['title'] = self.encode(title) else: # offset section level to account for ``base_section``. self.section_level += (self.settings.base_section - 1) HTMLTranslator.visit_title(self, node) self.section_level -= (self.settings.base_section - 1)
def starttag(self, node, tagname, suffix='\n', **attributes): attr_dicts = [attributes] if isinstance(node, nodes.Node): attr_dicts.append(node.attributes) if isinstance(node, dict): attr_dicts.append(node) # Munge each attribute dictionary. Unfortunately, we need to # iterate through attributes one at a time because some # versions of docutils don't case-normalize attributes. for attr_dict in attr_dicts: # For some reason additional classes in bullet list make it render poorly. # Such lists are used to render multiple return values in Numpy docstrings by Napoleon. if tagname == 'ul' and isinstance(node.parent, field_body): attr_dict.pop('class', None) attr_dict.pop('classes', None) continue for (key, val) in attr_dict.items(): # Prefix all CSS classes with "rst-"; and prefix all # names with "rst-" to avoid conflicts. if key.lower() in ('class', 'id', 'name'): attr_dict[key] = 'rst-%s' % val elif key.lower() in ('classes', 'ids', 'names'): attr_dict[key] = ['rst-%s' % cls for cls in val] elif key.lower() == 'href': if attr_dict[key][:1] == '#': attr_dict[key] = '#rst-%s' % attr_dict[key][1:] if tagname == 'th' and isinstance(node, field_name): attributes['valign'] = 'top' # Render rubric start as HTML header if tagname == 'p' and isinstance(node, rubric): tagname = 'h1' # For headings, use class="heading" if re.match(r'^h\d+$', tagname): attributes['class'] = ' '.join([attributes.get('class', ''), 'heading']).strip() return HTMLTranslator.starttag(self, node, tagname, suffix, **attributes)
def visit_literal_block(self, node): if node.rawsource != node.astext(): # most probably a parsed-literal block -- don't highlight return BaseTranslator.visit_literal_block(self, node) lang = self.highlightlang linenos = node.rawsource.count('\n') >= \ self.highlightlinenothreshold - 1 highlight_args = node.get('highlight_args', {}) if 'language' in node: # code-block directives lang = node['language'] highlight_args['force'] = True if 'linenos' in node: linenos = node['linenos'] if lang is self.highlightlang_base: # only pass highlighter options for original language opts = self.highlightopts else: opts = {} def warner(msg): self.builder.warn(msg, (self.builder.current_docname, node.line)) #highlighted = self.highlighter.highlight_block( #node.rawsource, lang, opts=opts, warn=warner, linenos=linenos, #**highlight_args) highlighted = node.rawsource #starttag = self.starttag(node, 'div', suffix='', #CLASS='highlight-%s' % lang) starttag = self.starttag(node, 'pre', suffix='', **{ "CLASS": 'prettyprint', "DATA-LANG": lang }) #self.body.append(starttag + highlighted + '</div>\n') self.body.append(starttag + highlighted + '</pre>\n') raise nodes.SkipNode
def visit_literal_block(self, node): if node.rawsource != node.astext(): # most probably a parsed-literal block -- don't highlight return BaseTranslator.visit_literal_block(self, node) lang = self.highlightlang linenos = node.rawsource.count('\n') >= \ self.highlightlinenothreshold - 1 highlight_args = node.get('highlight_args', {}) if node.has_key('language'): # code-block directives lang = node['language'] highlight_args['force'] = True if node.has_key('linenos'): linenos = node['linenos'] def warner(msg): self.builder.warn(msg, (self.builder.current_docname, node.line)) highlighted = self.highlighter.highlight_block( node.rawsource, lang, warn=warner, linenos=linenos, **highlight_args) starttag = self.starttag(node, 'div', suffix='', CLASS='highlight-%s' % lang) self.body.append(starttag + highlighted + '</div>\n') raise nodes.SkipNode
def visit_table(self, node): # type: (nodes.Node) -> None self._table_row_index = 0 return BaseTranslator.visit_table(self, node)
def __init__(self, document): HTMLTranslator.__init__(self, document) self.compact_p = None
def visit_field_list(self, node): self._fieldlist_row_index = 0 return BaseTranslator.visit_field_list(self, node)
def visit_table(self, node): self._table_row_index = 0 return BaseTranslator.visit_table(self, node)
def visit_title(self, node): BaseTranslator.visit_title(self, node) self.add_secnumber(node) self.add_fignumber(node) if isinstance(node.parent, nodes.table): self.body.append('<span class="caption-text">')
def visit_bullet_list(self, node): if len(node) == 1 and node[0].tagname == 'toctree': raise nodes.SkipNode BaseTranslator.visit_bullet_list(self, node)
def should_be_compact_paragraph(self, node): """Determine if the <p> tags around paragraph can be omitted.""" if isinstance(node.parent, addnodes.desc_content): # Never compact desc_content items. return False return BaseTranslator.should_be_compact_paragraph(self, node)
def visit_title(self, node): BaseTranslator.visit_title(self, node) self.add_secnumber(node)
def visit_field_list(self, node): # type: (nodes.Node) -> None self._fieldlist_row_index = 0 return BaseTranslator.visit_field_list(self, node)
def depart_image(self, node): # type: (nodes.Node) -> None if node['uri'].lower().endswith(('svg', 'svgz')): self.body.append(self.context.pop()) else: BaseTranslator.depart_image(self, node)