mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 02:28:21 +00:00
Copy docs into Zeek repo directly
This is based on commit 2731def9159247e6da8a3191783c89683363689c from the zeek-docs repo.
This commit is contained in:
parent
83f1e74643
commit
ded98cd373
1074 changed files with 169319 additions and 0 deletions
41
doc/ext/literal-emph.py
Normal file
41
doc/ext/literal-emph.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
import re
|
||||
|
||||
import sphinx
|
||||
from docutils import nodes
|
||||
|
||||
# This extension adds a 'literal-emph' directive that operates the same
|
||||
# as the 'code-block' directive except that it additionally understands
|
||||
# the **strong emphasis** markup, allowing custom rendering of it to be
|
||||
# substituted in the final literal block (e.g. HTML adds <strong> elements).
|
||||
# Adding " (no-emph)" to the end of a line within the 'literal-emph' content
|
||||
# disables substitutions for that line.
|
||||
|
||||
|
||||
class LiteralEmphNode(nodes.General, nodes.Element):
|
||||
pass
|
||||
|
||||
|
||||
class LiteralEmph(sphinx.directives.code.CodeBlock):
|
||||
def run(self):
|
||||
node = LiteralEmphNode()
|
||||
node += super().run()
|
||||
return [node]
|
||||
|
||||
|
||||
def visit_litemph_node(self, node):
|
||||
pass
|
||||
|
||||
|
||||
def depart_litemph_node(self, node):
|
||||
text = self.body[-1]
|
||||
text = re.sub(r"\*\*(.*?)\*\*(?!.* \(no-emph\)\n)", r"<strong>\1</strong>", text)
|
||||
text = re.sub(r"(.*) \(no-emph\)\n", r"\1\n", text)
|
||||
self.body[-1] = text
|
||||
|
||||
|
||||
def setup(app):
|
||||
app.add_directive("literal-emph", LiteralEmph)
|
||||
app.add_node(LiteralEmphNode, html=(visit_litemph_node, depart_litemph_node))
|
||||
return {
|
||||
"parallel_read_safe": True,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue