]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Add --force-link-text to md-convert.
authorWayne Davison <wayne@opencoder.net>
Sun, 23 Apr 2023 15:26:32 +0000 (08:26 -0700)
committerWayne Davison <wayne@opencoder.net>
Sun, 23 Apr 2023 15:26:32 +0000 (08:26 -0700)
maybe-make-man
md-convert

index 0dc173059bb31008e6670ce06cce7602e81e9740..c7af73934a775ed0f983f988697a16c81e9cfea6 100755 (executable)
@@ -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"
index 2cd9a72b6d2fe57a53dbed63469eba92b7c07ff6..5fd63a76d494eec72dca9f79a0bebc70a8fcf7b0 100755 (executable)
@@ -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.")