pydoc_fork.reporter.rst_support
index
../../pydoc_fork/reporter/rst_support.py

Rst to HTML function
Credits: https://stackoverflow.com/a/49047197/33264

 
Modules
 
docutils.core

 
`from` Modules
 
docutils.writers.html4css1

 
Classes
 
docutils.writers.html4css1.HTMLTranslator(docutils.writers._html_base.HTMLTranslator)
HTMLFragmentTranslator(docutils.writers.html4css1.HTMLTranslator)

 
class HTMLFragmentTranslator(docutils.writers.html4css1.HTMLTranslator)
HTMLFragmentTranslator(document: Any) -> None
 
Minimum to call docutils
 
 
Method resolution order:
HTMLFragmentTranslator
docutils.writers.html4css1.HTMLTranslator
docutils.writers._html_base.HTMLTranslator
docutils.nodes.NodeVisitor
builtins.object

Methods defined here:
__init__(self, document: Any) -> None
setup
astext(self) -> str
minimum to call docutils

Methods inherited from docutils.writers.html4css1.HTMLTranslator:
depart_author(self, node)
depart_authors(self, node)
depart_citation(self, node)
depart_colspec(self, node)
depart_description(self, node)
depart_docinfo(self, node)
depart_docinfo_item(self)
depart_enumerated_list(self, node)
depart_field(self, node)
depart_field_body(self, node)
depart_field_list(self, node)
depart_field_name(self, node)
depart_footnote(self, node)
depart_footnote_reference(self, node)
depart_image(self, node)
depart_label(self, node)
depart_literal_block(self, node)
# add newline
depart_option_group(self, node)
depart_option_list(self, node)
depart_option_list_item(self, node)
depart_paragraph(self, node)
depart_subscript(self, node)
depart_subtitle(self, node)
depart_superscript(self, node)
depart_table(self, node)
depart_tbody(self, node)
depart_thead(self, node)
footnote_backrefs(self, node)
is_compactable(self, node)
set_first_last(self, node)
# ersatz for first/last pseudo-classes missing in CSS1
should_be_compact_paragraph(self, node)
Determine if the <p> tags around paragraph ``node`` can be omitted.
visit_address(self, node)
# add newline after opening tag
visit_admonition(self, node)
# ersatz for first/last pseudo-classes
visit_author(self, node)
# author, authors: use <br> instead of paragraphs
visit_authors(self, node)
visit_citation(self, node)
# citations: Use table for bibliographic references.
visit_classifier(self, node)
# insert classifier-delimiter (not required with CSS2)
visit_colspec(self, node)
# use "width" argument insted of "style: 'width'":
visit_definition(self, node)
# ersatz for first/last pseudo-classes
visit_definition_list(self, node)
# don't add "simple" class value
visit_description(self, node)
# use a table for description lists
visit_docinfo(self, node)
# use table for docinfo
visit_docinfo_item(self, node, name, meta=True)
visit_doctest_block(self, node)
# add newline after opening tag
visit_entry(self, node)
# insert an NBSP into empty cells, ersatz for first/last
visit_enumerated_list(self, node)
The 'start' attribute does not conform to HTML 4.01's strict.dtd, but
cannot be emulated in CSS1 (HTML 5 reincludes it).
visit_field(self, node)
# use table for field-list:
visit_field_body(self, node)
visit_field_list(self, node)
visit_field_name(self, node)
visit_footnote(self, node)
# use table for footnote text
visit_footnote_reference(self, node)
# insert markers in text as pseudo-classes are not supported in CSS1:
visit_generated(self, node)
# just pass on generated text
visit_image(self, node)
visit_label(self, node)
# use table for footnote text,
# context added in footnote_backrefs.
visit_list_item(self, node)
# ersatz for first/last pseudo-classes
visit_literal(self, node)
# use <tt> (not supported by HTML5),
# cater for limited styling options in CSS1 using hard-coded NBSPs
visit_literal_block(self, node)
# add newline after opening tag, don't use <code> for code
visit_option_group(self, node)
# use table for option list
visit_option_list(self, node)
visit_option_list_item(self, node)
visit_paragraph(self, node)
visit_sidebar(self, node)
# ersatz for first/last pseudo-classes
visit_subscript(self, node)
# <sub> not allowed in <pre>
visit_subtitle(self, node)
# Use <h*> for subtitles (deprecated in HTML 5)
visit_superscript(self, node)
# <sup> not allowed in <pre> in HTML 4
visit_system_message(self, node)
# <tt> element deprecated in HTML 5
visit_table(self, node)
# "hard coded" border setting
visit_tbody(self, node)
# hard-coded vertical alignment
visit_thead(self, node)
# hard-coded vertical alignment

