From d3fd3960d8402d6f9621d35febef86b241808d99 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 29 Jul 2021 03:00:44 +0000 Subject: CTAN sync 202107290300 --- macros/latex/contrib/lipsum/CHANGELOG.md | 12 ++- macros/latex/contrib/lipsum/DEPENDS.txt | 1 + macros/latex/contrib/lipsum/lipsum.dtx | 125 ++++++++++++++++++++++++------- macros/latex/contrib/lipsum/lipsum.pdf | Bin 644963 -> 650355 bytes 4 files changed, 111 insertions(+), 27 deletions(-) (limited to 'macros/latex/contrib/lipsum') diff --git a/macros/latex/contrib/lipsum/CHANGELOG.md b/macros/latex/contrib/lipsum/CHANGELOG.md index a9010903f4..379801f73f 100644 --- a/macros/latex/contrib/lipsum/CHANGELOG.md +++ b/macros/latex/contrib/lipsum/CHANGELOG.md @@ -3,7 +3,17 @@ All notable changes to the `lipsum` bundle since mid-2021 will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -this project uses date-based 'snapshot' version identifiers. +and this project uses major+minor version identifiers. + +## [v2.5] + +### Fixed +- Language 'latin' undefined error with LuaTeX (gh/6). + +### Changed +- Require `babel` for language-specific hyphenation patterns (gh/6). +- In case a language is unknown, just warn instead of an error (gh/8). +- Use `\par` by default in `par-sep` rather than `par-end` (gh/7). ## [v2.4] diff --git a/macros/latex/contrib/lipsum/DEPENDS.txt b/macros/latex/contrib/lipsum/DEPENDS.txt index 574e1c1ca4..df6e9d50dd 100644 --- a/macros/latex/contrib/lipsum/DEPENDS.txt +++ b/macros/latex/contrib/lipsum/DEPENDS.txt @@ -1 +1,2 @@ hard l3kernel +soft babel diff --git a/macros/latex/contrib/lipsum/lipsum.dtx b/macros/latex/contrib/lipsum/lipsum.dtx index 8a20f78de8..6371737414 100644 --- a/macros/latex/contrib/lipsum/lipsum.dtx +++ b/macros/latex/contrib/lipsum/lipsum.dtx @@ -15,8 +15,8 @@ % Please send error reports and suggestions for improvements to % https://github.com/PhelypeOleinik/lipsum % -\def\lipsumversion{2.4} -\def\lipsumdate{2021-06-03} +\def\lipsumversion{2.5} +\def\lipsumdate{2021-07-28} %<*driver> \ProvidesFile{lipsum.dtx}% [\lipsumdate\space v\lipsumversion\space @@ -467,6 +467,12 @@ % disable automatic language switching with % |\setlipsum{auto-lang=false}|. % +% \pkg{lipsum} relies on \pkg{babel}'s \cs{hyphenrules} command to +% change the hyphenation patterns, thus it requires \pkg{babel} to be +% loaded in the document if |auto-lang=true|. If \pkg{babel} is not +% loaded, a warning is printed and the default language is used for +% hyphenation instead. +% % The language is defined individually for each dummy text % \secref{sec:other-texts}, but you may change it for the current dummy % text by using |\setlipsum{language=|\meta{lang}|}|. If you load @@ -1252,29 +1258,29 @@ % % \begin{macro}{\@@_set_hyphens:,\@@_restore_hyphens:} % Selects the hyphenation patterns for the language of the dummy text, -% using \pkg{babel}'s \cs{hyphenrules} if that's defined (when -% \pkg{babel} is loaded) or using \cs{language}\cs{l@\meta{lang}} -% otherwise. The hyphenation patterns are properly restored by +% using \pkg{babel}'s \cs{hyphenrules} if that's defined. +% If \cs{hyphenrules} doesn't exist (thus \pkg{babel} not loaded), +% call \cs{@@_set_hyphens_babel_missing:} which will behave in a +% slightly different way if encountered in the preamble or in the +% document body. The hyphenation patterns are properly restored by % \cs{@@_restore_hypehens:} when the text ends. % \begin{macrocode} \cs_new_protected:Npn \@@_set_hyphens: { \bool_if:NTF \l_@@_autolang_bool - { \use:x } { \use_none:n } + { \use:n } { \use_none:n } { \cs_if_exist:NTF \hyphenrules - { - \exp_not:N \hyphenrules { \g_@@_language_tl } - \cs_set_protected:Npn \@@_restore_hyphens: - { \exp_not:N \hyphenrules { \languagename } } - } { \cs_if_exist:cTF { l@ \g_@@_language_tl } - { \language \use:c { l@ \g_@@_language_tl } } - { \msg_error:nn { lipsum } { language-undefined } } - \cs_set_protected:Npn \@@_restore_hyphens: - { \language \int_eval:n { \language } \scan_stop: } + { + \exp_args:NV \hyphenrules \g_@@_language_tl + \cs_set_protected:Npx \@@_restore_hyphens: + { \exp_not:N \hyphenrules { \languagename } } + } + { \@@_missing_language_warning: } } + { \@@_set_hyphens_babel_missing: } } } \cs_new_protected:Npn \@@_restore_hyphens: @@ -1282,6 +1288,48 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\@@_set_hyphens_babel_missing:} +% In the document preamble this emits a warning telling the user that +% the proper hyphenations can't be used because \pkg{babel} isn't +% loaded, then shut up for the rest of the preamble. In the document +% body however, this is more serious, so we give a final warning and +% deactivate automatic hyphenation setting. +% \begin{macrocode} +\cs_new_protected:Npn \@@_set_hyphens_babel_missing: + { + \msg_warning:nnn { lipsum } { missing-babel } { preamble } + \cs_gset_eq:NN \@@_set_hyphens_babel_missing: \prg_do_nothing: + } +\AtBeginDocument + { + \cs_gset_protected:Npx \@@_set_hyphens_babel_missing: + { + \@ifpackageloaded { babel } + { \msg_error:nnn { lipsum } { missing-babel } { impossible } } + { \msg_warning:nnn { lipsum } { missing-babel } { document } } + \setlipsum { auto-lang = false } + } + } +\cs_if_exist:NT \DeclareHookRule + { \DeclareHookRule { begindocument } { lipsum } { after } { babel } } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_missing_language_warning:} +% Warn the user about an unknown/missing language. Most of the time +% the issue is a minimal installation that doesn't have Latin, but +% sometimes it may be a typo. Regardless of the case, warn the user +% then change the lanugage to \cs{languagename} so the warning appears +% only once, at least until it is changed again. +% \begin{macrocode} +\cs_new_protected:Npn \@@_missing_language_warning: + { + \msg_warning:nn { lipsum } { missing-language } + \tl_gset_eq:NN \g_@@_language_tl \languagename + } +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\NewLipsumPar} % Developer-Level macro to add a paragraph to the dummy text used by % \cs{lipsum} and related commands. To specify a new dummy text, see @@ -1333,22 +1381,22 @@ % \LipsumRestoreSentenceList, % \LipsumRestoreAll, % } -% \begin{macro}{\@@_delim_restore:nnnnn} +% \begin{macro}{\@@_delim_restore:nnn} % \begin{macro}{\@@_restore_par_list:,\@@_restore_sentence_list:} % These are some auxiliaries for the package options and for setting % up the default behaviour. % \begin{macrocode} -\cs_new_protected:Npn \@@_delim_restore:nnnnn #1 #2 #3 #4 #5 +\cs_new_protected:Npn \@@_delim_restore:nnn #1 #2 #3 { \keys_set:nn { lipsum } { - #1-before = , #1-begin = , #1-end = {#2}, #1-after = , - #1-before* = , #1-begin* = , #1-end* = {#3}, #1-after* = , - #1-sep = {#4}, #1-sep* = {#5} + #1-before = , #1-begin = , #1-end = , #1-after = , + #1-before* = , #1-begin* = , #1-end* = , #1-after* = , + #1-sep = {#2}, #1-sep* = {#3} } } \cs_new_protected:Nn \@@_restore_sentence_list: - { \@@_delim_restore:nnnnn { sentence } { } { } { ~ } { ~ } } + { \@@_delim_restore:nnn { sentence } { ~ } { ~ } } \cs_new_eq:NN \@@_restore_par_list: ? \cs_new_protected:Npn \LipsumRestoreParList { @@ -1379,7 +1427,7 @@ { % \end{macrocode} % \opt{nopar} is implemented as a choice key instead of a boolean so -% we can update the separators using \cs{@@_delim_restore:nnnnn}. +% we can update the separators using \cs{@@_delim_restore:nnn}. % It's initially false, and the default is |true| so that % |\usepackage[nopar]{lipsum}| works as it always did. % \begin{macrocode} @@ -1387,12 +1435,12 @@ nopar / true .code:n = { \cs_gset_protected:Npn \@@_restore_par_list: - { \@@_delim_restore:nnnnn { par } { } { \par } { ~ } { } } + { \@@_delim_restore:nnn { par } { ~ } { \par } } } , nopar / false .code:n = { \cs_gset_protected:Nn \@@_restore_par_list: - { \@@_delim_restore:nnnnn { par } { \par } { } { } { ~ } } + { \@@_delim_restore:nnn { par } { \par } { ~ } } } , nopar .initial:n = false , nopar .default:n = true , @@ -1470,13 +1518,38 @@ % \begin{macrocode} \msg_new:nnn { lipsum } { invalid-range } { Invalid~number~or~range~'#1'. } -\msg_new:nnn { lipsum } { language-undefined } - { Language~'\g_@@_language_tl'~undefined. } \msg_new:nnn { lipsum } { cmd-deprecated } { Command~'\iow_char:N\\#1'~deprecated. \\ See~the~lipsum~documentation~for~help. } +\msg_new:nnn { lipsum } { missing-babel } + { + Hyphenation~patterns~for~'\g_@@_language_tl'~ + cannot~be~used~because~babel~is~not~loaded.~ + \str_case:nn {#1} + { + { preamble } + { Loading~lipsum~after~babel~should~fix~the~issue. } + { document } + { + The~default~document~language~will~be~used~ + for~hyphenation~instead. + } + { impossible } + { + Something~wrong~happened~and~the~command~ + \iow_char:N\\hyphenrules~is~not~available. \\ \\ + Please~report! + } + } + \\ \\ This~message~won't~be~shown~again. + } +\msg_new:nnn { lipsum } { missing-language } + { + Unknown~language~'\g_@@_language_tl'.~ + Hyphenation~patterns~for~'\languagename'~will~be~used~instead. + } % \end{macrocode} % % \begin{macrocode} diff --git a/macros/latex/contrib/lipsum/lipsum.pdf b/macros/latex/contrib/lipsum/lipsum.pdf index 4186c1880f..c27ddc7e8b 100644 Binary files a/macros/latex/contrib/lipsum/lipsum.pdf and b/macros/latex/contrib/lipsum/lipsum.pdf differ -- cgit v1.2.3