Documentation: Fix some markdown formatting bugs.

This commit is contained in:
Avery Pennarun 2018-10-11 05:16:27 -04:00
commit 84fb972fb7
6 changed files with 23 additions and 18 deletions

View file

@ -1,2 +1,3 @@
*.1
/md-to-man
*.html

View file

@ -1,2 +1 @@
rm -f *~ .*~ *.1 t/*.1 md-to-man *.tmp t/*.tmp
rm -f *~ .*~ *.1 t/*.1 md-to-man *.tmp t/*.tmp *.html */*.html

View file

@ -1,6 +1,6 @@
redo-ifchange md2man.py
if ./md2man.py </dev/null >/dev/null; then
echo './md2man.py $2.md.tmp'
if ./md2man.py /dev/null /dev/null >/dev/null; then
echo './md2man.py $2.md.tmp $2.html'
else
echo "Warning: md2man.py missing modules; can't generate manpages." >&2
echo "Warning: try this: sudo easy_install markdown BeautifulSoup" >&2

View file

@ -132,7 +132,7 @@ def _text(bitlist):
elif typ in ['strong', 'code']:
out += '\\fB%s\\fR' % text
else:
raise ValueError('unexpected tag %r inside %r' % (typ, tag.name))
raise ValueError('unexpected tag %r inside text' % (typ,))
out = out.strip()
out = re.sub(re.compile(r'^\s+', re.M), '', out)
return out
@ -175,6 +175,7 @@ def do_definition(tag):
pre.append((typ,text))
_boldline(pre)
w.write(_text(post))
w.started = False
def do_list(tag):
@ -187,6 +188,7 @@ def do_list(tag):
else:
w.start_bullet()
for xi in i:
if str(xi).strip():
do(xi)
w.end_para()
w.end_bullet()
@ -215,7 +217,7 @@ def do(tag):
macro('.RE')
w.end_para()
elif name == 'p' or name == 'br':
g = re.match(re.compile(r'([^\n]*)\n +: +(.*)', re.S), str(tag))
g = re.match(re.compile(r'([^\n]*)\n *: +(.*)', re.S), str(tag))
if g:
# it's a definition list (which some versions of python-markdown
# don't support, including the one in Debian-lenny, so we can't
@ -238,11 +240,13 @@ DATE=''
AUTHOR=''
lines = []
if len(sys.argv) > 1:
for n in sys.argv[1:]:
lines += open(n).read().decode('utf8').split('\n')
else:
lines += sys.stdin.read().decode('utf8').split('\n')
if len(sys.argv) != 3:
sys.stderr.write('usage: %s <infile.md> <outfile.html> >outfile.1\n')
sys.exit(99)
infile = sys.argv[1]
htmlfile = sys.argv[2]
lines += open(infile).read().decode('utf8').split('\n')
# parse pandoc-style document headers (not part of markdown)
g = re.match(r'^%\s+(.*?)\((.*?)\)\s+(.*)$', lines[0])
@ -266,9 +270,10 @@ if g:
inp = '\n'.join(lines)
if AUTHOR:
inp += ('\n# AUTHOR\n\n%s\n' % AUTHOR).replace('<', '\\<')
inp += ('\n# AUTHOR\n\n%s\n' % AUTHOR).replace('<', '&lt;')
html = markdown.markdown(inp)
open(htmlfile, 'w').write(html)
soup = BeautifulSoup(html, convertEntities=BeautifulSoup.HTML_ENTITIES)
macro('.TH', PROD.upper(), SECTION, DATE, VENDOR, GROUPNAME)

View file

@ -33,8 +33,8 @@ The list is not filtered in any way; it contains *all* the
target filenames from the entire project. Remember that
the redo database may span more than just your project, so
you might need to filter the list before using it. (A
useful heuristic might be to remove any line starting with
'../' since it often refers to a target you don't care
useful heuristic might be to remove any line starting
with '../' since it often refers to a target you don't care
about.)
If you want a list of all targets, not just out-of-date

View file

@ -8,7 +8,7 @@ redo-stamp - detect if the current target has meaningfully changed
# SYNOPSIS
redo-stamp <\$3
redo-stamp <$3
# DESCRIPTION
@ -33,7 +33,7 @@ are:
- the actual target file contents:
redo-stamp <\$3
redo-stamp <$3
- a list of filenames: