texlive[41986] Master/texmf-dist: cstypo (3sep16)

commits+karl at tug.org commits+karl at tug.org
Sat Sep 3 23:36:23 CEST 2016


Revision: 41986
          http://tug.org/svn/texlive?view=revision&revision=41986
Author:   karl
Date:     2016-09-03 23:36:23 +0200 (Sat, 03 Sep 2016)
Log Message:
-----------
cstypo (3sep16)

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

Modified: trunk/Master/texmf-dist/doc/lualatex/cstypo/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/cstypo/README.md	2016-09-03 21:36:10 UTC (rev 41985)
+++ trunk/Master/texmf-dist/doc/lualatex/cstypo/README.md	2016-09-03 21:36:23 UTC (rev 41986)
@@ -1,11 +1,9 @@
 # cstypo
 
-This package provides macros for Czech language typography rules using
-Lua(La)TeX.
+This package provides macros for Czech language typography rules using Lua(La)TeX.
 
 - License is MIT license. See `LICENSE` file.
 
 - Author is [Václav Haisman](mailto:vhaisman+cstypo at gmail.com?subject=[cstypo])
 
-- Source code on GitHub in [`wilx/cstypo`](https://github.com/wilx/cstypo)
-  repository.
+- Source code on GitHub in [`wilx/cstypo`](https://github.com/wilx/cstypo) repository.

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

Modified: trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypo.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypo.tex	2016-09-03 21:36:10 UTC (rev 41985)
+++ trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypo.tex	2016-09-03 21:36:23 UTC (rev 41986)
@@ -13,6 +13,12 @@
 \usepackage{polyglossia}
 \setmainlanguage[]{english}
 
+\usepackage{newunicodechar}
+\newunicodechar{℃}{{°C}}
+\newunicodechar{℉}{{°F}}
+
+\usepackage[autostyle]{csquotes}
+
 \author{Václav Haisman\texorpdfstring{%
     \\{\small\href{mailto:vhaisman+cstypo at gmail.com?subject=[cstypo]}{vhaisman at gmail.com}}}{}}
 \date{\today}
@@ -66,6 +72,9 @@
 
 \section{User interface}
 
+Czech typography rules, when enabled by the following macros, are only
+enforced on text marked as Czech by \texttt{polyglossia} or \texttt{babel}.
+
 The following two macros allow to enable and disable hook that enforces
 penalization of line breaks after single letter words:
 %(\refitem{rulesList{itm:singleletter}):
@@ -88,7 +97,9 @@
 \end{lstlisting}
 
 The following two macros allow to enable and disable hook that enforces
-penalization of line breaks between number and \% symbol.
+penalization of line breaks between number and \enquote*{\%} symbol and also
+few more symbols: per thousand~\enquote*{‰}, degree~\enquote*{°}, degree
+Celsius~\enquote*{℃} and degree Fahrenheit~\enquote*{℉}.
 
 \begin{lstlisting}[style=myLatexStyle]
 \cstypoPercentsEnable
@@ -95,6 +106,15 @@
 \cstypoPercentsDisable
 \end{lstlisting}
 
+The following two macros allow to enable and disable hook that enforces
+penalization of line breaks between~\enquote*{§} symbol and following number.
+
+\begin{lstlisting}[style=myLatexStyle]
+\cstypoParagraphEnable
+\cstypoParagraphDisable
+\end{lstlisting}
+
+
 \section{History}
 
 This package was inspired by
@@ -106,6 +126,10 @@
 \href{http://tex.stackexchange.com/}{\TeX.SE} site itself.
 
 \begin{description}[style=nextline, labelwidth=4.5em, leftmargin=!, labelindent=0em]
+\item[\texttt{v0.03}] Limit Czech typography rules enforcement only to text
+  marked as Czech language. Handle per thousand~\enquote*{‰},
+  degree~\enquote*{°}, degree Celsius~\enquote*{℃}, degree
+  Fahrenheit~\enquote*{℉} and paragraph~\enquote*{§} symbols.
 \item[\texttt{v0.02}] Fixed some packaging and documentation issues found by
   CTAN submission review.
 \item[\texttt{v0.01}] First published version of this package.

Modified: trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.tex	2016-09-03 21:36:10 UTC (rev 41985)
+++ trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.tex	2016-09-03 21:36:23 UTC (rev 41986)
@@ -32,6 +32,23 @@
 
 Se správným nastavením fontů znak \% v `na 100 \%' skončí na další řádce.
 
+\expl{Next line is similar as the one above but tests behaviour for the ‰
+  character.}
+
+Zde, v České republice, stále není povoleno ani 1 ‰ alkoholu v krvi při
+řízení automobilu.
+
+\expl{Next line shows bad line break between degree sign `°' and number.}
+
+Součet všech tří úhlů v trojůhelníku je vždy 180 °.
+
+Voda taje při teplotě 0 ℃ a vypařuje se při 100 ℃.
+
+\expl{Next line show use of ``paragraf'' symbol. It should be kept with the
+  following number.}
+
+Jak může státní zástupce věc odložit zmiňuje § 159a.
+
 \section{Better line breaks}
 \expl{And here we add Lua code to penalize single letter words. It results in
 following line layout:}
@@ -39,6 +56,7 @@
 \cstypoSingleLetterEnable{}
 \cstypoPercentsEnable{}
 \cstypoALetterEnable{}
+\cstypoParagraphEnable{}
 Mezi oblíbené dětské pohádky patří pohádky \emph{O Palečkovi, Alenka v říši
   divů} a \emph{Socialismem k lepším zítřkům.}
 
@@ -53,6 +71,50 @@
 
 Se správným nastavením fontů znak \% v `na 100 \%' skončí na další řádce.
 
+\expl{Next line is similar as the one above but tests behaviour for the ‰
+  character.}
+
+Zde, v České republice, stále není povoleno ani 1 ‰ alkoholu v krvi při
+řízení automobilu.
+
+\expl{Next line shows line break between degree sign `°' and number. The
+  degree sign should stay with the number.}
+
+Součet všech tří úhlů v trojůhelníku je vždy 180 °.
+
+Voda taje při teplotě 0 ℃ a vypařuje se při 100 ℃.
+
+\expl{Next line show use of ``paragraf'' symbol. It should be kept with the
+  following number.}
+
+Jak může státní zástupce věc odložit zmiňuje § 159a.
+
+
+\section{Bad line breaks because of English}
+\expl{This section shows that while the hooks are still active, the actual
+  Czech language text is marked as English which results in bad line breaks.}
+
+\begin{english}
+Mezi oblíbené dětské pohádky patří pohádky \emph{O Palečkovi, Alenka v říši
+  divů} a \emph{Socialismem k lepším zítřkům.}
+
+Mezi oblíbené dětské pohádky patří pohádky \emph{[O Palečkovi], Alenka v říši
+  divů} a \emph{Socialismem (k lepším zítřkům).}
+
+Se správným nastavením fontů znak \% v `na 100 \%' skončí na další řádce.
+
+Zde, v České republice, stále není povoleno ani 1 ‰ alkoholu v krvi při
+řízení automobilu.
+
+Součet všech tří úhlů v trojůhelníku je vždy 180 °.
+
+Voda taje při teplotě 0 ℃ a vypařuje se při 100 ℃.
+
+Jak může státní zástupce věc odložit zmiňuje § 159a.
+
+\end{english}
+
+
 \section{Bad line breaks again}
 \expl{This section shows that disabling of the hook works and that the
   prepositions are again left at the end of their line.}
@@ -60,6 +122,7 @@
 \cstypoSingleLetterDisable{}
 \cstypoPercentsDisable{}
 \cstypoALetterDisable{}
+\cstypoParagraphDisable{}
 
 Mezi oblíbené dětské pohádky patří pohádky \emph{O Palečkovi, Alenka v říši
   divů} a \emph{Socialismem k lepším zítřkům.}
@@ -75,6 +138,21 @@
 
 Se správným nastavením fontů znak \% v `na 100 \%' skončí na další řádce.
 
+\expl{Next line is similar as the one above but tests behaviour for the ‰
+  character.}
 
+Zde, v České republice, stále není povoleno ani 1 ‰ alkoholu v krvi při
+řízení automobilu.
 
+\expl{Next line shows bad line break between degree sign `°' and number.}
+
+Součet všech tří úhlů v trojůhelníku je vždy 180 °.
+
+Voda taje při teplotě 0 ℃ a vypařuje se při 100 ℃.
+
+\expl{Next line show use of ``paragraf'' symbol. It should be kept with the
+  following number.}
+
+Jak může státní zástupce věc odložit zmiňuje § 159a.
+
 \end{document}

Modified: trunk/Master/texmf-dist/tex/lualatex/cstypo/cstypo.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/cstypo/cstypo.sty	2016-09-03 21:36:10 UTC (rev 41985)
+++ trunk/Master/texmf-dist/tex/lualatex/cstypo/cstypo.sty	2016-09-03 21:36:23 UTC (rev 41986)
@@ -8,12 +8,27 @@
 %
 \NeedsTeXFormat{LaTeX2e}[1994/06/01]
 \ProvidesPackage{cstypo}
-  [2016/08/30 v0.02 LaTeX package to enforce some basic Czech language
+  [2016/08/31 v0.03 LaTeX package to enforce some basic Czech language
   typography rules. Requires Lua(La)TeX.]
 
 \RequirePackage{ifluatex}
 
 \ifluatex
+
+\makeatletter
+\ifcsname l at czech\endcsname
+\PackageInfo{cstypo}{%
+  Czech language ID is \the\l at czech
+}
+\else
+\PackageError{cstypo}{%
+  \protect\l at czech\space is not defined
+}{%
+  Include cstypo package after polyglossia or babel.
+}
+\fi
+\makeatother
+
 \input{cstypo-tex}
 \else
 \PackageError{cstypo}{%

Modified: trunk/Master/texmf-dist/tex/luatex/cstypo/cstypo-tex.tex
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/cstypo/cstypo-tex.tex	2016-09-03 21:36:10 UTC (rev 41985)
+++ trunk/Master/texmf-dist/tex/luatex/cstypo/cstypo-tex.tex	2016-09-03 21:36:23 UTC (rev 41986)
@@ -1,3 +1,6 @@
+\catcode`\@=11
+\directlua{cstypo_czech_language_id = \the\l at czech}
+\catcode`\@=12
 \directlua{require('cstypo')}
 
 \long\def\cstypoSingleLetterEnable{%
@@ -14,3 +17,8 @@
   \directlua{cstypo_percents_enable()}}
 \long\def\cstypoPercentsDisable{%
   \directlua{cstypo_percents_disable()}}
+
+\long\def\cstypoParagraphEnable{%
+  \directlua{cstypo_paragraph_enable()}}
+\long\def\cstypoParagraphDisable{%
+  \directlua{cstypo_paragraph_disable()}}

Modified: trunk/Master/texmf-dist/tex/luatex/cstypo/cstypo.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/cstypo/cstypo.lua	2016-09-03 21:36:10 UTC (rev 41985)
+++ trunk/Master/texmf-dist/tex/luatex/cstypo/cstypo.lua	2016-09-03 21:36:23 UTC (rev 41986)
@@ -11,13 +11,16 @@
 local GLUE = node.id("glue")
 --print('GLUE value: ', GLUE)
 
+local CZECH_ID = cstypo_czech_language_id
+--print('CZECH_ID value: ', CZECH_ID)
 
 local function prevent_single_letter (head)
-  --print('prevent_single_letter hook is executing', head)
   while head do
     -- glyph
-    --print('inside prevent_single_letter loop, head.id: ', head.id)
-    if head.id == GLYPH then
+    if (head.id == GLYPH
+        -- and in Czech or unspecified (???)
+          and (head.lang == nil
+               or head.lang == CZECH_ID)) then
       -- only if we are at one letter word
       if unicode.utf8.match(unicode.utf8.char(head.char), "[zZsSuUkKoOvViI]") then
         -- and left of it is either a space
@@ -57,7 +60,10 @@
 local function prevent_a_letter (head)
   while head do
     -- glyph
-    if head.id == GLYPH then
+    if (head.id == GLYPH
+        -- and in Czech or unspecified (???)
+          and (head.lang == nil
+               or head.lang == CZECH_ID)) then
       -- only if we are at one letter word
       if unicode.utf8.match(unicode.utf8.char(head.char), "[aA]") then
         -- and previous is space
@@ -96,9 +102,12 @@
 local function prevent_percents (head)
   while head do
     -- glyph
-    if head.id == GLYPH then
+    if (head.id == GLYPH
+        -- and in Czech or unspecified (???)
+          and (head.lang == nil
+               or head.lang == CZECH_ID)) then
       -- only if we are at percentage sign
-      if unicode.utf8.match(unicode.utf8.char(head.char), "%%") then
+      if unicode.utf8.match(unicode.utf8.char(head.char), "[%%‰°℃℉]") then
         -- and left of it is a space
         if (head.prev.id == GLUE
             -- and left of the space is a digit.
@@ -126,3 +135,42 @@
   print('cstypo: Disabling percents hook.')
   luatexbase.remove_from_callback("pre_linebreak_filter", "cstypopercents")
 end
+
+
+local function prevent_paragraph (head)
+  while head do
+    -- glyph
+    if (head.id == GLYPH
+        -- and in Czech or unspecified (???)
+          and (head.lang == nil
+               or head.lang == CZECH_ID)) then
+      -- only if we are at paragraph symbol
+      if unicode.utf8.match(unicode.utf8.char(head.char), "[§]") then
+        -- and right of it is a space
+        if (head.next.id == GLUE
+              and (head.next.next.id == GLYPH
+                     and unicode.utf8.match(unicode.utf8.char(head.next.next.char),
+                                            "[0-9]"))) then
+          -- then avoid line break between the paragraph and the number
+          -- following it
+          local p = node.new("penalty")
+          p.penalty = 10000
+          node.insert_after(head, head, p)
+        end
+      end
+    end
+    head = head.next
+  end
+  return true
+end
+
+function cstypo_paragraph_enable()
+  print('cstypo: Enabling paragraph hook.')
+  luatexbase.add_to_callback("pre_linebreak_filter", prevent_paragraph,
+                             "cstypoparagraph")
+end
+
+function cstypo_paragraph_disable()
+  print('cstypo: Disabling paragraph hook.')
+  luatexbase.remove_from_callback("pre_linebreak_filter", "cstypoparagraph")
+end



More information about the tex-live-commits mailing list