texlive[52504] Master/texmf-dist: luavlna (23oct19)

commits+karl at tug.org commits+karl at tug.org
Wed Oct 23 23:40:44 CEST 2019


Revision: 52504
          http://tug.org/svn/texlive?view=revision&revision=52504
Author:   karl
Date:     2019-10-23 23:40:43 +0200 (Wed, 23 Oct 2019)
Log Message:
-----------
luavlna (23oct19)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/luatex/luavlna/README.md
    trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna-doc.pdf
    trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna-doc.tex
    trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna.tex
    trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua
    trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty

Modified: trunk/Master/texmf-dist/doc/luatex/luavlna/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luavlna/README.md	2019-10-23 21:40:23 UTC (rev 52503)
+++ trunk/Master/texmf-dist/doc/luatex/luavlna/README.md	2019-10-23 21:40:43 UTC (rev 52504)
@@ -1,4 +1,4 @@
-# Luavlna, version v0.1c, 2019-04-16
+# Luavlna, version v0.1d, 2019-10-22
 
 # Introduction
 

Modified: trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna-doc.tex	2019-10-23 21:40:23 UTC (rev 52503)
+++ trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna-doc.tex	2019-10-23 21:40:43 UTC (rev 52504)
@@ -44,7 +44,7 @@
 \verb!impnattypo! for Lua\LaTeX). %This package is for plain
 %lua\TeX and for lua\LaTeX.
 
-Other feature of this package is including of non-breakable space after 
+Another feature is inclusion of a non-breakable space after 
 initials, like in personal names, after or before academic degrees
 and between numbers and units (SI and others).
 
@@ -52,10 +52,11 @@
 TeX.sx\footnote{\url{http://tex.stackexchange.com/a/28128/2891}}.
 The difference is that it is possible to specify which single letters
 should be taken into account for different languages.
-The support for degrees and units was added as well.
+% The support for degrees and units was added as well.
 % The code works also for single letters at the beginning of the brackets.
 
 
+
 \section{Usage}
 
 The usage is simple:
@@ -169,6 +170,35 @@
 \end{verbatim}
 \end{mycode}
 
+
+\subsection{Split hyphens}
+
+The hyphenated words like ``je-li'' should be be hyphenated as ``je-/-li``
+according to the Czech typesetting rules. This behaviour can be enabled or disabled for a particular
+language using the following commands:
+
+\begin{mycode}
+  \cmd{\enablesplithyphens}\marg{language name}\\
+  \cmd{\disablesplithyphens}\marg{language name}
+\end{mycode}
+
+By default, it is enabled for the Czech language.
+
+Example in action:
+
+\begin{minipage}{3in}
+  \selectlanguage{czech}
+   Sedlec-Prčice, modro-zelený,  překladatel-tlumočník, kuchař-číšník, propan-butan,                                                                                          
+   Otýlie Sklenářová-Malá, František Jílek-Oberpfalcer.
+  \selectlanguage{english}
+\end{minipage}
+
+The similar behaviour can be achieved using the \verb|\splithyphens|  command
+provided by Czech langauge definitions for the Babel package, but it's use is
+discouraged. It prevents use ot the hyphen character in many situations. The
+solution provided by Luavlna should be safe.
+
+
 \subsection{Turning off language switching}
 
 By default, language of the nodes is taken into account. If you want to use

Modified: trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna.tex
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna.tex	2019-10-23 21:40:23 UTC (rev 52503)
+++ trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna.tex	2019-10-23 21:40:43 UTC (rev 52504)
@@ -5,6 +5,7 @@
 
 require "ltluatex"
 luatexbase.add_to_callback("pre_linebreak_filter", luavlna.preventsingle,"LuaVlna")
+luatexbase.add_to_callback("hyphenate", luavlna.split_hyphens, "allow hyphen breaks")
 % -- define the attribute number
 luavlna.preventsingleid = math.random(2^16)
 
@@ -54,6 +55,18 @@
   if not langid then return nil, "Cannot find language number for: "..lang end
   luavlna.set_main_language(langid)
 end	
+
+enable_split_hyphens = function(lang)
+  local langid = languages:get_number(lang)
+  if not langid then return nil, "Cannot find language number for: "..lang end
+  luavlna.split_hyphen_langs[langid] = true
+end
+
+disable_split_hyphens = function(lang)
+  local langid = languages:get_number(lang)
+  if not langid then return nil, "Cannot find language number for: "..lang end
+  luavlna.split_hyphen_langs[langid] = nil
+end
 }     
 
 % Set letters which are prevented from breaking
@@ -89,6 +102,11 @@
 \directlua{luavlna.debug(false)}
 }
 
+% enable/disable split hyphens for a language
+
+\def\enablesplithyphens#1{\directlua{enable_split_hyphens("#1")}}
+\def\disablesplithyphens#1{\directlua{disable_split_hyphens("#1")}}
+
 % disable processing of units or degrees
 
 \def\nopredegrees{\directlua{luavlna.no_predegrees = true}}
@@ -99,5 +117,6 @@
   \singlechars{czech}{AIiVvOoUuSsZzKk}
   \singlechars{slovak}{AIiVvOoUuSsZzKk}
   \compoundinitials{czech}{Ch,CH}
+  \enablesplithyphens{czech}
 \fi
 

Modified: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua	2019-10-23 21:40:23 UTC (rev 52503)
+++ trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua	2019-10-23 21:40:43 UTC (rev 52504)
@@ -305,6 +305,44 @@
   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
@@ -311,4 +349,6 @@
 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

Modified: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty	2019-10-23 21:40:23 UTC (rev 52503)
+++ trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty	2019-10-23 21:40:43 UTC (rev 52504)
@@ -20,5 +20,6 @@
   \singlechars{czech}{AIiVvOoUuSsZzKk}
   \singlechars{slovak}{AIiVvOoUuSsZzKk}
   \compoundinitials{czech}{Ch,CH}
+  \enablesplithyphens{czech}
 }
 \endinput



More information about the tex-live-commits mailing list