summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWayne Davison <wayne@opencoder.net>2025-01-15 22:19:33 -0800
committerWayne Davison <wayne@opencoder.net>2025-01-15 22:23:30 -0800
commit353506bc51a87e8df2ea12289786689ff9d44d14 (patch)
treeff51832af7efe32b763f37587db62f2bbd3fe9c2
parent7cff121ec8e198d7e27aa87410a17521c48a02e7 (diff)
Improve interior dashes in long options.
Improve the backslash-adding code in md-convert to affect dashes in the interior of long options. Perhaps fixes #686.
-rwxr-xr-xmd-convert2
1 files changed, 2 insertions, 0 deletions
diff --git a/md-convert b/md-convert
index 5fd63a76..fb2bc993 100755
--- a/md-convert
+++ b/md-convert
@@ -120,6 +120,7 @@ TZ_RE = re.compile(r'^#define\s+MAINTAINER_TZ_OFFSET\s+(-?\d+(\.\d+)?)', re.M)
VAR_REF_RE = re.compile(r'\$\{(\w+)\}')
VERSION_RE = re.compile(r' (\d[.\d]+)[, ]')
BIN_CHARS_RE = re.compile(r'[\1-\7]+')
+LONG_OPT_DASH_RE = re.compile(r'(--\w[-\w]+)')
SPACE_DOUBLE_DASH_RE = re.compile(r'\s--(\s)')
NON_SPACE_SINGLE_DASH_RE = re.compile(r'(^|\W)-')
WHITESPACE_RE = re.compile(r'\s')
@@ -540,6 +541,7 @@ class TransformHtml(HTMLParser):
if st.in_pre:
html = htmlify(txt)
else:
+ txt = LONG_OPT_DASH_RE.sub(lambda x: x.group(1).replace('-', 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)