Skip to content

Commit

Permalink
fix(languages): Break at ela geminada in Catalan cancels the punt vola
Browse files Browse the repository at this point in the history
  • Loading branch information
Omikhleia authored and Didier Willis committed Jan 21, 2024
1 parent 312cc12 commit f8c4c1e
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions core/hyphenator-liang.lua
Expand Up @@ -114,18 +114,44 @@ local hyphenateNode = function (node)
local hyphen = SILE.shaper:createNnodes(SILE.settings:get("font.hyphenchar"), node.options)
local newnodes = {}
for j, segment in ipairs(segments) do
local leadingApostrophe
local specificDiscretionary
if segment == "" then
SU.dump({ j, segments })
SU.error("No hyphenation segment should ever be empty", true)
end
if node.options.language == "tr" then
-- leading apostrophe (on next segment) cancels when hyphenated
local nextApostrophe = j < #segments and luautf8.match(segments[j+1], "^['’]")
if nextApostrophe then
segments[j+1] = luautf8.gsub(segments[j+1], "^['’]", "")
local replacement = SILE.shaper:createNnodes(nextApostrophe, node.options)
leadingApostrophe = SILE.nodefactory.discretionary({ replacement = replacement, prebreak = hyphen })
leadingApostrophe.parent = node
specificDiscretionary = SILE.nodefactory.discretionary({ replacement = replacement, prebreak = hyphen })
end
elseif node.options.language == "ca" then
-- punt volat (middle dot) cancels when hyphenated
-- Catalan typists may use a punt volat or precomposed characters.
-- The shaper might behave differently depending on the font, so we need to
-- be consistent here with the typist's choice.
if luautf8.find(segment, "ŀ$") then -- U+0140
segment = luautf8.sub(segment, 1, -2)
local ldot = SILE.shaper:createNnodes("ŀ", node.options)
local lhyp = SILE.shaper:createNnodes("l" .. SILE.settings:get("font.hyphenchar"), node.options)
specificDiscretionary = SILE.nodefactory.discretionary({ replacement = ldot, prebreak = lhyp })
elseif luautf8.find(segment, "Ŀ$") then -- U+013F
segment = luautf8.sub(segment, 1, -2)
local ldot = SILE.shaper:createNnodes("Ŀ", node.options)
local lhyp = SILE.shaper:createNnodes("L" .. SILE.settings:get("font.hyphenchar"), node.options)
specificDiscretionary = SILE.nodefactory.discretionary({ replacement = ldot, prebreak = lhyp })
elseif luautf8.find(segment, "l·$") then -- l + U+00B7
segment = luautf8.sub(segment, 1, -3)
local ldot = SILE.shaper:createNnodes("", node.options)
local lhyp = SILE.shaper:createNnodes("l" .. SILE.settings:get("font.hyphenchar"), node.options)
specificDiscretionary = SILE.nodefactory.discretionary({ replacement = ldot, prebreak = lhyp })
elseif luautf8.find(segment, "L·$") then -- L + U+00B7
segment = luautf8.sub(segment, 1, -3)
local ldot = SILE.shaper:createNnodes("", node.options)
local lhyp = SILE.shaper:createNnodes("L" .. SILE.settings:get("font.hyphenchar"), node.options)
specificDiscretionary = SILE.nodefactory.discretionary({ replacement = ldot, prebreak = lhyp })
end
end
for _, newNode in ipairs(SILE.shaper:createNnodes(segment, node.options)) do
Expand All @@ -135,8 +161,9 @@ local hyphenateNode = function (node)
end
end
if j < #segments then
if leadingApostrophe then
table.insert(newnodes, leadingApostrophe)
if specificDiscretionary then
specificDiscretionary.parent = node
table.insert(newnodes, specificDiscretionary)
else
local newNode = SILE.nodefactory.discretionary({ prebreak = hyphen })
newNode.parent = node
Expand Down

0 comments on commit f8c4c1e

Please sign in to comment.