texinfo: Properly render @acronym in plain text.
authorLudovic Courtès <ludo@gnu.org>
Wed, 29 Jan 2020 14:16:38 +0000 (15:16 +0100)
committerLudovic Courtès <ludo@gnu.org>
Wed, 29 Jan 2020 14:19:37 +0000 (15:19 +0100)
Fixes <https://bugs.gnu.org/37846>.
Reported by Christopher Baines <mail@cbaines.net>.

* module/texinfo/plain-text.scm (acronym): New procedure.
(tag-handlers): Change 'acro' handle to ACRONYM, and add 'acronym'
handler.
* test-suite/tests/texinfo.plain-text.test ("stexi->plain-text")
["acronym", "recursive acronym"]: New tests.

module/texinfo/plain-text.scm
test-suite/tests/texinfo.plain-text.test

index 6b7885ada92f469635fc64e8592f6aecb0bcfb57..5ea99c86bcbaf78536a1e1f657a8f0b7a5331b14 100644 (file)
 (define (var tag . body)
   (string-upcase (stexi->plain-text body)))
 
+(define (acronym tag . elts)
+  (match elts
+    ((('% ('acronym text)))
+     (stexi->plain-text text))
+    ((('% ('acronym text) ('meaning . body)))
+     (string-append (stexi->plain-text text)
+                    " ("
+                    (string-concatenate (map stexi->plain-text body))
+                    ")"))))
+
 (define (passthrough tag . body)
   (stexi->plain-text body))
 
     (url          ,code)
     (dfn          ,(make-surrounder "\""))
     (cite         ,(make-surrounder "\""))
-    (acro         ,passthrough)
+    (acro         ,acronym)                       ;XXX: useless?
+    (acronym      ,acronym)
     (email        ,key)
     (emph         ,(make-surrounder "_"))
     (sc           ,var)
index 565da8c7d368c30daa15aa84d5754d741ddd1e1d..4315cdbb1933a869323b428a9c7bb70153ecd15f 100644 (file)
       "This is another sentence.\nThat too.\n\n"
     (with-fluids ((*line-width* 26))
       (stexi->plain-text
-       '(*fragment* (para "This is another sentence. That too."))))))
+       '(*fragment* (para "This is another sentence. That too.")))))
+
+  (pass-if-equal "acronym"
+      "What's GNU (GNU's Not Unix)?\n\n"
+    (stexi->plain-text
+     '(*fragment* (para "What's "
+                        (acronym (% (acronym "GNU")
+                                    (meaning "GNU's Not Unix")))
+                        "?"))))
+
+  (pass-if-equal "recursive acronym"
+      "What's GNU (GNU's Not Unix)?\n\n"
+    (stexi->plain-text
+     '(*fragment* (para "What's "
+                        (acronym (% (acronym "GNU")
+                                    (meaning (acronym
+                                              (% (acronym "GNU")))
+                                             "'s Not Unix")))
+                        "?")))))