texlive[41957] Master: cstypo (30aug16)

commits+karl at tug.org commits+karl at tug.org
Wed Aug 31 00:09:13 CEST 2016


Revision: 41957
          http://tug.org/svn/texlive?view=revision&revision=41957
Author:   karl
Date:     2016-08-31 00:09:13 +0200 (Wed, 31 Aug 2016)
Log Message:
-----------
cstypo (30aug16)

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

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/lualatex/cstypo/
    trunk/Master/texmf-dist/doc/lualatex/cstypo/LICENSE
    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/
    trunk/Master/texmf-dist/tex/lualatex/cstypo/cstypo.sty
    trunk/Master/texmf-dist/tex/luatex/cstypo/
    trunk/Master/texmf-dist/tex/luatex/cstypo/cstypo-tex.tex
    trunk/Master/texmf-dist/tex/luatex/cstypo/cstypo.lua
    trunk/Master/tlpkg/tlpsrc/cstypo.tlpsrc

Added: trunk/Master/texmf-dist/doc/lualatex/cstypo/LICENSE
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/cstypo/LICENSE	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/lualatex/cstypo/LICENSE	2016-08-30 22:09:13 UTC (rev 41957)
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2016 Václav Haisman
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

Added: trunk/Master/texmf-dist/doc/lualatex/cstypo/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/cstypo/README.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/lualatex/cstypo/README.md	2016-08-30 22:09:13 UTC (rev 41957)
@@ -0,0 +1,11 @@
+# cstypo
+
+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.


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

Index: trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypo.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypo.pdf	2016-08-30 22:08:00 UTC (rev 41956)
+++ trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypo.pdf	2016-08-30 22:09:13 UTC (rev 41957)

