Skip to content

Commit

Permalink
In LuaTeX, ensure that empty paragraphs are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
zauguin committed Jun 21, 2021
1 parent 26e0dc3 commit 3931de2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
5 changes: 5 additions & 0 deletions base/changes.txt
Expand Up @@ -6,6 +6,11 @@ completeness or accuracy and it contains some references to files that
are not part of the distribution.
================================================================================

2021-06-21 Marcel Krüger <Marcel.Krueger@latex-project.org>

* ltpara.dtx:
Don't print effectivly empty paragraphs in RTL contexts in LuaTeX

2021-06-09 Frank Mittelbach <Frank.Mittelbach@latex-project.org>

* ltshipout.dtx:
Expand Down
37 changes: 34 additions & 3 deletions base/ltpara.dtx
Expand Up @@ -14,8 +14,8 @@
%%% From File: ltpara.dtx
%
% \begin{macrocode}
\def\ltparaversion{v1.0g}
\def\ltparadate{2021/05/27}
\def\ltparaversion{v1.0h}
\def\ltparadate{2021/06/21}
% \end{macrocode}
%<*driver>
\documentclass{l3doc}
Expand Down Expand Up @@ -714,6 +714,37 @@
%
%
%
% \begin{macro}{\@@_end_empty_par:}
% For most engines, running \cs{tex_par:D} in an empty paragraph will drop
% the paragraph, but in Lua\TeX\ this sometimes leads to paragraphs which
% contain only direction nodes. Therefore we first make sure that the list
% is really empty when using Lua\TeX.
% \changes{v1.0h}{2021/06/21}{Ensure that empty paragraphs are really empty in Lua\TeX}
% \begin{macrocode}
\sys_if_engine_luatex:TF
{
\newluafunction \g_@@_end_empty_par_id_int
\exp_args:Nx \everyjob {
\exp_not:V \everyjob
\exp_not:N \lua_now:n {
local~texnest, flush_list, par_token = tex.nest, node.flush_list, token.create'tex_par:D'~
lua.get_functions_table()[\int_use:N \g_@@_end_empty_par_id_int] = function()
local~nest_level = texnest.top~
local~cur_head = nest_level.head~
flush_list(cur_head.next)
nest_level.tail, cur_head.next = cur_head, nil~
token.put_next(par_token)
end
}
}
\protected \luadef \@@_end_empty_par: \g_@@_end_empty_par_id_int
} {
\cs_set_eq:NN \@@_end_empty_par: \tex_par:D
}
%
%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\g_@@_standard_everypar_tl}
% Whenever \TeX{} starts a paragraph it inserts first an
% indentation box and then executes the tokens stored in
Expand Down Expand Up @@ -746,7 +777,7 @@
% settings will not get lost as we need them for later.
% \begin{macrocode}
\group_begin:
\tex_par:D
\@@_end_empty_par:
\group_end:
% \end{macrocode}
% We then change \cs{tex_everypar:D} to generate an error so that
Expand Down

0 comments on commit 3931de2

Please sign in to comment.