Data and other attributes inherited from docutils.writers.html4css1.HTMLTranslator:
attribution_formats = {'dash': ('&mdash;', ''), 'none': ('', ''), 'parens': ('(', ')'), 'parentheses': ('(', ')')}
content_type = '<meta http-equiv="Content-Type" content="text/html; charset=%s" />\n'
content_type_mathml = '<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=%s" />\n'
doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tra...w.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'
object_image_types = {'.svg': 'image/svg+xml', '.swf': 'application/x-shockwave-flash'}
special_characters = {34: '&quot;', 38: '&amp;', 60: '&lt;', 62: '&gt;', ...}

Methods inherited from docutils.writers._html_base.HTMLTranslator:
add_meta(self, tag)
attval(self, text, whitespace=re.compile('[\n\r\t\x0b\x0c]'))
Cleanse, HTML encode, and return attribute value text.
check_simple_list(self, node)
Check for a simple list that can be rendered compactly.
cloak_email(self, addr)
Try to hide the link text of a email link from harversters.
cloak_mailto(self, uri)
Try to hide a mailto: URL from harvesters.
depart_Text(self, node)
depart_abbreviation(self, node)
depart_acronym(self, node)
depart_address(self, node)
depart_admonition(self, node=None)
depart_attribution(self, node)
depart_block_quote(self, node)
depart_bullet_list(self, node)
depart_caption(self, node)
depart_citation_reference(self, node)
depart_classifier(self, node)
depart_compound(self, node)
depart_contact(self, node)
depart_container(self, node)
depart_copyright(self, node)
depart_date(self, node)
depart_decoration(self, node)
depart_definition(self, node)
depart_definition_list(self, node)
depart_definition_list_item(self, node)
depart_doctest_block(self, node)
depart_document(self, node)
depart_emphasis(self, node)
depart_entry(self, node)
depart_figure(self, node)
depart_footer(self, node)
depart_generated(self, node)
depart_header(self, node)
depart_inline(self, node)
depart_legend(self, node)
depart_line(self, node)
depart_line_block(self, node)
depart_list_item(self, node)
depart_literal(self, node)
depart_math(self, node)
depart_math_block(self, node)
depart_meta(self, node)
depart_option(self, node)
depart_option_argument(self, node)
depart_option_string(self, node)
depart_organization(self, node)
depart_problematic(self, node)
depart_reference(self, node)
depart_revision(self, node)
depart_row(self, node)
depart_rubric(self, node)
depart_section(self, node)
depart_sidebar(self, node)
depart_status(self, node)
depart_strong(self, node)
depart_system_message(self, node)
depart_target(self, node)
depart_term(self, node)
Leave the end tag to `self.visit_definition()`, in case there's a
classifier.
depart_tgroup(self, node)
depart_title(self, node)
depart_title_reference(self, node)
depart_topic(self, node)
depart_transition(self, node)
depart_version(self, node)
emptytag(self, node, tagname, suffix='\n', **attributes)
Construct and return an XML-compatible empty tag.
encode(self, text)
Encode special characters in `text` & return.
set_class_on_child(self, node, class_, index=0)
Set class `class_` on the visible child no. index of `node`.
Do nothing if node has fewer children than `index`.
starttag(self, node, tagname, suffix='\n', empty=False, **attributes)
Construct and return a start tag given a node (id & class attributes
are extracted), tag name, and optional attributes.
stylesheet_call(self, path)
Return code to reference or embed stylesheet file `path`
unimplemented_visit(self, node)
visit_Text(self, node)
visit_abbreviation(self, node)
visit_acronym(self, node)
visit_attribution(self, node)
visit_block_quote(self, node)
visit_bullet_list(self, node)
visit_caption(self, node)
visit_citation_reference(self, node)
visit_comment(self, node, sub=<built-in method sub of re.Pattern object at 0x000001EC4BC2CBE0>)
Escape double-dashes in comment text.
visit_compound(self, node)
visit_contact(self, node)
visit_container(self, node)
visit_copyright(self, node)
visit_date(self, node)
visit_decoration(self, node)
visit_definition_list_item(self, node)
visit_document(self, node)
visit_emphasis(self, node)
visit_figure(self, node)
visit_footer(self, node)
# use HTML 5 <footer> element?
visit_header(self, node)
visit_inline(self, node)
visit_legend(self, node)
visit_line(self, node)
visit_line_block(self, node)
visit_math(self, node, math_env='')
visit_math_block(self, node)
visit_meta(self, node)
# Meta tags: 'lang' attribute replaced by 'xml:lang' in XHTML 1.1
# HTML5/polyglot recommends using both
visit_option(self, node)
visit_option_argument(self, node)
visit_option_string(self, node)
visit_organization(self, node)
visit_problematic(self, node)
visit_raw(self, node)
visit_reference(self, node)
visit_revision(self, node)
visit_row(self, node)
visit_rubric(self, node)
visit_section(self, node)
visit_status(self, node)
visit_strong(self, node)
visit_substitution_definition(self, node)
Internal only.
visit_substitution_reference(self, node)
visit_target(self, node)
visit_term(self, node)
visit_tgroup(self, node)
visit_title(self, node)
Only 6 section levels are supported by HTML.
visit_title_reference(self, node)
visit_topic(self, node)
visit_transition(self, node)
visit_version(self, node)

