\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}

\usepackage{newunicodechar}
\newunicodechar{℃}{{°C}}
\newunicodechar{℉}{{°F}}

\usepackage[autostyle]{csquotes}

\author{Václav Haisman\texorpdfstring{%
    \\{\small\href{mailto:vhaisman+cstypo@gmail.com?subject=[cstypo]}{vhaisman@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}

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}):

\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 \enquote*{\%} symbol and also
few more symbols: per thousand~\enquote*{‰}, degree~\enquote*{°}, degree
Celsius~\enquote*{℃} and degree Fahrenheit~\enquote*{℉}.

\begin{lstlisting}[style=myLatexStyle]
\cstypoPercentsEnable
\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
\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.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.
\end{description}

\end{document}
