diff options
author | Jonas Smedegaard <dr@jones.dk> | 2024-12-11 12:25:15 +0100 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2024-12-11 12:25:15 +0100 |
commit | 7d98938d5bb42b3668fc05d13ec757c2233ebb48 (patch) | |
tree | e2ef360d46774057ea21e44521116051429b1d5c | |
parent | ce388772af251bdc4cc7b2f41c89b548bc8d85cc (diff) |
add filter to avoid linebreak before lone percentage sign
-rw-r--r-- | _extensions/js/nobreaks/_extension.yml | 6 | ||||
-rw-r--r-- | _extensions/js/nobreaks/nobreaks.lua | 13 | ||||
-rw-r--r-- | _quarto.yml | 3 |
3 files changed, 22 insertions, 0 deletions
diff --git a/_extensions/js/nobreaks/_extension.yml b/_extensions/js/nobreaks/_extension.yml new file mode 100644 index 0000000..399be7b --- /dev/null +++ b/_extensions/js/nobreaks/_extension.yml @@ -0,0 +1,6 @@ +title: NoBreaks +author: Jonas Smedegaard +version: 0.0.1 +contributes: + filters: + - nobreaks.lua diff --git a/_extensions/js/nobreaks/nobreaks.lua b/_extensions/js/nobreaks/nobreaks.lua new file mode 100644 index 0000000..48a8fb5 --- /dev/null +++ b/_extensions/js/nobreaks/nobreaks.lua @@ -0,0 +1,13 @@ +-- Avoid linebreak before lone percentage sign + +function Para(el) + for i = 1, #el.content - 1 do + if el.content[i].t == "Space" then + local el_next = el.content[i + 1] + if el_next and el_next.t == "Str" and el_next.text == "%" then + el.content[i] = pandoc.Str("\u{00A0}") -- Non-breaking space + end + end + end + return el +end diff --git a/_quarto.yml b/_quarto.yml index b2007f4..e17a137 100644 --- a/_quarto.yml +++ b/_quarto.yml @@ -86,3 +86,6 @@ format: resources: - fonts + +filters: + - nobreaks |