summaryrefslogtreecommitdiff
path: root/_extensions/js/nobreaks/nobreaks.lua
diff options
context:
space:
mode:
Diffstat (limited to '_extensions/js/nobreaks/nobreaks.lua')
-rw-r--r--_extensions/js/nobreaks/nobreaks.lua13
1 files changed, 13 insertions, 0 deletions
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