Property changes on: trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypo.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypo.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypo.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypo.tex	2016-08-30 22:09:13 UTC (rev 41957)
@@ -0,0 +1,114 @@
+\documentclass[paper=B5,DIV=calc,parskip=half]{scrartcl}
+\usepackage{ifluatex}
+
+\usepackage{fontspec}
+%\defaultfontfeatures{Ligatures={TeX,Common},Scale=MatchLowercase}
+\setmainfont[]{Charis SIL}
+\setsansfont[Ligatures={TeX,Common}, Scale=MatchLowercase]{TeX Gyre Heros}
+\setmonofont[Ligatures=,Scale=MatchLowercase]{DejaVu Sans Mono}
+
+\usepackage{listings}
+\usepackage{enumitem}
+%\usepackage{enumitem-zref}
+\usepackage{polyglossia}
+\setmainlanguage[]{english}
+
+\author{Václav Haisman\texorpdfstring{%
+    \\{\small\href{mailto:vhaisman+cstypo at gmail.com?subject=[cstypo]}{vhaisman at gmail.com}}}{}}
+\date{\today}
+\title{\texttt{cstypo} user manual}
+
+\PassOptionsToPackage{unicode}{hyperref}
+\usepackage{bookmark}
+\usepackage{xcolor}
+\hypersetup{
+  colorlinks,
+  linkcolor={red!50!black},
+  citecolor={blue!50!black},
+  urlcolor={blue!80!black},
+  breaklinks=true}
+\urlstyle{same}  % don't use monospace font for urls
+
+\usepackage{microtype}
+\usepackage{metalogo}
+
+\setlength{\emergencystretch}{3em}  % prevent overfull lines
+
+\lstdefinestyle{myLatexStyle}{
+  language=[LaTeX]{Tex},
+  basicstyle=\ttfamily
+}
+
+
+\begin{document}
+\begin{titlepage}
+  \maketitle  
+\end{titlepage}
+
+\tableofcontents
+
+\section{Introduction}
+The \href{https://www.ctan.org/pkg/cstypo}{\texttt{cstypo}}\footnote{Source
+  code is on GitHub in
+  \href{https://github.com/wilx/cstypo}{\texttt{wilx/cstypo}} repository.}
+package provides macros that enforce basic Czech typography rules through Lua
+hooks available in \LuaTeX{}.
+
+\begin{enumerate}%[name=rulesList]
+\item\label{itm:singleletter} There should be no line break between single
+  letter preprosition and single letter conjugations and word following them.
+\item\label{itm:percents} There should be no line break between number and \%
+  symbol.
+\end{enumerate}
+
+There are obviously more rules than these two but only the above rules are
+enforcable through this package.
+
+\section{User interface}
+
+The following two macros allow to enable and disable hook that enforces
+penalization of line breaks after single letter words:
+%(\refitem{rulesList{itm:singleletter}):
+
+\begin{lstlisting}[style=myLatexStyle]
+\cstypoSingleLetterEnable
+\cstypoSingleLetterDisable
+\end{lstlisting}
+
+The following two macros allow to enable and disable hook that enforces the
+same rule as above but for ‘a’ conjugation. The reason that this is separete
+from the rest of the single letter prepositions and conjugations is that line
+break after ‘a’ is tolerated for narrow column texts. It might be desirable
+to have this rule enforced for all of the single letter words except for the
+‘a’.
+
+\begin{lstlisting}[style=myLatexStyle]
+\cstypoALetterEnable
+\cstypoALetterDisable
+\end{lstlisting}
+
+The following two macros allow to enable and disable hook that enforces
+penalization of line breaks between number and \% symbol.
+
+\begin{lstlisting}[style=myLatexStyle]
+\cstypoPercentsEnable
+\cstypoPercentsDisable
+\end{lstlisting}
+
+\section{History}
+
+This package was inspired by
+\texttt{\href{http://www.ctan.org/pkg/impnattypo}{impnattypo}} French
+typography package. It would not be possible without help and comments from
+people of
+\href{http://chat.stackexchange.com/rooms/41/tex-latex-and-friends}{\TeX{},
+  \LaTeX{} and Friends} StackExchange chat room and the
+\href{http://tex.stackexchange.com/}{\TeX.SE} site itself.
+
+\begin{description}[style=nextline, labelwidth=4.5em, leftmargin=!, labelindent=0em]
+\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.
+\end{description}
+
+\end{document}


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

Index: trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.pdf	2016-08-30 22:08:00 UTC (rev 41956)
+++ trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.pdf	2016-08-30 22:09:13 UTC (rev 41957)

Property changes on: trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.tex	2016-08-30 22:09:13 UTC (rev 41957)
@@ -0,0 +1,80 @@
+\documentclass{article}
+\usepackage{lmodern}
+\usepackage{ifluatex}
+\usepackage[a6paper]{geometry}
+\usepackage{parskip}
+\usepackage{polyglossia}
+\setmainlanguage[]{czech}
+\setotherlanguage{english}
+\usepackage{microtype}
+
+\setlength{\emergencystretch}{3em}  % prevent overfull lines
+\newcommand{\expl}[1]{\begin{english}\sffamily #1\end{english}}
+
+\usepackage{cstypo}
+
+\begin{document}
+\section{Bad line breaks}
+\expl{The follwing text has prepostions `O' and `k' at end of line which
+  is incorrect according to Czech language typography standards:}
+
+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.}
+
+\expl{The follwing text is the same as above but parentheses are used to test
+  that a preposition stay (or not stay, in this case) with following word
+  even if the prepostion is preceeded with a parenthesis:}
+
+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).}
+
+\expl{Next line shows bad line break between number and the \% symbol.}
+
+Se správným nastavením fontů znak \% v `na 100 \%' skončí na další řádce.
+
+\section{Better line breaks}
+\expl{And here we add Lua code to penalize single letter words. It results in
+following line layout:}
+
+\cstypoSingleLetterEnable{}
+\cstypoPercentsEnable{}
+\cstypoALetterEnable{}
+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.}
+
+\expl{The follwing text is the same as above but parentheses are used to test
+  that a preposition stay with following word even if the prepostion is
+  preceeded with a parenthesis:}
+
+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).}
+
+\expl{Here, the \% symbol should be together with the number.}
+
+Se správným nastavením fontů znak \% v `na 100 \%' skončí na další řádce.
+
+\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.}
+
+\cstypoSingleLetterDisable{}
+\cstypoPercentsDisable{}
+\cstypoALetterDisable{}
+
+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.}
+
+\expl{The follwing text is the same as above but parentheses are used to test
+  that a preposition stay (or not stay, in this case) with following word
+  even if the prepostion is preceeded with a parenthesis:}
+
+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).}
+
+\expl{And here, line break is inserted before the \% symbol again.}
+
+Se správným nastavením fontů znak \% v `na 100 \%' skončí na další řádce.
+
+
+
+\end{document}


Property changes on: trunk/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/lualatex/cstypo/cstypo.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/cstypo/cstypo.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/lualatex/cstypo/cstypo.sty	2016-08-30 22:09:13 UTC (rev 41957)
@@ -0,0 +1,30 @@
+% LaTeX package to enforce some basic Czech language typography
+% rules. Requires LuaLaTeX.
+%
+% (c) 2016 Václav Haisman
+%
+%% This program can be redistributed and/or modified under the terms of the
+%% MIT license. See LICENSE file.
+%
+\NeedsTeXFormat{LaTeX2e}[1994/06/01]
+\ProvidesPackage{cstypo}
+  [2016/08/30 v0.02 LaTeX package to enforce some basic Czech language
+  typography rules. Requires Lua(La)TeX.]
+
+\RequirePackage{ifluatex}
+
+\ifluatex
+\input{cstypo-tex}
+\else
+\PackageError{cstypo}{%
+  This requires LuaTeX or LuaLaTeX
+}{%
+  Compile this with LuaTeX or LuaLaTeX.
+}
+
+\fi
+
+\endinput
+
+%%
+%% End of file `cstypo.sty'.


