aboutsummaryrefslogtreecommitdiff
path: root/scripts/gen_vimdoc.py
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-04-27 18:25:55 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-05-01 00:18:49 +0200
commitc11e6181330e9e27ec8af1712f505b38a00d8ca3 (patch)
tree02d3ccdecacaea5046de2367d07e46bced76c3b3 /scripts/gen_vimdoc.py
parentafd947e0c3b34a0dc36140a373af46aa31d8f1ab (diff)
downloadrneovim-c11e6181330e9e27ec8af1712f505b38a00d8ca3.tar.gz
rneovim-c11e6181330e9e27ec8af1712f505b38a00d8ca3.tar.bz2
rneovim-c11e6181330e9e27ec8af1712f505b38a00d8ca3.zip
gen_vimdoc.py: support <pre> preformatted text [ci skip]
Diffstat (limited to 'scripts/gen_vimdoc.py')
-rwxr-xr-xscripts/gen_vimdoc.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py
index 3449cf68e5..cdcab817ad 100755
--- a/scripts/gen_vimdoc.py
+++ b/scripts/gen_vimdoc.py
@@ -139,7 +139,7 @@ def is_blank(text):
return '' == clean_lines(text)
-def get_text(parent):
+def get_text(parent, preformatted=False):
"""Combine all text in a node."""
if parent.nodeType == parent.TEXT_NODE:
return parent.data
@@ -147,9 +147,9 @@ def get_text(parent):
out = ''
for node in parent.childNodes:
if node.nodeType == node.TEXT_NODE:
- out += clean_text(node.data)
+ out += node.data if preformatted else clean_text(node.data)
elif node.nodeType == node.ELEMENT_NODE:
- out += ' ' + get_text(node)
+ out += ' ' + get_text(node, preformatted)
return out
@@ -271,6 +271,10 @@ def render_node(n, text, prefix='', indent='', width=62):
text += doc_wrap(n.data, indent=indent, width=width)
elif n.nodeName == 'computeroutput':
text += ' `{}` '.format(get_text(n))
+ elif n.nodeName == 'preformatted':
+ o = get_text(n, preformatted=True)
+ ensure_nl = '' if o[-1] == '\n' else '\n'
+ text += ' >{}{}\n<'.format(ensure_nl, o)
elif is_inline(n):
for c in n.childNodes:
text += render_node(c, text)