summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-10-23 21:40:43 +0000
committerKarl Berry <karl@freefriends.org>2019-10-23 21:40:43 +0000
commitd580dddbf84953059f75b9bcefb4086128ffcb58 (patch)
tree4ab46e5c78be1390ae64968b00f2d15f298b649f /Master/texmf-dist/tex/luatex
parentdb9dd963f8bb7e87f0913c3041e0665133f8e8b3 (diff)
luavlna (23oct19)
git-svn-id: svn://tug.org/texlive/trunk@52504 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex')
-rw-r--r--Master/texmf-dist/tex/luatex/luavlna/luavlna.lua40
-rw-r--r--Master/texmf-dist/tex/luatex/luavlna/luavlna.sty1
2 files changed, 41 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua b/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua
index 84d4c3f82cd..73a10fe9ba8 100644
--- a/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua
+++ b/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua
@@ -305,10 +305,50 @@ local function prevent_single_letter (head)
return true
end
+-- Enable hyphenation of words that contain hyphens
+-- and repeating of the explicit hyphen on a new line when
+-- the hyphen is hyphenated
+-- It should be used in the `hyphenate` callback
+-- based on ShreewatsaR's code from:
+-- https://tex.stackexchange.com/a/417883/2891
+local hyphenate_langs = {}
+local break_hyphens = function(head, tail)
+ local hyphenchar = string.byte("-")
+ local glyph_id = node.id("glyph")
+ local n = head
+ while n do
+ if n.id == glyph_id and hyphenate_langs[n.lang] and n.char == hyphenchar then
+ -- Insert an infinite penalty before, and a zero-width glue node after, the hyphen.
+ -- Like writing "\nobreak-\hspace{0pt}" or equivalently "\penalty10000-\hskip0pt"
+ local p = node.new(node.id('penalty'))
+ p.penalty = 10000
+ head, p = node.insert_before(head, n, p)
+ local g = node.new(node.id('glue'))
+ head, g = node.insert_after(head, n, g)
+ -- insert the discretionary
+ local disc = node.new("disc")
+ disc.penalty = tex.hyphenpenalty
+ disc.subtype = 2
+ disc.pre = node.copy(n)
+ disc.post = node.copy(n)
+ disc.replace = node.copy(n)
+ node.insert_before(head, g, disc)
+ -- insert another penalty
+ node.insert_before(head, g, node.copy(p))
+ node.remove(head,n)
+ n = g
+ end
+ n = n.next
+ end
+ lang.hyphenate(head, tail)
+end
+
M.preventsingle = prevent_single_letter
M.singlechars = set_singlechars
M.initials = set_initials
M.set_tex4ht = set_tex4ht
M.debug = set_debug
M.set_main_language = set_main_language
+M.split_hyphen_langs = hyphenate_langs
+M.split_hyphens = break_hyphens
return M
diff --git a/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty b/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty
index 059c260ea11..44efffb6bd6 100644
--- a/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty
+++ b/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty
@@ -20,5 +20,6 @@
\singlechars{czech}{AIiVvOoUuSsZzKk}
\singlechars{slovak}{AIiVvOoUuSsZzKk}
\compoundinitials{czech}{Ch,CH}
+ \enablesplithyphens{czech}
}
\endinput