Changes

Jump to navigation Jump to search
1,255 bytes added ,  13:42, 26 December 2021
Add description regarding --errors
While ConTeXt (i.e. mtxrun) already automates The [[First Document]] page provides a lot, in bigger projects I find it tedious cursory introduction to call context with all its options all the timetypesetting document using ConTeXt. One might use The [https://www.gnu.org/software/make/ make[Context]] or [https://githubpage describes the command-line options in brief.com/cereda/arara arara], but I mostly use shell scripts (on OSX and Linux)This page provides additional information for command-line options. Here are some useful snippets:
<pre>#!/bin/bash== --run ==
OS=`uname`if [ "$TEXROOT" == "" ]Process one or more files; then # setup ConTeXt’s path; I used different locations on OSX this is the default action and Linux # You might also check on the hostname or if the path exists if [ "$OS" == "Linux" ]; then source /var/opt/context/tex/setuptex /var/opt/context/tex elif [ "$OS" == "Darwin" ]; then source ~/Library/texmf/tex/setuptex ~/Library/texmf/tex fifimay be omitted.
# ulimit was 256 on older OSX versions, that's too low for bigger booksif [ `ulimit` != "unlimited" ]; then ulimit = -S -n 2048fiautopdf ==
# I like to have my PDFs versioned at least by dateISODATE=`date +"%Y-%m-%d"`Reopen the generated PDF file in the system's default PDF file viewer after recompiling a document.
PRD=$1if [ "$1" =--purgeall = "" ]; then echo Which product? ls -Alh prd_*.tex exit 1fiRESULT=${PRD}_${ISODATE}
MODE=$2if [ "$MODE" == "" ]; then echo Using lowres pictures for previewDelete all build artifacts generated during compiling of a document, such as ''.tuc'' and ''. Use log'print' parameter for highres modefiles. MOD=lowreselse # print RESULT=${RESULT}_$MODEfi
if [ "$OS" == "Darwin" ]; then OPEN='open -a Preview' SHARE-path=~/Boxelse OPENlist ="qpdfview --quiet" SHARE=~/Dropboxfi
context Provide a comma--jit prd_${PRD} --result=_pdf/$RESULT --mode=$MODif [ "$?" == "0" ]; then ${OPEN} _pdf/$RESULT.pdf & cp _pdf/${RESULT}separated list of paths for ConTeXt to search when processing.pdf ${SHARE}/projects/fiFor example:
context --path="$HOME/writing/common/styles,$HOME/writing/amazing-novel/styles" == --result == Changes the output document file name. ConTeXt creates the output document file in the current working directory; this option cannot create or move the output document in a different directory. Instead, change the working directory before running ConTeXt and use the ''--path'' option to configure where ConTeXt searches for files to process. == --errors == ConTeXt is sometimes quite liberal when it comes to non-syntactical errors in the source files. Missing fonts, missing characters in a font, missing references do not automatically abort a run or exit with a non-successful return value. To report possible issues, either compile with <code>--errors</code> or use <texcode>\enabledirectives [logs.errors]</texcode> in the source file. Example: <texcode>\starttext%% missing figure\externalfigure [nonexistent]\stoptext</texcode> Compiling with <code>context --noconsole --silent --nostatistics file.tex</code> would result in no output (as well as a successful return value). If, on the other hand, compiled with <code>context --noconsole --silent --nostatistics --errors file.tex</code> the output would be: <texcode>error logging > start possible issuesgraphics > start missing figuresgraphics > foographics > stop missing figureserror logging > stop possible issues</texcode> The return value would still be zero (success), though. To have the return value reflect possible found issues, patterns can be used. Example: <texcode>\enabledirectives [logs.errors=*]</texcode> Alternatively the patterns can be provided as a compile switch <code>--errors='*'</code>. The quotes are required to prevent shell expansion. With these options, the <code>context</precode>would return 1 (failure) if problems are found.  Note that only some of the problems are reported, some of which might not be critical and other, possibly critical problems, are not detected. [[Category:Basics]][[Category:Tools]]
69

edits

Navigation menu