texlive[47892] Master: luavlna (31may18)

commits+karl at tug.org commits+karl at tug.org
Thu May 31 23:52:22 CEST 2018


Revision: 47892
          http://tug.org/svn/texlive?view=revision&revision=47892
Author:   karl
Date:     2018-05-31 23:52:21 +0200 (Thu, 31 May 2018)
Log Message:
-----------
luavlna (31may18)

Modified Paths:
--------------
    trunk/Master/tlpkg/bin/tlpkg-ctan-check
    trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/luatex/luavlna/
    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/
    trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-csplain-langs.lua
    trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-langno.lua
    trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-predegrees.lua
    trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-presi.lua
    trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-si.lua
    trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-sufdegrees.lua
    trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.4ht
    trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua
    trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty
    trunk/Master/tlpkg/tlpsrc/luavlna.tlpsrc

Added: trunk/Master/texmf-dist/doc/luatex/luavlna/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luavlna/README.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/luatex/luavlna/README.md	2018-05-31 21:52:21 UTC (rev 47892)
@@ -0,0 +1,119 @@
+# Luavlna, version v0.1b, 2018-05-31
+
+# Introduction
+
+`Luavlna` is a small package for plain LuaTeX and LuaLaTeX. In some languages,
+like Czech or Polish, there should be no single letter words at the
+line end, according to the typographical norms. There exists some
+external commands (like `vlna`) or packages (`encxvlna` for encTeX,
+`xevlna` for XeTeX, `impnattypo` for LuaLaTeX).
+
+Other feature of this package is including of non-breakable space after initials,
+like in personal names, after or before academic degrees
+and between numbers and units (SI and others).
+
+The code is modified version of Patrick Gundlach’s answer on
+TeX.sx[^1]. 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.
+
+# Usage
+
+The usage is simple:
+
+    \input ucode
+    \uselanguage{czech}
+    %% in the case of luacsplain, use instead:
+    %% \chyph
+    %% but language code for Czech is different than in LaTeX or normal 
+    %% LuaTeX, so you will need to set single letters with somethinh like:
+    %% \singlechars{5}{AIiVvOoUuSsZzKk}
+    \input luavlna
+    \preventsingledebugon
+    \input luaotfload.sty
+    \font\hello={name:Linux Libertine O:+rlig;+clig;+liga;+tlig} at 12pt 
+    \hsize=3in
+    \hello
+    Příliš žluťoučký kůň úpěl ďábelské ódy. 
+    Text s krátkými souhláskami a samohláskami i dalšími jevy 
+    z nabídky možností (v textu možnými). 
+    
+    I začátek odstavce je třeba řešit, i když výskyt zalomení není pravděpodobný.
+    
+    Co třeba í znaky š diakritikou?
+    
+    Různé možnosti [v závorkách <i jiných znacích
+
+    Podpora iniciál a titulů: M. J. Hegel, Ing. Běháková, Ph.D., Ž. Zíbrt.
+
+    Podpora jednotek: 100,5 MN\cdot{}s, 100.5 kJ, 200 µA, $-1$ dag, 12 MiB, 1 m$^3$/s.
+
+    \preventsingledebugoff
+    \bye
+
+
+It is also possible to use the package with lua, just use
+
+        \usepackage{luavlna}
+
+in the preamble.
+
+# Commands
+
+    \singlechars{language name}{letters} 
+
+Enable this feature for certain letters in given language. 
+
+Default values:
+
+    %% only Czech and Slovak are supported out of the box
+    \singlechars{czech}{AIiVvOoUuSsZzKk}
+    \singlechars{slovak}{AIiVvOoUuSsZzKk}
+
+    \compoundinitials{language name}{compounds}
+
+Declare compound letters for given language. Second argument should be comma 
+separated list of compound letters, in exact form in which they can appear.
+
+Default values:
+
+    \compoundinitials{czech}{Ch}
+
+##Turning off language switching
+
+By default, language of the nodes is taken into account. If you want to use
+settings for one language for a whole document, you can use following command:
+
+    	\preventsinglelang{language name}
+
+##Turning off processing
+
+If you want to stop processing of the spaces in the document you can use
+command
+
+    \preventsingleoff
+
+To resume processing, use
+
+    \preventsingleon
+
+## Debugging commands 
+
+    \preventsingledebugon
+    \preventsingledebugoff
+
+Insert debugging marks on/off. Default off.
+
+# Authors
+
+Michal Hoftich
+Miro Hrončok
+
+# License
+
+Permission is granted to copy, distribute and/or modify this software
+under the terms of the LaTeX Project Public License, version 1.3.
+
+[^1]:
+    <http://tex.stackexchange.com/a/28128/2891>


Property changes on: trunk/Master/texmf-dist/doc/luatex/luavlna/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna-doc.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna-doc.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna-doc.pdf	2018-05-31 21:51:17 UTC (rev 47891)
+++ trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna-doc.pdf	2018-05-31 21:52:21 UTC (rev 47892)

Property changes on: trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna-doc.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna-doc.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna-doc.tex	2018-05-31 21:52:21 UTC (rev 47892)
@@ -0,0 +1,269 @@
+\documentclass[12pt]{ltxdoc}
+%\documentclass{article}
+%\usepackage[utf8]{luainputenc}
+\usepackage{fontspec}
+\setmainfont[Ligatures=TeX]{Linux Libertine O}
+\usepackage[czech,english]{babel}
+\usepackage{luacode}
+\usepackage{amsfonts}
+%\usepackage[]{polyglossia}
+%\setmainlanguage{english}
+%\setotherlanguage{czech}
+%\usepackage{url}
+\usepackage{hyperref}
+%\input prevent-single
+%\usepackage[]{prevent-single}
+\usepackage[]{luavlna}
+%\input prevent-single
+%\def\preventsingledebugon{}
+\newenvironment{mycode}{
+	%\leavevmode%
+	\medskip%
+	\parindent=0pt%
+}{\medskip}
+
+\ifdefined\version\else
+  \def\version{{{VERSION}}}
+  \let\gitdate\date
+\fi
+
+\begin{document}
+\title{The \verb|luavlna| package}
+\author{Michal Hoftich (\url{michal.h21 at gmail.com})\\Miro Hrončok (\url{miro at hroncok.cz})}
+\date{Version \version\\\gitdate}
+\maketitle
+\tableofcontents
+\section{Introduction}
+
+
+This is a small package for plain Lua\TeX and Lua\LaTeX. In some languages, like
+Czech or Polish, there should be no single letter words at the line
+end, according to the typographical norms. There exists some
+external commands (like \verb!vlna!) or packages (\verb!encxvlna!
+for enc\TeX, \verb!xevlna! for Xe\TeX,
+\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 
+initials, like in personal names, after or before academic degrees
+and between numbers and units (SI and others).
+
+The code is modified version of Patrick Gundlach's answer on
+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 code works also for single letters at the beginning of the brackets.
+
+
+\section{Usage}
+
+The usage is simple:
+
+\begin{verbatim}
+\input ucode
+\uselanguage{czech}
+%% in the case of luacsplain, use instead:
+%% \chyph
+\input luavlna
+\preventsingledebugon
+\input luaotfload.sty
+\font\hello={name:Linux Libertine O:+rlig;+clig;+liga;+tlig} at 12pt 
+\hsize=3in
+\hello
+Příliš žluťoučký kůň úpěl ďábelské ódy. 
+Text s krátkými souhláskami a samohláskami i dalšími jevy 
+z nabídky možností (v textu možnými). 
+
+I začátek odstavce je třeba řešit, i když výskyt zalomení 
+není pravděpodobný.
+
+Co třeba í znaky š diakritikou?
+
+Různé možnosti [v závorkách <i jiných znacích
+
+Podpora iniciál a titulů: M. J. Hegel, Ing. Běháková, Ph.D., Ž. Zíbrt.
+
+Podpora jednotek: 100,5 MN\cdot{}s, 100.5 kJ, 200 µA, $-1$ dag, 
+12 MiB, 1 m$^3$/s.
+
+Uvnitř matematiky by mělo být zpracování vypnuté:  $k \in \mathbb N$. 
+Pokračujeme v příkladu.
+
+\preventsingledebugoff
+\bye
+\end{verbatim}
+
+%\noindent\parbox{3in}{%
+
+\noindent
+\begin{minipage}{3in}
+\preventsingledebugon
+\selectlanguage{czech}
+Příliš \textit{žluťoučký kůň} úpěl ďábelské ódy. 
+Text s krátkými souhláskami a samohláskami i dalšími jevy z nabídky možností (v textu možnými). 
+
+I začátek odstavce je třeba řešit, i když výskyt zalomení není pravděpodobný.
+
+Co třeba í znaky š diakritikou?
+
+Různé možnosti [v závorkách \textless i jiných znacích
+
+Podpora iniciál a titulů: M. J. Hegel, Ing. Běháková, Ph.D., Ž. Zíbrt.
+
+Podpora jednotek: 100,5 MN\cdot{}s, 100.5 kJ, 200 µA, $-1$ dag, 12 MiB, 1 m$^3$/s.
+
+Uvnitř matematiky by mělo být zpracování vypnuté:  $k \in \mathbb N$. Pokračujeme v příkladu.
+
+\preventsingledebugoff
+%}
+\end{minipage}
+
+\selectlanguage{english}
+\bigskip
+It is also possible to use the package with Lua\LaTeX, just use
+
+\begin{verbatim}
+	\usepackage{luavlna}
+\end{verbatim}
+
+in the preamble.
+
+\section{Commands}
+
+\begin{mycode}
+\cmd{\singlechars}\marg{language name}\marg{letters} 
+\end{mycode}
+
+Enable this feature for certain letters in given language. 
+%Language code is internall \TeX\ code for the language, it is $0$ for English, 
+%$16$ for Czech. Please note that in \verb|csplain|, language code for Czech 
+%is $5$ and you will have to set it yourself.
+
+Default values:
+
+\begin{mycode}
+\begin{verbatim}
+%% only Czech and Slovak are supported out of the box
+\singlechars{czech}{AIiVvOoUuSsZzKk}
+\singlechars{slovak}{AIiVvOoUuSsZzKk}
+\end{verbatim}
+\end{mycode}
+
+%By default, all
+%single letters are processed, this command can be used to pass a
+%string of characters, which should be processed only.
+
+\begin{mycode}
+\cmd{\compoundinitials}\marg{language name}\marg{compounds}
+\end{mycode}
+
+Declare compound letters for given language. Second argument should be comma 
+separated list of compound letters, in exact form in which they can appear.
+
+Default values:
+
+\begin{mycode}
+\begin{verbatim}
+\compoundinitials{czech}{Ch,CH}
+\end{verbatim}
+\end{mycode}
+
+\subsection{Turning off language switching}
+
+By default, language of the nodes is taken into account. If you want to use
+settings for one language for a whole document, you can use following command:
+
+\begin{mycode}
+\cmd{\preventsinglelang}\marg{language name}
+\end{mycode}
+
+\subsection{Turning off processing}
+
+If you want to stop processing of the spaces in the document you can use command
+
+\begin{mycode}
+\cmd{\preventsingleoff}
+\end{mycode}
+
+To resume processing, use
+
+\begin{mycode}
+\cmd{\preventsingleon}
+\end{mycode}
+
+You can also disable units and degrees processing:
+
+\begin{mycode}
+  \cmd{\nounits}\\
+  \cmd{\nopredegrees}\\
+  \cmd{\nosufdegrees}
+\end{mycode}
+
+\subsection{Debugging commands}
+\begin{mycode}
+\cmd{\preventsingledebugon}\par
+\cmd{\preventsingledebugoff}
+\end{mycode}
+
+Insert debugging marks on/off. Default off.
+
+\section{Lua module \texttt{luavlna-langno.lua}}
+
+When we process glyph nodes with Lua\TeX\ callbacks, there are \verb|lang| 
+fields available. These are numerical codes of languages, but no information
+about language names easily accesible from Lua side is available.\footnote{%
+	Language names are stored in \TeX macros like \verb|\string\l at langname|, but 
+	different formats use different naming of these macros}
+These numbers are format dependent, majority of formats like 
+Lua\LaTeX use \verb|language.dat| file provided by \verb|babel| 
+for assign numbers to languages, but for example \verb|csplain| 
+use its own system.
+
+To allow easy setting of language dependent parameters, \verb|langno| module 
+was created. It's purpose is to translate language code to language name and 
+the other way. Lua\LaTeX, Lua\TeX\ and CSplain formats are supported at the moment.
+
+\subsection{Recognized languages}
+\subsubsection{Lua\TeX\ and Lua\LaTeX}
+
+File \verb|language.dat| is processed to load language names, aliases and assigned numbers. These language names are the same as supported by \verb|babel| package.
+
+\begin{quotation}
+  \small\noindent
+\begin{luacode*}
+  langno = require "luavlna-langno"
+  function print_format_lang(fmt)
+    local luatex = langno.load_languages(fmt)
+    local t = {}
+    for k, v in pairs(luatex.names) do
+      t[#t+1]=k
+    end
+    table.sort(t)
+    tex.print(table.concat(t,", "))
+  end
+  print_format_lang("luatex")
+\end{luacode*}
+\end{quotation}
+
+\subsubsection{CSplain}
+
+Different method is used. File \verb|hyphen.lan| is included in CSplain, where 
+language numbers are assigned to ISO-639-1 or ISO-639-2 language codes. 
+These language codes were then normalized to names used vy \verb|babel|, or 
+standard English language names.
+
+\begin{quotation}
+  \small\noindent
+  \begin{luacode*}
+    print_format_lang("csplain")
+  \end{luacode*}
+\end{quotation}
+
+
+\section{License}
+
+Permission is granted to copy, distribute and/or modify this software
+under the terms of the LaTeX Project Public License, version 1.3.
+
+\end{document}


Property changes on: trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna-doc.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna.tex
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna.tex	2018-05-31 21:52:21 UTC (rev 47892)
@@ -0,0 +1,104 @@
+% detect LaTeX and use the correct method for luatexbase inclusion
+\ifx\RequirePackage\undefined
+  \input{luatexbase.sty}%
+\else
+  \RequirePackage{luatexbase}
+\fi
+
+\newluatexattribute\preventsinglestatus
+% Modify pre_linebreak_filter callback so the spaces can be inserted
+\directlua{%         
+luavlna = require "luavlna" 
+langno  = require "luavlna-langno"
+luatexbase.add_to_callback("pre_linebreak_filter", luavlna.preventsingle," ")
+
+local languages = langno.load_languages()
+local get_lang_id = function(lang)
+  local langid = lang 
+  if not tonumber(lang) then
+    langid = languages:get_number(lang)
+  end
+  return langid
+end
+
+% Process string and make table of enabled single letters
+% By default, spaces for all single letters are inserted
+% This can be modified with \singlechars macro
+set_singlechars = function(lang,chars)
+  local utf_gmatch = unicode.utf8.gmatch
+  % local langnumbers = languages.names
+  local langid = get_lang_id(lang) 
+  if not langid then return nil, "Cannot find language number for: "..lang end
+  local chars = chars  or ""
+  local singlechars = {}
+  local percent = string.char(37)
+  local alpha = percent .. "a"
+  for char in utf_gmatch(chars,"("..alpha..")") do
+    singlechars[char] = true
+  end
+  luavlna.singlechars(langid,singlechars)
+end
+
+% set compound characters for initials handling
+% useful for Czech "Ch" etc.
+% comma separated list of compounds
+set_compounds = function(lang, compounds)
+  local langid = get_lang_id(lang)
+  if not langid then return nil, "Cannot find language number for: "..lang end
+  local c = compounds:explode(",+") % match multiple colons as one
+  local  compoundstable = {}
+  for _, compound in pairs(c) do
+    compoundstable[compound] = true
+  end
+  luavlna.initials(langid, compoundstable)
+end
+
+set_main_language = function(lang)
+  local langid = languages:get_number(lang)
+  if not langid then return nil, "Cannot find language number for: "..lang end
+  luavlna.set_main_language(langid)
+end	
+}     
+
+% Set letters which are prevented from breaking
+\def\singlechars#1#2{%
+\directlua{set_singlechars("#1","#2")}
+}
+
+% Define compound initials
+\def\compoundinitials#1#2{%
+\directlua{set_compounds("#1","#2")}
+}
+% Enable inserting of visual marks for debugging
+\def\preventsingledebugon{%
+\directlua{luavlna.debug(true)}
+}
+
+\def\preventsinglelang#1{%
+	\directlua{set_main_language("#1")}
+} 
+
+\def\preventsingleon{%
+	\preventsinglestatus=2
+}
+
+\def\preventsingleoff{
+	\preventsinglestatus=1
+}
+% Disable inserting of visual marks for dewbugging
+\def\preventsingledebugoff{%
+\directlua{luavlna.debug(false)}
+}
+
+% disable processing of units or degrees
+
+\def\nopredegrees{\directlua{luavlna.no_predegrees = true}}
+\def\nosufdegrees{\directlua{luavlna.no_sufdegrees = true}}
+\def\nounits{\directlua{luavlna.no_unit = true}}
+
+\ifdefined\nosingledefaults\else
+  \singlechars{czech}{AIiVvOoUuSsZzKk}
+  \singlechars{slovak}{AIiVvOoUuSsZzKk}
+  \compoundinitials{czech}{Ch,CH}
+\fi
+


Property changes on: trunk/Master/texmf-dist/doc/luatex/luavlna/luavlna.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-csplain-langs.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-csplain-langs.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-csplain-langs.lua	2018-05-31 21:52:21 UTC (rev 47892)
@@ -0,0 +1,59 @@
+return {
+["spanish; castilian"]={26, 126},
+["magyar; hungarian"]={30, 130},
+["english; usenglish; american"]={100},
+["icelandic"]={42, 142},
+["basque"]={33, 133},
+["coptic"]={205},
+["catalan; valencian"]={204},
+["welsh"]={24, 124},
+["irish"]={34, 134},
+["armenian"]={210},
+["chinese"]={41, 141},
+["danish"]={25, 125},
+["turkish"]={31, 131},
+["interlingua "]={103},
+["slovak"]={6, 16, 116},
+["english; ukenglish; british"]={101},
+["ukrainian"]={209},
+["turkmen"]={47, 147},
+["sanskrit"]={207},
+["hindi"]={212},
+["lao"]={214},
+["finnish"]={29, 129},
+["assamese"]={211},
+["greek; polutonikogreek"]={203},
+["czech"]={5, 15, 115},
+["tamil"]={221},
+["italian"]={102},
+["french; francais; canadien; acadian"]={22, 122},
+["telugu"]={222},
+["croatian"]={40, 140},
+["panjabi; punjabi"]={220},
+["oriya"]={219},
+["russian"]={208},
+["malayalam"]={217},
+["marathi"]={218},
+["uppersorbian"]={43, 143},
+["portuges; portuguese; brazilian; brazil"]={38, 138},
+["galician"]={45, 145},
+["latvian"]={215},
+["afrikaans"]={44, 144},
+["lithuanian"]={216},
+["slovenian;slovene"]={28, 128},
+["mongolian"]={206},
+["greek; polutonikogreek"]={202},
+["latin"]={48, 148},
+["indonesian; indon; bahasai; bahasam; malay; meyalu"]={104},
+["polish"]={23, 123},
+["bokmål"]={35, 135},
+["dutch; flemish"]={37, 137},
+["greek; polutonikogreek"]={201},
+["norsk; nynorsk; norwegian"]={36, 136},
+["kannada"]={213},
+["estonian"]={32, 132},
+["english; usenglish; american; ukenglish; british; canadian; australian; newzealand"]={0},
+["romanian; moldavian; moldovan"]={39, 139},
+["german; germanb; ngerman; naustrian"]={21, 121},
+["kurdish"]={46, 146},
+}


Property changes on: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-csplain-langs.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-langno.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-langno.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-langno.lua	2018-05-31 21:52:21 UTC (rev 47892)
@@ -0,0 +1,120 @@
+-- langno.lua
+-- library for working with luatex's language numbers
+-- glyph nodes have numerical lang field, but the language names for
+-- these numbers aren't saved. 
+--
+-- this library tries to find language names by parsing `language.dat` file
+-- 
+
+local M = {}
+
+local tex = tex or {}
+
+local format = tex.formatname -- or "luatex"
+
+-- languages object
+local lang_obj = function(names, numbers)
+	local obj = {}
+	obj.__index = obj
+	local self = setmetatable({},obj)
+	self.names = names
+	self.numbers = numbers
+	-- get language name by number
+	self.get_name = function(self, number)
+		return self.numbers[number]
+	end
+	-- get language number by name
+	self.get_number = function(self, name)
+		return self.names[name]
+	end
+	return self
+end
+
+
+-- default language loader, language.dat file is parsed
+local load_lang_dat = function(start)
+  -- languages are saved in the file language.dat
+  local lang_dat = kpse.find_file("language.dat")
+  if not lang_dat then 
+    return nil, "Cannot load file language.dat"
+  end
+  local f = io.open(lang_dat, "r")
+  local i = start or 0
+  local numlang = {} -- return language name 
+  local langnum = {} -- return language number
+  for line in f:lines() do
+    -- match comment, equal sign and first word on a line
+    local first, language = line:match("%s*([%%%=]?)([%a]*)")
+    if first ~="%" then  -- ignore comments
+      langnum[language] = i
+      if first ~="=" then -- on lines starting with eq are language synonyms
+        --print(i, language)
+        numlang[i] = language
+        i = i + 1
+      end
+    end
+  end
+  return lang_obj(langnum, numlang)--{numbers = numlang, names = langnum}
+end
+
+local load_lang_dat_lualatex = function()
+  return load_lang_dat(1)
+end
+
+local load_csplain= function()
+	local l = require "luavlna-csplain-langs"
+	local langnum = {}
+	local numlang = {}
+	for k, v in pairs(l) do
+		local first = k:gsub(" *;.*","")
+		--print(first)
+		langnum[first] = v
+		for _,i in ipairs(v) do
+			numlang[i] = first
+		end
+	end
+	return lang_obj(langnum, numlang)
+end
+
+
+-- because different formats may use different ways to load languages
+-- driver mechanism is provided.  
+local drivers = {}
+drivers["lualatex"] = load_lang_dat_lualatex
+drivers["luatex"]  = load_lang_dat
+drivers["default"] = load_lang_dat
+drivers["csplain"] = load_csplain
+drivers["pdfcsplain"] = load_csplain
+drivers["luaplain"] = load_csplain
+
+local load_languages = function(name)
+  local name = name or format
+	print ("Load driver: "..name)
+  local func =  drivers[name] or drivers["default"]
+  if not func then return nil, "Cannot find driver function "..name end
+  return func()
+end
+
+-- only load_languages function is provided to the outside world
+M.load_languages = load_languages
+
+return M
+--[[
+
+-- sample usage:
+local j = load_languages()
+print(j:get_name(16))
+print(j:get_number("slovak"))
+for k, v in pairs(j.numbers) do
+  print(k,v)
+end
+--]]
+
+-- this may be used in future, if I find a way how does local language.dat
+-- affect language loading
+-- load local language.dat
+--[[
+local loc = kpse.var_value('TEXMFLOCAL') .. "tex/generic/config/language.dat"
+local f, msg = io.open(loc, "r")
+f:read("*all")
+--]]


Property changes on: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-langno.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-predegrees.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-predegrees.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-predegrees.lua	2018-05-31 21:52:21 UTC (rev 47892)
@@ -0,0 +1,65 @@
+return {
+  "ak.",
+  "akad.",
+  "arch.",
+  "arm.",
+  "art.",
+  "Bc.",
+  "BcA.",
+  "brig.",
+  "čet.",
+  "des.",
+  "Dipl.-Ing.",
+  "doc.",
+  "dr.",
+  "Dr.",
+  "Dr.-Ing.",
+  "gen.",
+  "genmjr.",
+  "genplk.",
+  "genpor.",
+  "ICDr.",
+  "ing.",
+  "Ing.",
+  "JUDr.",
+  "kpt.",
+  "mal.",
+  "MDDr.",
+  "MgA.",
+  "Mgr.",
+  "mjr.",
+  "MSDr.",
+  "MUDr.",
+  "MVDr.",
+  "npor.",
+  "nprap.",
+  "nrtm.",
+  "nstržm.",
+  "PaedDr.",
+  "PharmDr.",
+  "PhDr.",
+  "PhMr.",
+  "plk.",
+  "por.",
+  "pplk.",
+  "ppor.",
+  "pprap.",
+  "prap.",
+  "prof.",
+  "RCDr.",
+  "RNDr.",
+  "RSDr.",
+  "RTDr.",
+  "rtm.",
+  "rtn.",
+  "soch.",
+  "stržm.",
+  "sv.",
+  "svob.",
+  "šprap.",
+  "št.",
+  "ThDr.",
+  "ThLic.",
+  "ThMgr.",
+  "voj.",
+}


Property changes on: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-predegrees.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-presi.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-presi.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-presi.lua	2018-05-31 21:52:21 UTC (rev 47892)
@@ -0,0 +1,30 @@
+return {
+  "Y",
+  "Yi",
+  "Z",
+  "Zi",
+  "E",
+  "Ei",
+  "P",
+  "Pi",
+  "T",
+  "Ti",
+  "G",
+  "Gi",
+  "M",
+  "Mi",
+  "k",
+  "Ki",
+  "h",
+  "da",
+  "d",
+  "c",
+  "m",
+  "µ",
+  "n",
+  "p",
+  "f",
+  "a",
+  "z",
+  "y",
+}


Property changes on: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-presi.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-si.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-si.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-si.lua	2018-05-31 21:52:21 UTC (rev 47892)
@@ -0,0 +1,38 @@
+return {
+  "A",
+  "b",
+  "B",
+  "Bq",
+  "C",
+  "°C",
+  "cd",
+  "dag",
+  "eV",
+  "F",
+  "°F",
+  "g",
+  "Gy",
+  "H",
+  "Hz",
+  "J",
+  "K",
+  "kat",
+  "kg",
+  "lm",
+  "lx",
+  "m",
+  "mg",
+  "mol",
+  "N",
+  "Pa",
+  "rad",
+  "s",
+  "S",
+  "sr",
+  "Sv",
+  "T",
+  "V",
+  "W",
+  "Wb",
+  "Ω",
+}


Property changes on: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-si.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-sufdegrees.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-sufdegrees.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-sufdegrees.lua	2018-05-31 21:52:21 UTC (rev 47892)
@@ -0,0 +1,21 @@
+return {
+  "BBA",
+  "BLaw",
+  "BPA",
+  "BSc.",
+  "B.Th.",
+  "CSc.",
+  "DiS.",
+  "DSc.",
+  "LL.B.",
+  "LL.M.",
+  "MBA",
+  "MLaw",
+  "MMed.",
+  "MPA",
+  "MSc.",
+  "M.Th.",
+  "PhD.",
+  "Ph.D.",
+  "Th.D.",
+}


Property changes on: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna-sufdegrees.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.4ht
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.4ht	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.4ht	2018-05-31 21:52:21 UTC (rev 47892)
@@ -0,0 +1,5 @@
+\directlua{
+luavlna.set_tex4ht()
+}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.4ht
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua	2018-05-31 21:52:21 UTC (rev 47892)
@@ -0,0 +1,316 @@
+-- Module luavlna
+-- code originally created by Patrick Gundlach
+-- http://tex.stackexchange.com/q/27780/2891
+-- The code was adapted for plain TeX and added some more features
+-- 1. It is possible to turn this functionality only for some letters
+-- 2. Code now works even for single letters after brackets etc.
+--
+local M = {}
+local utf_match = unicode.utf8.match
+local utf_char  = unicode.utf8.char
+local utf_len   = unicode.utf8.len
+
+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 math_id  = node.id "math"
+local period_char = string.byte(".")
+
+local alpha = string.char(37).."a" -- alpha class, entering 
+-- percent char directly caused error
+local alphas = {}
+local match_char = function(x) return utf_match(x,alpha) end
+local match_table = function(x, chars)
+  local chars=chars or {} 
+  return chars[x] 
+end 
+local singlechars = {} -- {a=true,i=true,z=true, v=true, u=true, o = true} 
+
+local initials = {}
+
+local main_language = nil
+
+-- when main_language is set, we will not use lang info in the nodes, but 
+-- main language instead
+local get_language = function(lang)
+  return main_language or lang
+end
+
+local set_main_language = function(lang)
+  main_language = lang
+end
+
+local debug = false
+local tex4ht = false
+-- Enable processing only for certain letters
+-- must be table in the {char = true, char2=true} form
+local set_singlechars= function(lang,c)
+  --print("Set single chars lua")
+  print(type(lang), lang)
+  if type(lang) == "table" then
+    for _,l in pairs(lang) do
+      print("language: ",l)
+      singlechars[l] = c
+    end
+  else
+    local lang = tonumber(lang)
+    print("language: ",lang)
+    -- for k,_ in pairs(c) do print(k) end
+    singlechars[lang] = c
+  end
+end
+
+local set_initials = function(lang,c)
+  if type(lang) == "table" then
+    for _,l in pairs(lang) do
+      initials[l] = c
+    end
+  else
+    local lang = tonumber(lang)
+    initials[lang]=c
+  end
+end
+
+
+local debug_tex4ht = function(head,p)
+  --[[ local w = node.new("glyph")
+  w.lang = tex.lang
+  w.font = font.current()
+  w.char = 64
+  ]]
+  --node.remove(head,node.prev(p))
+  local w = node.new("whatsit", "special")
+  w.data = "t4ht=<span style='background-color:red;width:2pt;'> </span>"
+  return w, head
+end
+
+local debug_node = function(head,p)
+  local w
+  if tex4ht then
+    w, head = debug_tex4ht(head,p)
+  else
+    w = node.new("whatsit","pdf_literal")                          
+    w.data = "q 1 0 1 RG 1 0 1 rg 0 0 m 0 5 l 2 5 l 2 0 l b Q"           
+  end
+  node.insert_after(head,head,w)                                       
+  node.insert_after(head,w,p)                                          
+  -- return w
+end
+
+
+local set_debug= function(x)
+  debug = x
+end
+
+local set_tex4ht = function()
+  tex4ht = true
+end
+
+local insert_penalty = function(head)
+  local p = node.new("penalty")                                           
+  p.penalty = 10000                                                       
+  local debug = debug or false
+  if debug then
+    local w = debug_node(head,p)
+  else
+    node.insert_after(head,head,p) 
+  end
+  return head
+end
+
+local replace_with_thin_space = function(head)
+  local gluenode = node.new(node.id("glue"))
+  local gluespec = node.new(node.id("glue_spec"))
+  gluenode.width = tex.sp("0.2em")
+  -- gluenode.spec = gluespec
+  gluenode.next = head.next
+  gluenode.prev = head.prev
+  gluenode.next.prev = gluenode
+  gluenode.prev.next = gluenode
+  return gluenode
+end
+
+local is_alpha = function(c)
+  local status = alphas[c]
+  if not status then 
+    status = utf_match(c, alpha)
+    alphas[c] = status
+  end
+  return status
+end
+
+-- find whether letter is uppercase
+local up_table = {}
+local is_uppercase= function(c)
+  if not is_alpha(c) then return false end
+  local status = up_table[c]
+  if status ~= nil then
+    return status
+  end
+  status = unicode.utf8.upper(c) == c
+  up_table[c] = status
+  return status
+end
+
+local is_number = function(word)
+  return tonumber(string.sub(word, -1)) ~= nil
+end
+
+local init_buffer = ""
+local is_initial = function(c, lang)
+  return is_uppercase(c)
+end
+
+local cut_off_end_chars = function(word, dot)
+  local last = string.sub(word, -1)
+  while word ~= "" and (not dot or last ~= ".") and not is_alpha(last) do
+    word = string.sub(word, 1, -2) -- remove last char
+    last = string.sub(word, -1)
+  end
+  return word
+end
+
+local part_until_non_alpha = function(word)
+  for i = 1, #word do
+    local c = word:sub(i,i)
+    if not is_alpha(c) then
+      word = string.sub(word, 1, i-1)
+      break
+    end
+  end
+  return word
+end
+
+
+function Set (list)
+  local set = {}
+  for _, l in ipairs(list) do set[l] = true end
+  return set
+end
+
+
+local presi = (require "luavlna-presi")
+local si = Set(require "luavlna-si")
+
+local is_unit = function(word)
+  if M.no_unit==true then return false end
+  word = part_until_non_alpha(word)
+  if si[word] then
+    return true
+  end
+  for _, prefix in pairs(presi) do
+    s, e = string.find(word, prefix)
+    if s == 1 then
+      local unit = string.sub(word, e+1)
+      if si[unit] then
+        return true
+      end
+    end
+  end
+  return false
+end
+
+local predegrees = Set (require "luavlna-predegrees")
+local sufdegrees = Set (require "luavlna-sufdegrees")
+
+local function prevent_single_letter (head)                                   
+  local singlechars = singlechars  -- or {} 
+  -- match_char matches all single letters, but this method is abbandoned
+  -- in favor of using table with enabled letters. With this method, multiple
+  -- languages are supported
+  local test_fn = match_table -- singlechars and match_table or match_char
+  local space = true
+  local init = false
+  local anchor = head
+  local wasnumber = false
+  local word = ""
+  local no_predegrees = M.no_predegrees
+  local no_sufdegrees = M.no_sufdegrees
+  local in_math = false
+  while head do
+    local id = head.id 
+    local nextn = head.next
+    local skip = node.has_attribute(head, luatexbase.attributes.preventsinglestatus) 
+    if id == math_id then
+      if head.subtype == 0 then
+        word = ""
+        in_math = true
+      else
+        in_math = false
+        if is_number(word) then wasnumber = true end
+        word = ""
+      end
+    end
+    if skip ~= 1 and not in_math  then 
+      if id == glue_id then
+        if wasnumber then
+          if word ~= "" then
+            wasnumber = false
+            word = cut_off_end_chars(word, false)
+            if is_unit(word) then
+              anchor = replace_with_thin_space(anchor)
+              insert_penalty(anchor.prev)
+            end
+          end
+        elseif is_number(word) then
+          wasnumber = true
+        else
+          word = cut_off_end_chars(word, true)
+          if no_predegrees ~= true and predegrees[word] then
+            insert_penalty(head.prev)
+          elseif no_sufdegrees ~= true and sufdegrees[word] then
+            insert_penalty(anchor.prev)
+          end
+        end
+        space=true
+        anchor = head
+        word = ""
+        init = is_initial " " -- reset initials
+      elseif space==true and id == glyph_id and is_alpha(utf_char(head.char)) then -- a letter 
+        local lang = get_language(head.lang)
+        local char = utf_char(head.char)
+        word = char
+        init = is_initial(char,lang)
+        local s = singlechars[lang] or {} -- load singlechars for node's lang
+        --[[
+        for k, n in pairs(singlechars) do
+        for c,_ in pairs(n) do
+        --print(type(k), c)
+        end
+        end
+        --]]
+        if test_fn(char, s) and nextn ~= nil and nextn.id == glue_id then    -- only if we are at a one letter word
+          head = insert_penalty(head)
+        end                                                                       
+        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 
+        head = insert_penalty(head)
+      elseif head.id == glyph_id then
+        local char = utf_char(head.char)
+        word = word .. char
+        init = is_initial(char, head.lang)
+        -- hlist support
+      elseif head.id == hlist_id then
+        prevent_single_letter(head.head)
+        -- vlist support
+      elseif head.id == vlist_id then
+        prevent_single_letter(head.head)
+      end              
+    elseif id == glyph_id and in_math then
+      word = word .. utf_char(head.char)
+    end
+    head = head.next                                                            
+  end                                                                             
+  return  true
+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
+return M


Property changes on: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty	2018-05-31 21:52:21 UTC (rev 47892)
@@ -0,0 +1,24 @@
+\ProvidesPackage{luavlna}[2017/09/30 luavlna]
+
+\def\nosingledefaults{\relax}
+\input luavlna 
+
+\def\singlechars#1#2{%
+  \ifcsname l@#1\endcsname%
+    \expandafter\directlua\expandafter{set_singlechars("\the\csname l@#1\endcsname","#2")}%
+  \fi%
+}
+
+% Define compound initials
+\def\compoundinitials#1#2{%
+  \ifcsname l@#1\endcsname%
+    \expandafter\directlua\expandafter{set_compounds("\the\csname l@#1\endcsname","#2")}%
+  \fi%
+}
+
+\AtBeginDocument{%
+  \singlechars{czech}{AIiVvOoUuSsZzKk}
+  \singlechars{slovak}{AIiVvOoUuSsZzKk}
+  \compoundinitials{czech}{Ch,CH}
+}
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/luatex/luavlna/luavlna.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check	2018-05-31 21:51:17 UTC (rev 47891)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2018-05-31 21:52:21 UTC (rev 47892)
@@ -406,7 +406,7 @@
     lualatex-math lualibs
     luamesh luamplib luaotfload luapackageloader
     luasseq luatex85 luatexbase luatexja luatexko luatextra
-    luatodonotes luaxml
+    luatodonotes luavlna luaxml
     lwarp lxfonts ly1 lyluatex
   m-tx macros2e macroswap mafr magaz mailing mailmerge
     make4ht makebarcode makebase makebox makecell makecirc makecmds

Modified: trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc	2018-05-31 21:51:17 UTC (rev 47891)
+++ trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc	2018-05-31 21:52:21 UTC (rev 47892)
@@ -32,6 +32,7 @@
 depend luatexbase
 depend luatexko
 depend luatextra
+depend luavlna
 depend luaxml
 depend nodetree
 depend odsfile

Added: trunk/Master/tlpkg/tlpsrc/luavlna.tlpsrc
===================================================================


More information about the tex-live-commits mailing list