Subject: [PATCH scdoc v2] Emit \(ti and \(ha instead of ~ and ^

From: Kirill Chibisov <~sircmpwn/[email-masked]>
Date: Tue, 6 Aug 2024 19:58:54 +0300

Groff since 1.23 maps '^' and '~' by default to U+02C6 and U+02DC
respectively.

The suggestion in groff_man_style(7) is to use \(ti and \(ha when the
latin variants are desired.

Links: https://lists.gnu.org/archive/html/info-gnu/2023-07/msg00001.html
---
Haven't noticed that there's a test framework.
 src/main.c                |  8 ++++++++
 test/character-substitute | 18 ++++++++++++++++++
 2 files changed, 26 insertions(+)
 create mode 100755 test/character-substitute

diff --git a/src/main.c b/src/main.c
index a49cb40..92dc991 100644
--- a/src/main.c
+++ b/src/main.c
@@ -261,6 +261,14 @@ static void parse_text(struct parser *p) {
 			// Suppress sentence spacing
 			fprintf(p->output, "\\&");
 			break;
+		case '~':
+			// Escape tilda to not render it with U+02DC
+			fprintf(p->output, "\\(ti");
+			break;
+		case '^':
+			// Escape caret to not render it with U+02C6
+			fprintf(p->output, "\\(ha");
+			break;
 		default:
 			last = ch;
 			utf8_fputch(p->output, ch);
diff --git a/test/character-substitute b/test/character-substitute
new file mode 100755
index 0000000..6fe5589
--- /dev/null
+++ b/test/character-substitute
@@ -0,0 +1,18 @@
+#!/bin/sh
+. test/lib.sh
+
+begin "Substitute ~ with \(ti"
+scdoc <<EOF | grep '\\fIhello\\(ti\\fR' >/dev/null
+test(8)
+
+_hello~_
+EOF
+end 0
+
+begin "Substitute ^ with \(ha"
+scdoc <<EOF | grep '\\fIhello\\(ha\\fR' >/dev/null
+test(8)
+
+_hello^_
+EOF
+end 0
-- 
2.44.2

---

From: "builds.sr.ht" <~sircmpwn/[email-masked]>
Date: Tue, 06 Aug 2024 16:59:45 +0000

scdoc/patches/.build.yml: SUCCESS in 13s

[Emit \(ti and \(ha instead of ~ and ^][0] v2 from [Kirill Chibisov][1]

[0]: https://lists.sr.ht/~sircmpwn/public-inbox/patches/54317
[1]: mailto:[email-masked]

✓ #1295127 SUCCESS scdoc/patches/.build.yml https://builds.sr.ht/~sircmpwn/job/1295127