summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWayne Davison <wayne@opencoder.net>2023-04-23 08:26:32 -0700
committerWayne Davison <wayne@opencoder.net>2023-04-23 08:26:32 -0700
commit6ae7f4085a5012038c29ae1c70f626cae7714b69 (patch)
treee571a2d8755fb64923ed48ec3aaf87b910123ba1
parent0f599d3641bd197ff01f5182fad33169aa46a055 (diff)
downloadrsync-6ae7f4085a5012038c29ae1c70f626cae7714b69.tar.gz
Add --force-link-text to md-convert.
-rwxr-xr-xmaybe-make-man9
-rwxr-xr-xmd-convert3
2 files changed, 10 insertions, 2 deletions
diff --git a/maybe-make-man b/maybe-make-man
index 0dc17305..c7af7393 100755
--- a/maybe-make-man
+++ b/maybe-make-man
@@ -8,6 +8,7 @@ fi
inname="$1"
srcdir=`dirname "$0"`
flagfile="$srcdir/.md2man-works"
+force_flagfile="$srcdir/.md2man-force"
if [ ! -f "$flagfile" ]; then
# We test our smallest manpage just to see if the python setup works.
@@ -32,4 +33,10 @@ if [ ! -f "$flagfile" ]; then
fi
fi
-"$srcdir/md-convert" "$srcdir/$inname"
+if [ -f "$force_flagfile" ]; then
+ opt='--force-link-text'
+else
+ opt=''
+fi
+
+"$srcdir/md-convert" $opt "$srcdir/$inname"
diff --git a/md-convert b/md-convert
index 2cd9a72b..5fd63a76 100755
--- a/md-convert
+++ b/md-convert
@@ -494,7 +494,7 @@ class TransformHtml(HTMLParser):
elif tag == 'a':
if st.a_href_external:
st.txt = st.txt.strip()
- if st.a_href != st.txt:
+ if args.force_link_text or st.a_href != st.txt:
st.man_out.append(manify(st.txt) + "\n")
st.man_out.append(".UE\n") # This might get replaced with a punctuation version in handle_UE()
st.after_a_tag = True
@@ -639,6 +639,7 @@ if __name__ == '__main__':
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)
parser.add_argument('--test', action='store_true', help="Just test the parsing without outputting any files.")
parser.add_argument('--dest', metavar='DIR', help="Create files in DIR instead of the current directory.")
+ 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.")
parser.add_argument('--debug', '-D', action='count', default=0, help='Output copious info on the html parsing. Repeat for even more.')
parser.add_argument("--help", "-h", action="help", help="Output this help message and exit.")
parser.add_argument("mdfiles", metavar='FILE.md', nargs='+', help="One or more .md files to convert.")