The branch, master has been updated via 7e94e521 Some NEWS.html improvements. via 5ef7e3c9 Remove `<a name=...>` tags. from d2cc1149 Get md-convert to output the release html files in the right dir.
https://git.samba.org/?p=rsync.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 7e94e5214485418f8ee4e2cc15a6aba37ddd6893 Author: Wayne Davison <wa...@opencoder.net> Date: Sat Jan 15 20:56:22 2022 -0800 Some NEWS.html improvements. - Improve NEWS heading's link targets using version info. - Optimize regex compilation. - Make sure every link target is unique. - Allow link targets to start with a number. commit 5ef7e3c9c511118cc486a88d84f5d8dd5baaf12e Author: Wayne Davison <wa...@opencoder.net> Date: Sat Jan 15 20:55:54 2022 -0800 Remove `<a name=...>` tags. ----------------------------------------------------------------------- Summary of changes: NEWS.md | 37 ------------------------------- md-convert | 74 +++++++++++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 54 insertions(+), 57 deletions(-) Changeset truncated at 500 lines: diff --git a/NEWS.md b/NEWS.md index 959e1da7..a019a2a5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,3 @@ -<a name="3.2.4"></a> # NEWS for rsync 3.2.4 (UNRELEASED) @@ -214,7 +213,6 @@ ------------------------------------------------------------------------------ -<a name="3.2.3"></a> # NEWS for rsync 3.2.3 (6 Aug 2020) @@ -315,7 +313,6 @@ (with a fallback to the old 1-char string kluge for older compilers). ------------------------------------------------------------------------------ -<a name="3.2.2"></a> # NEWS for rsync 3.2.2 (4 Jul 2020) @@ -391,7 +388,6 @@ can create the interrelated structs and accessors that loadparm.c needs. ------------------------------------------------------------------------------ -<a name="3.2.1"></a> # NEWS for rsync 3.2.1 (22 Jun 2020) @@ -454,7 +450,6 @@ - Merged the OLDNEWS.md file into NEWS.md. ------------------------------------------------------------------------------ -<a name="3.2.0"></a> # NEWS for rsync 3.2.0 (19 Jun 2020) @@ -666,7 +661,6 @@ - Some code typos were fixed (as pointed out by a Fossies run). ------------------------------------------------------------------------------ -<a name="3.1.3"></a> # NEWS for rsync 3.1.3 (28 Jan 2018) @@ -737,7 +731,6 @@ - Support newer yodl versions when converting man pages. ------------------------------------------------------------------------------ -<a name="3.1.2"></a> # NEWS for rsync 3.1.2 (21 Dec 2015) @@ -803,7 +796,6 @@ - Improved the m4 generation rules and some autoconf idioms. ------------------------------------------------------------------------------ -<a name="3.1.1"></a> # NEWS for rsync 3.1.1 (22 Jun 2014) @@ -923,7 +915,6 @@ and/or zlib code is put early in the CFLAGS. ------------------------------------------------------------------------------ -<a name="3.1.0"></a> # NEWS for rsync 3.1.0 (28 Sep 2013) @@ -1174,7 +1165,6 @@ - Fixed some build issues for Android and Minix. ------------------------------------------------------------------------------ -<a name="3.0.9"></a> # NEWS for rsync 3.0.9 (23 Sep 2011) @@ -1234,7 +1224,6 @@ - Some minor manpage improvements. ------------------------------------------------------------------------------ -<a name="3.0.8"></a> # NEWS for rsync 3.0.8 (26 Mar 2011) @@ -1373,7 +1362,6 @@ - Fixed the testsuite/xattrs.test script on OS X. ------------------------------------------------------------------------------ -<a name="3.0.7"></a> # NEWS for rsync 3.0.7 (31 Dec 2009) @@ -1441,7 +1429,6 @@ - The testsuite no longer uses `id -u`, so it works better on Solaris. ------------------------------------------------------------------------------ -<a name="3.0.6"></a> # NEWS for rsync 3.0.6 (8 May 2009) @@ -1500,7 +1487,6 @@ - Fixed an failure transferring special files from Solaris to Linux. ------------------------------------------------------------------------------ -<a name="3.0.5"></a> # NEWS for rsync 3.0.5 (28 Dec 2008) @@ -1565,7 +1551,6 @@ idiom. (See the support dir.) ------------------------------------------------------------------------------ -<a name="3.0.4"></a> # NEWS for rsync 3.0.4 (6 Sep 2008) @@ -1633,7 +1618,6 @@ even more consistency checks on the files. ------------------------------------------------------------------------------ -<a name="3.0.3"></a> # NEWS for rsync 3.0.3 (29 Jun 2008) @@ -1724,7 +1708,6 @@ bleed-over into patches that follow. ------------------------------------------------------------------------------ -<a name="3.0.2"></a> # NEWS for rsync 3.0.2 (8 Apr 2008) @@ -1746,7 +1729,6 @@ packaging dir. ------------------------------------------------------------------------------ -<a name="3.0.1"></a> # NEWS for rsync 3.0.1 (3 Apr 2008) @@ -1885,7 +1867,6 @@ - Updated the build scripts to work with a revised FTP directory structure. ------------------------------------------------------------------------------ -<a name="3.0.0"></a> # NEWS for rsync 3.0.0 (1 Mar 2008) @@ -2236,7 +2217,6 @@ the 3.0.0 release. ------------------------------------------------------------------------------ -<a name="2.6.9"></a> # NEWS for rsync 2.6.9 (6 Nov 2006) @@ -2396,7 +2376,6 @@ consistent opening comments. ------------------------------------------------------------------------------ -<a name="2.6.8"></a> # NEWS for rsync 2.6.8 (22 Apr 2006) @@ -2466,7 +2445,6 @@ actions to a file (something that only a daemon supports at present). ------------------------------------------------------------------------------ -<a name="2.6.7"></a> # NEWS for rsync 2.6.7 (11 Mar 2006) @@ -2790,7 +2768,6 @@ ~/.popt. ------------------------------------------------------------------------------ -<a name="2.6.6"></a> # NEWS for rsync 2.6.6 (28 Jul 2005) @@ -2856,7 +2833,6 @@ (log-format w/%i) and some double-verbose messages. ------------------------------------------------------------------------------ -<a name="2.6.5"></a> # NEWS for rsync 2.6.5 (1 Jun 2005) @@ -3037,7 +3013,6 @@ enables the optional copying of extended attributes. ------------------------------------------------------------------------------ -<a name="2.6.4"></a> # NEWS for rsync 2.6.4 (30 March 2005) @@ -3419,7 +3394,6 @@ - Improved configure to better handle cross-compiling. ------------------------------------------------------------------------------ -<a name="2.6.3"></a> # NEWS for rsync 2.6.3 (30 Sep 2004) @@ -3663,7 +3637,6 @@ removed. ------------------------------------------------------------------------------ -<a name="2.6.2"></a> # NEWS for rsync 2.6.2 (30 Apr 2004) @@ -3705,7 +3678,6 @@ - Two new diffs were added to the patches dir. ------------------------------------------------------------------------------ -<a name="2.6.1"></a> # NEWS for rsync 2.6.1 (26 Apr 2004) @@ -3897,7 +3869,6 @@ applied, and rebuilt the rest. ------------------------------------------------------------------------------ -<a name="2.6.0"></a> # NEWS for rsync 2.6.0 (1 Jan 2004) @@ -4037,7 +4008,6 @@ other side (primarily for testing purposes). (Wayne Davison) ------------------------------------------------------------------------------ -<a name="2.5.7"></a> # NEWS for rsync 2.5.7 (4 Dec 2003) @@ -4049,7 +4019,6 @@ Andrea Barisani) ------------------------------------------------------------------------------ -<a name="2.5.6"></a> # NEWS for rsync 2.5.6, aka "the dwd-between-jobs release" (26 Jan 2003) @@ -4144,7 +4113,6 @@ should build on more platforms. (Paul Green) ------------------------------------------------------------------------------ -<a name="2.5.5"></a> # NEWS for rsync 2.5.5, aka Snowy River (2 Apr 2002) @@ -4183,7 +4151,6 @@ - Improved network error handling. (Greg A. Woods) ------------------------------------------------------------------------------ -<a name="2.5.4"></a> # NEWS for rsync 2.5.4, aka "Imitation lizard skin" (13 Mar 2002) @@ -4203,7 +4170,6 @@ - Additional test cases for `--compress`. (Martin Pool) ------------------------------------------------------------------------------ -<a name="2.5.3"></a> # NEWS for rsync 2.5.3, aka "Happy 26" (11 Mar 2002) @@ -4252,7 +4218,6 @@ error message. (Colin Walters) ------------------------------------------------------------------------------ -<a name="2.5.2"></a> # NEWS for rsync 2.5.2 (26 Jan 2002) @@ -4301,7 +4266,6 @@ Razor. (Debian #124286) ------------------------------------------------------------------------------ -<a name="2.5.1"></a> # NEWS for rsync 2.5.1 (3 Jan 2002) @@ -4336,7 +4300,6 @@ - Clearer error messages for some conditions. ------------------------------------------------------------------------------ -<a name="2.5.0"></a> # NEWS for rsync 2.5.0 (30 Nov 2001) diff --git a/md-convert b/md-convert index 900fef16..597aa908 100755 --- a/md-convert +++ b/md-convert @@ -111,6 +111,21 @@ UNDR_FONT = ('\3', r"\fI") NBR_DASH = ('\4', r"\-") NBR_SPACE = ('\xa0', r"\ ") +FILENAME_RE = re.compile(r'^(?P<fn>(?P<srcdir>.+/)?(?P<name>(?P<prog>[^/]+?)(\.(?P<sect>\d+))?)\.md)$') +ASSIGNMENT_RE = re.compile(r'^(\w+)=(.+)') +QUOTED_RE = re.compile(r'"(.+?)"') +VAR_REF_RE = re.compile(r'\$\{(\w+)\}') +VERSION_RE = re.compile(r' (\d[.\d]+)[, ]') +BIN_CHARS_RE = re.compile(r'[\1-\7]+') +SPACE_DOUBLE_DASH_RE = re.compile(r'\s--(\s)') +NON_SPACE_SINGLE_DASH_RE = re.compile(r'(^|\W)-') +WHITESPACE_RE = re.compile(r'\s') +CODE_BLOCK_RE = re.compile(r'[%s](.+?)[=%s].*' % (BOLD_FONT[0], NORM_FONT[0])) +NBR_DASH_RE = re.compile(r'[%s]' % NBR_DASH[0]) +INVALID_TARGET_CHARS_RE = re.compile(r'[^-A-Za-z0-9._]') +INVALID_START_CHAR_RE = re.compile(r'^([^A-Za-z0-9])') +MANIFY_LINESTART_RE = re.compile(r"^(['.])", flags=re.M) + md_parser = None env_subs = { } @@ -125,7 +140,7 @@ def main(): def parse_md_file(mdfn): - fi = re.match(r'^(?P<fn>(?P<srcdir>.+/)?(?P<name>(?P<prog>[^/]+?)(\.(?P<sect>\d+))?)\.md)$', mdfn) + fi = FILENAME_RE.match(mdfn) if not fi: die('Failed to parse a md input file name:', mdfn) fi = argparse.Namespace(**fi.groupdict()) @@ -207,19 +222,19 @@ def find_man_substitutions(): with open(srcdir + 'version.h', 'r', encoding='utf-8') as fh: txt = fh.read() - m = re.search(r'"(.+?)"', txt) + m = QUOTED_RE.search(txt) env_subs['VERSION'] = m.group(1) with open('Makefile', 'r', encoding='utf-8') as fh: for line in fh: - m = re.match(r'^(\w+)=(.+)', line) + m = ASSIGNMENT_RE.match(line) if not m: continue var, val = (m.group(1), m.group(2)) if var == 'prefix' and env_subs[var] is not None: continue - while re.search(r'\$\{', val): - val = re.sub(r'\$\{(\w+)\}', lambda m: env_subs[m.group(1)], val) + while VAR_REF_RE.search(val): + val = VAR_REF_RE.sub(lambda m: env_subs[m.group(1)], val) env_subs[var] = val if var == 'srcdir': break @@ -256,6 +271,7 @@ class TransformHtml(HTMLParser): prior_target = None, opt_prefix = 'opt', a_txt_start = None, + target_suf = '', ) if st.want_manpage: @@ -281,7 +297,7 @@ class TransformHtml(HTMLParser): for href, txt in st.derived_hashtags: derived = txt2target(txt, href[1:]) if derived not in st.created_hashtags: - txt = re.sub(r'[\1-\7]+', '', txt.replace(NBR_DASH[0], '-').replace(NBR_SPACE[0], ' ')) + txt = BIN_CHARS_RE.sub('', txt.replace(NBR_DASH[0], '-').replace(NBR_SPACE[0], ' ')) warn('Unknown derived hashtag link in', self.fn, 'based on:', (href, txt)) for bad in st.bad_hashtags: @@ -387,13 +403,22 @@ class TransformHtml(HTMLParser): else: txt = None add_to_txt = None - if tag == 'h1' or tag == 'h2': + if tag == 'h1': + tgt = txt + target_suf = '' + if tgt.startswith('NEWS for '): + m = VERSION_RE.search(tgt) + if m: + tgt = m.group(1) + st.target_suf = '-' + tgt + self.add_target(tgt) + elif tag == 'h2': st.man_out.append(st.p_macro + '.SH "' + manify(txt) + '"\n') - self.add_target(txt) + self.add_target(txt, st.target_suf) st.opt_prefix = 'daemon-opt' if txt == 'DAEMON OPTIONS' else 'opt' elif tag == 'h3': st.man_out.append(st.p_macro + '.SS "' + manify(txt) + '"\n') - self.add_target(txt) + self.add_target(txt, st.target_suf) elif tag == 'p': if st.dt_from == 'p': tag = 'dt' @@ -474,20 +499,29 @@ class TransformHtml(HTMLParser): if st.in_pre: html = htmlify(txt) else: - txt = re.sub(r'\s--(\s)', NBR_SPACE[0] + r'--\1', txt).replace('--', NBR_DASH[0]*2) - txt = re.sub(r'(^|\W)-', r'\1' + NBR_DASH[0], txt) + txt = SPACE_DOUBLE_DASH_RE.sub(NBR_SPACE[0] + r'--\1', txt).replace('--', NBR_DASH[0]*2) + txt = NON_SPACE_SINGLE_DASH_RE.sub(r'\1' + NBR_DASH[0], txt) html = htmlify(txt) if st.in_code: - txt = re.sub(r'\s', NBR_SPACE[0], txt) + txt = WHITESPACE_RE.sub(NBR_SPACE[0], txt) html = html.replace(NBR_DASH[0], '-').replace(NBR_SPACE[0], ' ') # <code> is non-breaking in CSS st.html_out.append(html.replace(NBR_SPACE[0], ' ').replace(NBR_DASH[0], '-⁠')) st.txt += txt - def add_target(self, txt): + def add_target(self, txt, suf=None): st = self.state txt = txt2target(txt, st.opt_prefix) if txt: + if suf: + txt += suf + if txt in st.created_hashtags: + for j in range(2, 1000): + chk = txt + '-' + str(j) + if chk not in st.created_hashtags: + print('Made link target unique:', chk) + txt = chk + break st.html_out.append('<a id="' + txt + '" href="#' + txt + '" class="tgt"></a>') st.created_hashtags.add(txt) st.prior_target = txt @@ -507,24 +541,24 @@ class TransformHtml(HTMLParser): def txt2target(txt, opt_prefix): - 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) + txt = CODE_BLOCK_RE.sub(r'\1', txt.strip().rstrip(':')) + txt = NBR_DASH_RE.sub('-', txt) + txt = BIN_CHARS_RE.sub('', txt) + txt = INVALID_TARGET_CHARS_RE.sub('_', txt) if opt_prefix and txt.startswith('-'): txt = opt_prefix + txt else: - txt = re.sub(r'^([^A-Za-z])', r't\1', txt) + txt = INVALID_START_CHAR_RE.sub(r't\1', txt) return txt def manify(txt): - return re.sub(r"^(['.])", r'\&\1', txt.replace('\\', '\\\\') + return MANIFY_LINESTART_RE.sub(r'\&\1', txt.replace('\\', '\\\\') .replace(NBR_SPACE[0], NBR_SPACE[1]) .replace(NBR_DASH[0], NBR_DASH[1]) .replace(NORM_FONT[0], NORM_FONT[1]) .replace(BOLD_FONT[0], BOLD_FONT[1]) - .replace(UNDR_FONT[0], UNDR_FONT[1]), flags=re.M) + .replace(UNDR_FONT[0], UNDR_FONT[1])) def htmlify(txt): -- The rsync repository. _______________________________________________ rsync-cvs mailing list rsync-cvs@lists.samba.org https://lists.samba.org/mailman/listinfo/rsync-cvs