summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luavlna
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-11-07 22:21:01 +0000
committerKarl Berry <karl@freefriends.org>2019-11-07 22:21:01 +0000
commitdd150ee00b6fdd391d2301f5034b2eb58a1fafe6 (patch)
tree367769ea8df983ecf99b266bebe1a4d78307b0f6 /Master/texmf-dist/tex/luatex/luavlna
parent31a444d84abd6a8be620a0714b0ff03426d7b883 (diff)
luavlna (7nov19)
git-svn-id: svn://tug.org/texlive/trunk@52682 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luavlna')
-rw-r--r--Master/texmf-dist/tex/luatex/luavlna/luavlna.lua38
-rw-r--r--Master/texmf-dist/tex/luatex/luavlna/luavlna.sty14
-rw-r--r--Master/texmf-dist/tex/luatex/luavlna/luavlna.tex1
3 files changed, 48 insertions, 5 deletions
diff --git a/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua b/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua
index dea4c052eb0..d1eaa6f0044 100644
--- a/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua
+++ b/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua
@@ -14,6 +14,7 @@ local glue_id = node.id "glue"
local glyph_id = node.id "glyph"
local hlist_id = node.id "hlist"
local vlist_id = node.id "vlist"
+local penalty_id = node.id "penalty"
local math_id = node.id "math"
local period_char = string.byte(".")
@@ -224,6 +225,7 @@ local function prevent_single_letter (head)
local word = ""
local no_predegrees = M.no_predegrees
local no_sufdegrees = M.no_sufdegrees
+ local no_initials = M.no_initials
local in_math = false
while head do
local id = head.id
@@ -284,7 +286,7 @@ local function prevent_single_letter (head)
space = false
-- handle initials
-- uppercase letter followed by period (code 46)
- elseif init and head.id == glyph_id and head.char == period_char and nextn.id == glue_id and utf_len(word) == 1 then
+ elseif no_initials~=true and init and head.id == glyph_id and head.char == period_char and nextn.id == glue_id and utf_len(word) == 1 then
head = insert_penalty(head)
elseif head.id == glyph_id then
local char = utf_char(head.char)
@@ -305,20 +307,48 @@ local function prevent_single_letter (head)
return true
end
+local hyphenate_langs = {}
+local hyphenchar = string.byte("-")
+-- don't break if the next or previous char is hyphen, in order to support ligaturing of dashes
+local is_hyphen_ligature = function(n)
+ local next_node = n.next
+ -- split_hyphens code
+ if next_node and next_node.id == glyph_id and next_node.char == hyphenchar then
+ return true
+ end
+ local prev_node = n.prev
+ if prev_node and prev_node.id == glyph_id and prev_node.char == hyphenchar then
+ return true
+ end
+ return false
+end
+
+-- detect if the current character is a hyphen
+local function is_breakable_hyphen(n)
+ return n.id == glyph_id and hyphenate_langs[n.lang] and n.char == hyphenchar
+end
+
+-- don't process hyphens if the next node is penalty
+-- necessary to support \nobreakdash
+local function is_next_penalty(n)
+ local next_node = n.next
+ if next_node and next_node.id == penalty_id then
+ return true
+ end
+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
local skip = node.has_attribute(n, M.preventsingleid)
- if skip ~= 1 and n.id == glyph_id and hyphenate_langs[n.lang] and n.char == hyphenchar then
+ if skip ~= 1 and is_breakable_hyphen(n) and not is_next_penalty(n) and not is_hyphen_ligature(n) 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'))
diff --git a/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty b/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty
index 48db36b5f47..c620b670d10 100644
--- a/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty
+++ b/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty
@@ -1,4 +1,6 @@
-\ProvidesPackage{luavlna}[2017/09/30 luavlna]
+\ProvidesPackage{luavlna}[2019/10/30 luavlna]
+
+\RequirePackage{kvoptions}
\def\nosingledefaults{\relax}
\input luavlna
@@ -32,7 +34,16 @@
\fi%
}
+\DeclareVoidOption{noinitials}{\noinitials}
+\DeclareVoidOption{nounits}{\nounits}
+\DeclareVoidOption{nopredegrees}{\nopredegrees}
+\DeclareVoidOption{nosufdegrees}{\nosufdegrees}
+\DeclareVoidOption{noprocess}{\preventsingleoff}
+\DeclareVoidOption{debug}{\preventsingledebugon}
+\DeclareBoolOption[true]{defaults}
+\ProcessKeyvalOptions*
+\ifluavlna@defaults
\AtBeginDocument{%
\singlechars{czech}{AIiVvOoUuSsZzKk}
\singlechars{slovak}{AIiVvOoUuSsZzKk}
@@ -40,4 +51,5 @@
\enablesplithyphens{czech}
\enablesplithyphens{slovak}
}
+\fi
\endinput
diff --git a/Master/texmf-dist/tex/luatex/luavlna/luavlna.tex b/Master/texmf-dist/tex/luatex/luavlna/luavlna.tex
index 5159fbe5b54..ab47b8d6fcf 100644
--- a/Master/texmf-dist/tex/luatex/luavlna/luavlna.tex
+++ b/Master/texmf-dist/tex/luatex/luavlna/luavlna.tex
@@ -112,6 +112,7 @@ end
\def\nopredegrees{\directlua{luavlna.no_predegrees = true}}
\def\nosufdegrees{\directlua{luavlna.no_sufdegrees = true}}
\def\nounits{\directlua{luavlna.no_unit = true}}
+\def\noinitials{\directlua{luavlna.no_initials = true}}
\ifdefined\nosingledefaults\else
\singlechars{czech}{AIiVvOoUuSsZzKk}