Skip to content

Text replacements are not recursive

David Kastrup requested to merge dev/dak/text-replacements-recursive into master

When performing text replacements, do not process parts coming from a replacement for new replacements.

The previous logic led to strange semantics. Because the longest replacements were processed first, this printed "a":

\markup \replace
  #'(("looong" . "short")
     ("short" . "a"))
"looong"

but this printed "looong":

\markup \replace
  #'(("short" . "looong")
     ("looong" . "a"))
"short"

Also, if the replacement string contained the replaced string anywhere but as a prefix, an infinite loop occured, like in

\markup \replace
  #'(("a" . "ba"))
"a"

Fix these two bugs and clarify the behavior in NR.

Edited by Jonas Hahnfeld

Merge request reports