1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

texinfo: Properly render @acronym in plain text.

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.
This commit is contained in:
Ludovic Courtès 2020-01-29 15:16:38 +01:00
parent c4b2bd3781
commit ff14b77ff5
2 changed files with 31 additions and 2 deletions

View file

@ -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)

View file

@ -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")))
"?")))))