Skip to content

Commit 6ae7f40

Browse files
committed
Add --force-link-text to md-convert.
1 parent 0f599d3 commit 6ae7f40

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

maybe-make-man

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ fi
88
inname="$1"
99
srcdir=`dirname "$0"`
1010
flagfile="$srcdir/.md2man-works"
11+
force_flagfile="$srcdir/.md2man-force"
1112

1213
if [ ! -f "$flagfile" ]; then
1314
# We test our smallest manpage just to see if the python setup works.
@@ -32,4 +33,10 @@ if [ ! -f "$flagfile" ]; then
3233
fi
3334
fi
3435

35-
"$srcdir/md-convert" "$srcdir/$inname"
36+
if [ -f "$force_flagfile" ]; then
37+
opt='--force-link-text'
38+
else
39+
opt=''
40+
fi
41+
42+
"$srcdir/md-convert" $opt "$srcdir/$inname"

md-convert

+2-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ class TransformHtml(HTMLParser):
494494
elif tag == 'a':
495495
if st.a_href_external:
496496
st.txt = st.txt.strip()
497-
if st.a_href != st.txt:
497+
if args.force_link_text or st.a_href != st.txt:
498498
st.man_out.append(manify(st.txt) + "\n")
499499
st.man_out.append(".UE\n") # This might get replaced with a punctuation version in handle_UE()
500500
st.after_a_tag = True
@@ -639,6 +639,7 @@ if __name__ == '__main__':
639639
parser = argparse.ArgumentParser(description="Convert markdown into html and (optionally) nroff. Each input filename must have a .md suffix, which is changed to .html for the output filename. If the input filename ends with .num.md (e.g. foo.1.md) then a nroff file is also output with the input filename's .md suffix removed (e.g. foo.1).", add_help=False)
640640
parser.add_argument('--test', action='store_true', help="Just test the parsing without outputting any files.")
641641
parser.add_argument('--dest', metavar='DIR', help="Create files in DIR instead of the current directory.")
642+
parser.add_argument('--force-link-text', action='store_true', help="Don't remove the link text if it matches the link href. Useful when nroff doesn't understand .UR and .UE.")
642643
parser.add_argument('--debug', '-D', action='count', default=0, help='Output copious info on the html parsing. Repeat for even more.')
643644
parser.add_argument("--help", "-h", action="help", help="Output this help message and exit.")
644645
parser.add_argument("mdfiles", metavar='FILE.md', nargs='+', help="One or more .md files to convert.")

0 commit comments

Comments
 (0)