From: Wayne Davison Date: Fri, 14 Jan 2022 07:39:40 +0000 (-0800) Subject: Add more link targets to html man pages. X-Git-Tag: v3.2.4pre2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f08505e92ba385e3af1be9138916269a58c057e7;p=thirdparty%2Frsync.git Add more link targets to html man pages. --- diff --git a/md-convert b/md-convert index d1266f45..3b66a059 100755 --- a/md-convert +++ b/md-convert @@ -332,10 +332,18 @@ class TransformHtml(HTMLParser): st.at_first_tag_in_dd = False - def add_anchor(self, txt): + def add_target(self, txt): st = self.state - txt = txt.lower().replace(' ', '-') - st.html_out.append('') + txt = re.sub(r'[%s](.+?)[=%s].*' % (BOLD_FONT[0], NORM_FONT[0]), r'\1', txt.strip()) + txt = re.sub(r'[%s]' % NBR_DASH[0], '-', txt) + txt = re.sub(r'[\1-\7]+', '', txt) + txt = re.sub(r'[^-A-Za-z0-9._]', '_', txt) + if txt.startswith('-'): + txt = 'opt' + txt + else: + txt = re.sub(r'^([^A-Za-z])', r't\1', txt) + if txt: + st.html_out.append('') def handle_endtag(self, tag): @@ -350,14 +358,16 @@ class TransformHtml(HTMLParser): add_to_txt = None if tag == 'h1' or tag == 'h2': st.man_out.append(st.p_macro + '.SH "' + manify(txt) + '"\n') - self.add_anchor(txt) + self.add_target(txt) elif tag == 'h3': st.man_out.append(st.p_macro + '.SS "' + manify(txt) + '"\n') - self.add_anchor(txt) + self.add_target(txt) elif tag == 'p': if st.dt_from == 'p': tag = 'dt' st.man_out.append('.IP "' + manify(txt) + '"\n') + if txt.startswith(BOLD_FONT[0]): + self.add_target(txt) st.dt_from = None elif txt != '': st.man_out.append(manify(txt) + "\n")