Data and other attributes inherited from docutils.writers._html_base.HTMLTranslator:
doctype_mathml = '<!DOCTYPE html>\n'
embedded_stylesheet = '<style type="text/css">\n\n%s\n</style>\n'
generator = '<meta name="generator" content="Docutils %s: http://docutils.sourceforge.net/" />\n'
head_prefix_template = '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="%(lang)s" lang="%(lang)s">\n<head>\n'
in_word_wrap_point = re.compile('.+\\W\\W.+|[-?].+')
lang_attribute = 'lang'
math_tags = {'html': ('div', 'span', 'formula'), 'latex': ('pre', 'tt', 'math'), 'mathjax': ('div', 'span', 'math'), 'mathml': ('div', '', '')}
mathjax_script = '<script type="text/javascript" src="%s"></script>\n'
mathjax_url = 'file:/usr/share/javascript/mathjax/MathJax.js'
stylesheet_link = '<link rel="stylesheet" href="%s" type="text/css" />\n'
words_and_spaces = re.compile('[^ \\n]+| +|\\n')
xml_declaration = '<?xml version="1.0" encoding="%s" ?>\n'

Methods inherited from docutils.nodes.NodeVisitor:
dispatch_departure(self, node)
Call self."``depart_`` + node class name" with `node` as
parameter.  If the ``depart_...`` method does not exist, call
self.unknown_departure.
dispatch_visit(self, node)
Call self."``visit_`` + node class name" with `node` as
parameter.  If the ``visit_...`` method does not exist, call
self.unknown_visit.
unknown_departure(self, node)
Called before exiting unknown `Node` types.
 
Raise exception unless overridden.
unknown_visit(self, node)
Called when entering unknown `Node` types.
 
Raise an exception unless overridden.

Data and other attributes inherited from docutils.nodes.NodeVisitor:
optional = ()

 
Functions
 
rst_to_html(text: str) -> str
Convert rst string to html string

 
Data
  html_fragment_writer = <docutils.writers.html4css1.Writer object>