aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-01-16 12:24:48 -0800
committerKaz Kylheku <kaz@kylheku.com>2025-01-16 12:24:48 -0800
commit7e4cec049ba8fcd5f8d329dbbd3c97f872c14089 (patch)
tree4a59aa741fc8e28aea580e355074e6d82967f9c4
parent8f16311831fee57605105813420115b7dd61d2f3 (diff)
downloadmnpgr-7e4cec049ba8fcd5f8d329dbbd3c97f872c14089.tar.gz
mnpgr-7e4cec049ba8fcd5f8d329dbbd3c97f872c14089.tar.bz2
mnpgr-7e4cec049ba8fcd5f8d329dbbd3c97f872c14089.zip
Map dash-like unicode characters to ASCII dash.k
- Look for the following characters in the input: - U+2010 (Hyphen), - U+2013 (En Dash) - U+2014 (Em Dash) - U+2212 (Minus) and convert them to: - U+002D (ASCII Hyphen-Minus) - This is not just for appearance. I use an old version of Screen which somehow reacts badly to the U+2010 hyphen; the terminal becomes seriously corrupt, making the portions of a man page adjacent to hyphenated lines unreadable.
-rw-r--r--README.md5
-rwxr-xr-xmnpgr.tl5
2 files changed, 8 insertions, 2 deletions
diff --git a/README.md b/README.md
index 47b8a24..b2184c2 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,11 @@ syntax coloring, like what you see `less`.
Because `mngpr` itself resolves the overstrikes, the resulting rendering
in Vim is searchable.
+Another benefit of `mnpgr` is that it replaces with a plain ASCII dash
+(U+002D) all the nonsense Unicode dashes output by GNU groff.
+This is not just esthetics. In some systems, the U+2010 hyphen
+seriously corrupts the terminal display, rendering man pages unreadable.
+
## Installation
The `mnpgr.vim` file goes into your `~/.vim/syntax` directory, which
diff --git a/mnpgr.tl b/mnpgr.tl
index 46619c9..3256815 100755
--- a/mnpgr.tl
+++ b/mnpgr.tl
@@ -97,7 +97,8 @@
(with-resources ((rendered-file (path-cat mnpgr-dir `@page.@section.@cols`)
(remove-path rendered-file)))
(with-stream (s (open-file rendered-file "w"))
- (let ((ofilt (make-overstrike-filter (lambda (str) (put-string str s)))))
+ (let ((hfilt (op regsub #/[\x2010\x2013\x2014\x2212]/ "-"))
+ (ofilt (make-overstrike-filter (lambda (str) (put-string str s)))))
(whilet ((line (get-line)))
- [ofilt line])))
+ (flow line hfilt ofilt))))
(sh `vim +'@{vim-commands}' '@{rendered-file}' < /dev/tty`))))