guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 03/06: texinfo: Properly render @acronym in plain text.


From: Ludovic Courtès
Subject: [Guile-commits] 03/06: texinfo: Properly render @acronym in plain text.
Date: Wed, 12 Feb 2020 05:43:29 -0500 (EST)

civodul pushed a commit to branch stable-2.2
in repository guile.

commit 7dfd7b074332d39a915a8e6ffc48428521303ccd
Author: Ludovic Courtès <address@hidden>
AuthorDate: Wed Jan 29 15:16:38 2020 +0100

    texinfo: Properly render @acronym in plain text.
    
    Fixes <https://bugs.gnu.org/37846>.
    Reported by Christopher Baines <address@hidden>.
    
    * 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            | 13 ++++++++++++-
 test-suite/tests/texinfo.plain-text.test | 20 +++++++++++++++++++-
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/module/texinfo/plain-text.scm b/module/texinfo/plain-text.scm
index 6b7885a..5ea99c8 100644
--- a/module/texinfo/plain-text.scm
+++ b/module/texinfo/plain-text.scm
@@ -198,6 +198,16 @@
 (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))
 
@@ -246,7 +256,8 @@
     (url          ,code)
     (dfn          ,(make-surrounder "\""))
     (cite         ,(make-surrounder "\""))
-    (acro         ,passthrough)
+    (acro         ,acronym)                       ;XXX: useless?
+    (acronym      ,acronym)
     (email        ,key)
     (emph         ,(make-surrounder "_"))
     (sc           ,var)
diff --git a/test-suite/tests/texinfo.plain-text.test 
b/test-suite/tests/texinfo.plain-text.test
index 565da8c..4315cdb 100644
--- a/test-suite/tests/texinfo.plain-text.test
+++ b/test-suite/tests/texinfo.plain-text.test
@@ -31,4 +31,22 @@
       "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")))
+                        "?")))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]