texlive[52682] Master/texmf-dist: luavlna (7nov19)

commits+karl at tug.org commits+karl at tug.org
Thu Nov 7 23:21:01 CET 2019


Revision: 52682
          http://tug.org/svn/texlive?view=revision&revision=52682
Author:   karl
Date:     2019-11-07 23:21:01 +0100 (Thu, 07 Nov 2019)
Log Message:
-----------
luavlna (7nov19)

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/tex/luatex/luavlna/luavlna.lua
    trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty
    trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.tex

Modified: trunk/Master/texmf-dist/doc/luatex/luavlna/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luavlna/README.md	2019-11-07 22:20:49 UTC (rev 52681)
+++ trunk/Master/texmf-dist/doc/luatex/luavlna/README.md	2019-11-07 22:21:01 UTC (rev 52682)
@@ -1,4 +1,4 @@
-# Luavlna, version v0.1e, 2019-10-29
+# Luavlna, version v0.1f, 2019-11-06
 
 # 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-11-07 22:20:49 UTC (rev 52681)
+++ trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna-doc.tex	2019-11-07 22:21:01 UTC (rev 52682)
@@ -130,6 +130,19 @@
 
 in the preamble.
 
+\section{Package options}
+The \verb|luavlna| package recognizes the following options
+
+\begin{description}
+  \item[\texttt{noprocess}] -- disable the automatic document processing.
+  \item[\texttt{noinitials}] -- disable processing of the initials.
+  \item[\texttt{nounits}] -- disable processing of the SI units.
+  \item[\texttt{nopredegrees}] -- disable processing of the the academic degrees before names.
+  \item[\texttt{nosufdegrees}] -- disable processing of the the academic degrees after names.
+  \item[\texttt{debug}] -- enable the debugging mode.
+  \item[\texttt{defaults}] -- load default settings. Enabled by default.
+\end{description}
+
 \section{Commands}
 
 \begin{mycode}
@@ -222,14 +235,16 @@
 \cmd{\preventsingleon}
 \end{mycode}
 
-You can also disable units and degrees processing:
+You can also disable initials, units and degrees processing:
 
 \begin{mycode}
+  \cmd{\noinitials}\\
   \cmd{\nounits}\\
   \cmd{\nopredegrees}\\
   \cmd{\nosufdegrees}
 \end{mycode}
 
+
 \subsection{Debugging commands}
 \begin{mycode}
 \cmd{\preventsingledebugon}\par

Modified: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua	2019-11-07 22:20:49 UTC (rev 52681)
+++ trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua	2019-11-07 22:21:01 UTC (rev 52682)
@@ -14,6 +14,7 @@
 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 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 @@
         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,6 +307,36 @@
   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
@@ -311,14 +343,12 @@
 -- 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'))

Modified: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty	2019-11-07 22:20:49 UTC (rev 52681)
+++ trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty	2019-11-07 22:21:01 UTC (rev 52682)
@@ -1,5 +1,7 @@
-\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 at defaults
 \AtBeginDocument{%
   \singlechars{czech}{AIiVvOoUuSsZzKk}
   \singlechars{slovak}{AIiVvOoUuSsZzKk}
@@ -40,4 +51,5 @@
   \enablesplithyphens{czech}
   \enablesplithyphens{slovak}
 }
+\fi
 \endinput

Modified: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.tex
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.tex	2019-11-07 22:20:49 UTC (rev 52681)
+++ trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.tex	2019-11-07 22:21:01 UTC (rev 52682)
@@ -112,6 +112,7 @@
 \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}



More information about the tex-live-commits mailing list