Property changes on: trunk/Master/texmf-dist/tex/lualatex/cstypo/cstypo.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/luatex/cstypo/cstypo-tex.tex
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/cstypo/cstypo-tex.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/luatex/cstypo/cstypo-tex.tex	2016-08-30 22:09:13 UTC (rev 41957)
@@ -0,0 +1,16 @@
+\directlua{require('cstypo')}
+
+\long\def\cstypoSingleLetterEnable{%
+  \directlua{cstypo_single_letter_enable()}}
+\long\def\cstypoSingleLetterDisable{%
+  \directlua{cstypo_single_letter_disable()}}
+
+\long\def\cstypoALetterEnable{%
+  \directlua{cstypo_a_letter_enable()}}
+\long\def\cstypoALetterDisable{%
+  \directlua{cstypo_a_letter_disable()}}
+
+\long\def\cstypoPercentsEnable{%
+  \directlua{cstypo_percents_enable()}}
+\long\def\cstypoPercentsDisable{%
+  \directlua{cstypo_percents_disable()}}


Property changes on: trunk/Master/texmf-dist/tex/luatex/cstypo/cstypo-tex.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/luatex/cstypo/cstypo.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/cstypo/cstypo.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/luatex/cstypo/cstypo.lua	2016-08-30 22:09:13 UTC (rev 41957)
@@ -0,0 +1,128 @@
+--[[--
+(c) 2016 Václav Haisman
+
+This program can be redistributed and/or modified under the terms of the MIT
+license. See LICENSE file.
+--]]--
+
+local GLYPH = node.id("glyph")
+--print('GLYPH value: ', GLYPH)
+
+local GLUE = node.id("glue")
+--print('GLUE value: ', GLUE)
+
+
+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
+      -- 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
+        if ((head.prev.id == GLUE
+             -- or one of '{[('
+               or (head.prev.id == GLYPH
+                     and unicode.utf8.match(unicode.utf8.char(head.prev.char),
+                                            "[%[%]()%{%}]")))
+          -- and right of the one letter word is also a space
+          and head.next.id == GLUE) then
+          -- then avoid line break between the single letter word and the
+          -- word following it
+          local p = node.new("penalty")
+          p.penalty = 10000
+          node.insert_after(head, head, p)
+          --print('inserting penalty at ', head)
+        end
+      end
+    end
+    head = head.next
+  end
+  return true
+end
+
+function cstypo_single_letter_enable ()
+  print('cstypo: Enabling single letter hook.')
+  luatexbase.add_to_callback("pre_linebreak_filter", prevent_single_letter,
+                             "cstyposingleletter")
+end
+
+function cstypo_single_letter_disable ()
+  print('cstypo: Disabling single letter hook.')
+  luatexbase.remove_from_callback("pre_linebreak_filter", "cstyposingleletter")
+end
+
+
+local function prevent_a_letter (head)
+  while head do
+    -- glyph
+    if head.id == GLYPH then
+      -- only if we are at one letter word
+      if unicode.utf8.match(unicode.utf8.char(head.char), "[aA]") then
+        -- and previous is space
+        if ((head.prev.id == GLUE
+             -- or previous is one of '{[('
+               or (head.prev.id == GLYPH
+                     and unicode.utf8.match(unicode.utf8.char(head.prev.char),
+                                            "[%[%]()%{%}]")))
+          -- and right of the one letter word is also a space
+          and head.next.id == GLUE) then
+          -- then avoid line break between the single letter word and the
+          -- word 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_a_letter_enable ()
+  print('cstypo: Enabling \'a\' letter hook.')
+  luatexbase.add_to_callback("pre_linebreak_filter", prevent_a_letter,
+                             "cstypoaletter")
+end
+
+function cstypo_a_letter_disable ()
+  print('cstypo: Disabling \'a\' letter hook.')
+  luatexbase.remove_from_callback("pre_linebreak_filter", "cstypoaletter")
+end
+
+
+local function prevent_percents (head)
+  while head do
+    -- glyph
+    if head.id == GLYPH then
+      -- only if we are at percentage sign
+      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.
+              and head.prev.prev.id == GLYPH
+              and unicode.utf8.match(unicode.utf8.char(head.prev.prev.char),
+                                     "[0-9]")) then
+          local p = node.new("penalty")
+          p.penalty = 10000
+          node.insert_after(head.prev.prev, head.prev.prev, p)
+        end
+      end
+    end
+    head = head.next
+  end
+  return true
+end
+
+function cstypo_percents_enable()
+  print('cstypo: Enabling percents hook.')
+  luatexbase.add_to_callback("pre_linebreak_filter", prevent_percents,
+                             "cstypopercents")
+end
+
+function cstypo_percents_disable()
+  print('cstypo: Disabling percents hook.')
+  luatexbase.remove_from_callback("pre_linebreak_filter", "cstypopercents")
+end


Property changes on: trunk/Master/texmf-dist/tex/luatex/cstypo/cstypo.lua
___________________________________________________________________
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	2016-08-30 22:08:00 UTC (rev 41956)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2016-08-30 22:09:13 UTC (rev 41957)
@@ -173,7 +173,7 @@
     cprotect cquthesis
     crbox crimson crop
     crossreference crossrefware crossword crosswrd cryptocode cryst
-    cs csbulletin cslatex csplain csquotes csquotes-de csvsimple cstex
+    cs csbulletin cslatex csplain csquotes csquotes-de cstypo csvsimple cstex
     ctan_chk ctanify ctanupload ctable ctablestack ctex ctex-faq
     cursolatex cuisine
     currfile currvita curve curve2e curves

Modified: trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc	2016-08-30 22:08:00 UTC (rev 41956)
+++ trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc	2016-08-30 22:09:13 UTC (rev 41957)
@@ -8,6 +8,7 @@
 depend checkcites
 depend chickenize
 depend cloze
+depend cstypo
 depend ctablestack
 depend enigma
 depend interpreter

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


More information about the tex-live-commits mailing list