--- en2em - replace space-enclosed en-dash with nospace em-dash --- --- Some typographical styles, including danish, --- use en-dash with spaces around to indicate a short pause, --- whereas others, including some british and american styles, --- use an em-dash without spaces. --- --- This plugin allows to always use en-dash at the source -- --- which also eases writing with semantic line breaks, like here -- --- and then convert while rendering as needed. --- --- SPDX-FileCopyrightText: 2025 Jonas Smedegaard --- SPDX-License-Identifier: GPL-3.0-or-later local em_dash = pandoc.Str("\u{2014}") local nothing = pandoc.Str("") local TypeIsSpacy = { Space = true, SoftBreak = true } function Block(el) if el.content == nil then return end for i = 1, #el.content - 1 do if el.content[i].t == "Str" and el.content[i].text == "\u{2013}" then local el_prev = el.content[i - 1] local el_next = el.content[i + 1] if el_prev and el_next and TypeIsSpacy[el_prev.t] and TypeIsSpacy[el_next.t] then el.content[i] = em_dash el.content[i - 1] = nothing el.content[i + 1] = nothing end end end return el end