Skip to content

Commit

Permalink
Merge pull request #1969 from alerque/turkish-apostrophe-hyphenation
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque authored Jan 26, 2024
2 parents 0f64791 + 9cd97af commit 4719863
Show file tree
Hide file tree
Showing 9 changed files with 296 additions and 2,146 deletions.
10 changes: 8 additions & 2 deletions core/hyphenator-liang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,18 @@ local hyphenateNode = function (node)
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)
specificDiscretionary = SILE.nodefactory.discretionary({ replacement = replacement, prebreak = hyphen })
if SILE.settings:get("languages.tr.replaceApostropheAtHyphenation") then
-- leading apostrophe (on next segment) cancels when hyphenated
specificDiscretionary = SILE.nodefactory.discretionary({ replacement = replacement, prebreak = hyphen })
else
-- hyphen character substituted for upcomming apostrophe
local kesme = SILE.shaper:createNnodes(nextApostrophe, node.options)
specificDiscretionary = SILE.nodefactory.discretionary({ replacement = replacement, prebreak = kesme })
end
end
elseif node.options.language == "ca" then
-- punt volat (middle dot) cancels when hyphenated
Expand Down
7 changes: 7 additions & 0 deletions documentation/c08-language.sil
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ The size of these spaces is determined by
According to Polish typography conventions, when a break occurs at an explicit hyphen, the hyphen gets repeated at the beginning of the new line.
SILE automatically handles this.

\subsection{Turkish}

According to Turkish typography conventions, when a break occurs at an existing apostrophe, the break point is allowed but no hyphenation character is shown.
SILE behaves this way default.
Some publisher style guides suggest an alternative behavior replacing the apostrophe with the hyphenation character.
This alternative behavior can be achieved by setting \autodoc:setting[check=false]{languages.tr.replaceApostropheAtHyphenation} to \code{true}.

\subsection{Japanese / Chinese}

SILE aims to conform with the W3G document “Requirements for Japanese Text Layout”\footnote{\url{https://www.w3.org/TR/jlreq/}} which describes the typographic conventions for Japanese (and also Chinese) text.
Expand Down
11 changes: 11 additions & 0 deletions languages/tr.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
-- Different years of TDK and various publisher style guides differ on this point.
-- Current official guidance suggests dropping the hypenation mark if the break
-- occurs at an apostrophe (kesme işareti). Some older guidance and some publishers
-- suggest dropping the apostrophe instead.
SILE.settings:declare({
parameter = "languages.tr.replaceApostropheAtHyphenation",
type = "boolean",
default = false,
help = "If enabled, substitute the apostophe for a hyphen at break points, otherwise keep the apostrophe and hide the hyphen."
})

-- Quotes may be part of a word in Turkish
SILE.nodeMakers.tr = pl.class(SILE.nodeMakers.unicode)
SILE.nodeMakers.tr.isWordType = { cm = true, qu = true }
Expand Down
Loading

0 comments on commit 4719863

Please sign in to comment.