How to use the docutils.nodes.raw function in docutils

To help you get started, we’ve selected a few docutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flexxui / flexx / docs / scripts / uiexample.py View on Github external
def init(self):
        """  # mind the indentation

SIMPLE_CODE_T2 = """
from flexx import flx

class App(flx.Widget):

    def init(self):
        """  # mind the indentation

all_examples = []


class uiexample(nodes.raw): pass


def create_ui_example(filename, to_root, height=300, source=None):
    """ Given a filename, export the containing app to HTML, return
    generated HTML. Needs to be done via filename, not direct code, so
    that PScript can obtain source.
    """
    code = open(filename, 'rb').read().decode()
    fname = os.path.split(filename)[1]
    filename_parts = 'examples', fname[:-3] + '.html'
    filename_abs = os.path.join(HTML_DIR, *filename_parts)
    filename_rel = to_root + '/' + '/'.join(filename_parts)
    
    # Import - mod_name must be unique, because JS modules match Py modules
    try:
        mod_name = "app_" + fname[:-3]
github nagareproject / core / nagare / doc / code_block.py View on Github external
lexer = get_lexer_by_name(arguments[0])
    except ValueError:
        lexer = TextLexer()

    if 'linenos' in options:
        options['linenos'] = True
        options['cssclass'] = 'ncode'

    if 'hl_lines' in options:
        options['hl_lines'] = [int(l.strip()) for l in options['hl_lines'].split(',')]

    formatter = HtmlFormatter(noclasses=True, **options)
    parsed = highlight(u'\n'.join(content), lexer, formatter)
    if 'linenos' in options:
        parsed = '<div class="ncodediv">' + parsed + '</div>'
    return [nodes.raw('', parsed, format='html')]
github IronLanguages / ironpython2 / External.LCA_RESTRICTED / Languages / IronPython / 27 / Doc / docutils / parsers / rst / directives / misc.py View on Github external
% (self.name, self.options['url'], error))
            raw_file = io.StringInput(
                source=raw_text, source_path=source, encoding=encoding,
                error_handler=(self.state.document.settings.\
                               input_encoding_error_handler))
            try:
                text = raw_file.read()
            except UnicodeError, error:
                raise self.severe(
                    'Problem with "%s" directive:\n%s: %s'
                    % (self.name, error.__class__.__name__, error))
            attributes['source'] = source
        else:
            # This will always fail because there is no content.
            self.assert_has_content()
        raw_node = nodes.raw('', text, **attributes)
        return [raw_node]
github ContinualAI / wiki / conf.py View on Github external
def role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
        return [nodes.raw('', text, format=format)], []
github peopledoc / procrastinate / docs / sphinxext / changelog.py View on Github external
section = nodes.section(ids=[id_section])
        section += nodes.title(text=title)

        par = nodes.paragraph()

        # Links
        par += nodes.reference("", "GitHub", refuri=release["url"])
        if pypi_name:
            par += nodes.Text(" - ")
            url = "https://pypi.org/project/" f"{pypi_name}/{tag}/"
            par += nodes.reference("", "PyPI", refuri=url)

        section += par

        # Body
        section += nodes.raw(text=release["descriptionHTML"], format="html")
        yield section
github twisted / twisted / doc / web2 / generation-scripts / formatters.py View on Github external
def python(name, arguments, options, content, lineno,
           content_offset, block_text, state, state_machine):
    inp = StringIO('\n'.join(content))
    outp = StringIO()
    htmlizer.filter(inp, outp, writer=htmlizer.SmallerHTMLWriter)
    html = outp.getvalue()
    return [nodes.raw('', html, format='html')]
python.content = 1
github RunestoneInteractive / RunestoneComponents / runestone / showeval / showeval.py View on Github external
if step == True:
                if line != "":
                    if is_dynamic:
                        esc_line = str(line).replace("{", "\{")
                    else:
                        esc_line = str(line)
                    self.options["steps"].append(esc_line)
            elif "~~~~" in line:
                step = True
            else:
                self.options["preReqLines"] += line + "<br>\n"

        res = (CODE + SCRIPT) % self.options

        addHTMLToDB(self.options["divid"], self.options["basecourse"], res)
        return [nodes.raw(self.block_text, res, format="html")]
github RunestoneInteractive / RunestoneComponents / runestone / video / video.py View on Github external
super(IframeVideo, self).run()
        self.options['video_id'] = directives.uri(self.arguments[0])
        if not self.options.get('width'):
            self.options['width'] = self.default_width
        if not self.options.get('height'):
            self.options['height'] = self.default_height
        if not self.options.get('align'):
            self.options['align'] = 'left'
        if not self.options.get('http'):
            self.options['http'] = 'https'
        if not self.options.get('divid'):
            self.options['divid'] = self.arguments[0]
        
        res = self.html % self.options
        addHTMLToDB(self.options['divid'], self.options['basecourse'], res)
        raw_node = nodes.raw(self.block_text, res, format='html')
        raw_node.source, raw_node.line = self.state_machine.get_source_and_line(self.lineno)
        return [raw_node]
github openmm / openmm / docs / sphinx / caption.py View on Github external
def run(self):
        latexPrefix = raw('', '{\\centering', format='latex')
        latexSuffix = raw('', '\\par}\\bigskip', format='latex')
        text = '\n'.join(self.content)
        content_node = compound(rawsource=text)
        self.state.nested_parse(self.content, self.content_offset, content_node)
        content_node.attributes['classes'].append('caption')
        return [latexPrefix, content_node, latexSuffix]
github OpenDSA / OpenDSA / tools / simple2full.py View on Github external
def run(self):
    # """ Restructured text extension for including CSS and other libraries """
    return [nodes.raw('', 'null', format='xml')]