aboutsummaryrefslogtreecommitdiff
path: root/_extensions/js/nobreaks/nobreaks.lua
blob: f4e26a21622ea37bdffa494eaa2448b82b645218 (plain)
  1. -- Avoid linebreak between a number and a unit or quantifier
  2. local non_breaking_space = pandoc.Str("\u{00A0}")
  3. function Para(el)
  4. for i = 1, #el.content - 1 do
  5. if el.content[i].t == "Space" then
  6. local el_prev = el.content[i - 1]
  7. local el_next = el.content[i + 1]
  8. if el_prev and el_next
  9. and el_prev.t == "Str" and el_next.t == "Str"
  10. and string.match(el_prev.text, "%d$")
  11. and string.match(el_next.text, "^[%a%%§°Ωμµ]")
  12. then
  13. el.content[i] = non_breaking_space
  14. end
  15. end
  16. end
  17. return el
  18. end