wspr / hardwrap Goto Github PK
View Code? Open in Web Editor NEWA LaTeX package to wrap lines in log file messages
A LaTeX package to wrap lines in log file messages
[Incidentally, qstest looks quite useful. I've been meaning to find a testing framework for my LaTeX cocde for quite a while now. I'll have to explore qstest some more.]
Would be good to take care of ~
, \par
, etc, à la hyperref's bookmark string transformations. This is a bit open-ended and no need to go overboard.
Looks like the package to use for that is Heiko's stringenc
.
Courtesy Ulrich Diez:
\documentclass{article}
\usepackage{hardwrap}
\begin{document}
% Test A (OK) :
\HardWrap{\message}{15}{\HardWrapSetup}{^^J}{Test\\Test\\Test}
% Test B (Problem) :
\HardWrap{\message}{15}{\HardWrapSetup}{^^J}{Test\\Test\\}
\end{document}
Providing hard-wrapped wrappers for the expl3 notification system would be a good extension for the package.
One day hardwrap might make it into LaTeX3 internally (if it works well and people seem to use it), but until then co-existing would nice.
Test case:
\documentclass{article}
\usepackage{hardwrap}
\GeneratePackageLogMacros{pkg}
\begin{document}
\makeatletter
\pkg@error{Error text.}{More error text.}
\makeatother
\end{document}
After hitting Ctrl+C
, the following message is shown:
\hw@wrappedtext ->\hw@protected@newline
Error\space text.
l.11 \pkg@error{Error text.}{More error text.}
Normally you'd write \space\space\space
to write three spaces in a row. This doesn't work because they're expanded at which point they collapse. Need to locally define \space
as \protected
to avoid this.
I haven't really warmed to the names of:
\GeneratePackageLogMacros[prefix]{name}
\GenerateClassLogMacros[prefix]{name}
I sort of think that these might be slightly easier to remember/mentally-parse:
\GenerateLogMacros{Package}[prefix]{name}
\GenerateLogMacros{Class}[prefix]{name}
What do you think?
When attempting to compile a document with xelatex, I get the following error:
! Undefined control sequence.
l.48 \ifnum\pdfshellescape
>0\relax
We should probably account for this possibility.
I often need to display supplementary information in a message that looks good if it's indented or whatever. So rather than writing \space\spaces\space
it'd be nice to have something like \indent
that takes care of this for us.
\begin{qstest}{braced material is a pain}{} \HardWrap{\xdef\TMP}{50}{}{NEWLINE}{AAA {\LIPSUM} ZZZ}% \Expect*{\TMP} *{} \end{qstest}
Not sure what the expected behaviour here should be.
Here's the test case:
\GeneratePackageLogMacros{test}
\test@error{x}{x}
Output is:
! Package test Error: \MessageBreak x.
Similarly for the class version.
(info and warning appear okay, though.
The following causes an infinite loop (due to the quark token being expanded).
\hardwrap{40}{\xdef\mytext}{\par}{Space }
\mytext
There's no reason, necessarily, to keep LaTeX's \PackageError
. We could write an entirely separate command with the same functionality but formatted as we like. E.g., in expl3 I've just started experimenting with output for error messages that looks like
................................................ . ! fontspec error "unknown-options" . . The following font options are not recognised: . foo . . For immediate help type H . ...............................................
Test case:
\GeneratePackageLogMacros{pkg}
\pkg@warning{\protect\LaTeX}
Result:
Package pkg Warning: \protect \LaTeX
Expected result:
Package pkg Warning: \LaTeX
(Why package authors don't just use \string\blah and make my life simpler, I don't know.)
LATEX News Issue 34, November 2021:
"\PackageNote and \ClassNote added LATEX offers these three commands: \PackageError to signal errors that stop the processing; \PackageWarning to generate a warning message on the terminal but continue with the processing; and \PackageInfo to provide some information that is only written to the .log file but not sent to the terminal. What has not existed up to now is a way to provide information on the terminal that identifies itself as coming from a specific package but which does not claim to be a warning. (Packages that wanted to write to the terminal used \PackageWarning even though the information was not in fact a warning.) We have therefore now added \PackageNote (and the closely related \PackageNoteNoLine); these identify themselves as “informational”, but they still go to the terminal and not only to the .log file. Similar commands exist for classes and so there too we have new commands: \ClassNote and \ClassNoteNoLine. (github issue 613)"
Hardwrap is missing the equivalents for \PackageNote, \PackageNoteNoLine, \ClassNote, and \ClassNoteNoLine.
Nitpicking:
\RequirePackage{ifxetex}
please replace obsolete call to ifxetex
with the recent iftex
package.2011/02/12
, new ISO 8601 Date format is 2011-02-12
, see LaTeX News Issue 27, April 2017. On the one hand, this would require LaTeX2e format 2017-04-15, but on the other hand we are at the end of 2022 now.Code line 41: \ifwindows\else
For me this looks like the documentation "This only works for pdfTEX in TEX Live." is missing an "on Windows". Additionally: If I execute kpsewhich -var-value=max_print_line
at the command prompt I get
105% default: max_print_line = 79; arbitrary
Looking into my texmf.cnf file I read:
max_print_line = 105% default: max_print_line = 79; arbitrary
Thus, it would also work on Windows. OK, on Windows, where Cygwin is installed and added to the path. Would be nice if this could be regarded.
For me
\usepackage{hardwrap}
\makeatletter
\setmaxprintline{\@@input"|kpsewhich -var-value=max_print_line"\relax}
\makeatother
works (\showthe\hw@maxprintline
says 105
), but breaks portability of the document to other computers without Cygwin@Windows.
Note: I am not compiling under Cygwin at all, it is just installed.
The following generates an error:
\GeneratePackageLogMacros{mypkg}
\mypkg@warning{Testing \noexpand\textbf.}% should output 'Testing \textbf.'
Some existing packages use \noexpand\macroname to achieve the effect of printing '\macroname' verbatim to the log file.
Perhaps if the user enters ^^J
to insert a newline, these should be replaced by their "hardwrap newline" equivalent. This would probably make transitioning a little easier, too.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.