| 1 |
% linebreaker.sty |
| 2 |
% |
| 3 |
% (c) Michal Hoftich <[email protected]> |
| 4 |
% |
| 5 |
%% This program can be redistributed and/or modified under the terms |
| 6 |
%% of the LaTeX Project Public License Distributed from CTAN archives |
| 7 |
%% in directory macros/latex/base/lppl.txt. |
| 8 |
|
| 9 |
\ProvidesPackage{linebreaker} |
| 10 |
|
| 11 |
\RequirePackage{luatexbase} |
| 12 |
\directlua{% |
| 13 |
linebreaker = require "linebreaker" |
| 14 |
luatexbase.add_to_callback("linebreak_filter", linebreaker.linebreak, "new linebreak callback") |
| 15 |
luatexbase.add_to_callback("post_linebreak_filter", linebreaker.post_linebreak, "new linebreak callback") |
| 16 |
luatexbase.add_to_callback("hpack_quality", linebreaker.hpack_quality, "Our overfull box reporting function") |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
% linebreaker setup |
| 21 |
\ExplSyntaxOn |
| 22 |
\keys_define:nn{linebreaker}{ |
| 23 |
debug .code:n = \directlua{linebreaker.debug=true}, |
| 24 |
maxtolerance .code:n = \directlua{linebreaker.max_tolerance = tonumber("#1")}, |
| 25 |
maxemergencystretch .code:n = \directlua{linebreaker.max_emergencystretch = tex.sp("#1")}, |
| 26 |
maxcycles .code:n = \directlua{linebreaker.max_cycles = tonumber("#1")}, |
| 27 |
cubic .code:n = \directlua{linebreaker.use_cubic = true} |
| 28 |
} |
| 29 |
\NewDocumentCommand{\linebreakersetup}{m}{ |
| 30 |
\keys_set:nn {linebreaker} {#1} |
| 31 |
} |
| 32 |
\ExplSyntaxOff |
| 33 |
|
| 34 |
% enable/disable linebreaker |
| 35 |
\NewDocumentCommand{\linebreakerenable}{}{\directlua{linebreaker.active=true}} |
| 36 |
\NewDocumentCommand{\linebreakerdisable}{}{\directlua{linebreaker.active=false}} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
\endinput |