From: Wayne Davison Date: Sun, 23 Apr 2023 15:26:32 +0000 (-0700) Subject: Add --force-link-text to md-convert. X-Git-Tag: v3.3.0pre1~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6ae7f4085a5012038c29ae1c70f626cae7714b69;p=thirdparty%2Frsync.git Add --force-link-text to md-convert. --- diff --git a/maybe-make-man b/maybe-make-man index 0dc173059..c7af73934 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 2cd9a72b6..5fd63a76d 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.")