diff options
Diffstat (limited to '_extensions/js/nobreaks/nobreaks.lua')
-rw-r--r-- | _extensions/js/nobreaks/nobreaks.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/_extensions/js/nobreaks/nobreaks.lua b/_extensions/js/nobreaks/nobreaks.lua new file mode 100644 index 0000000..dad13d5 --- /dev/null +++ b/_extensions/js/nobreaks/nobreaks.lua @@ -0,0 +1,20 @@ +-- Avoid linebreak between a number and a unit or quantifier + +local non_breaking_space = pandoc.Str("\u{00A0}") + +function Para(el) + for i = 1, #el.content - 1 do + if el.content[i].t == "Space" then + local el_prev = el.content[i - 1] + local el_next = el.content[i + 1] + if el_prev and el_next + and el_prev.t == "Str" and el_next.t == "Str" + and string.match(el_prev.text, "%d$") + and string.match(el_next.text, "^[%a%%§°]") + then + el.content[i] = non_breaking_space + end + end + end + return el +end |