summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkxl
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2021-07-16 22:58:17 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2021-07-16 22:58:17 +0200
commita06e8a0d7325ee248138a327e1117139b71aeaba (patch)
treec0ffdfcb82aac51b5e35fb3e5aa2ae0314d62220 /tex/context/modules/mkxl
parenteebab79d84255890c1a6d320fba146b1c422c3a6 (diff)
downloadcontext-a06e8a0d7325ee248138a327e1117139b71aeaba.tar.gz
2021-07-16 22:01:00
Diffstat (limited to 'tex/context/modules/mkxl')
-rw-r--r--tex/context/modules/mkxl/m-barcodes.mkxl40
-rw-r--r--tex/context/modules/mkxl/m-gnuplot.mkxl97
-rw-r--r--tex/context/modules/mkxl/m-tikz.mkxl112
3 files changed, 249 insertions, 0 deletions
diff --git a/tex/context/modules/mkxl/m-barcodes.mkxl b/tex/context/modules/mkxl/m-barcodes.mkxl
new file mode 100644
index 000000000..43540e457
--- /dev/null
+++ b/tex/context/modules/mkxl/m-barcodes.mkxl
@@ -0,0 +1,40 @@
+%D \module
+%D [ file=m-barcodes,
+%D version=2010.03.14,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=Barcodes,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{barcodes}{the 'zint' module is a better choice}
+
+\usemodule[zint]
+
+\unprotect
+
+\pushoverloadmode
+
+\let\normalbarcode\barcode
+
+\permanent\protected\def\barcode[#1]%
+ {\normalbarcode[\c!text=\dummyparameter{code},\c!alternative=\dummyparameter{type},#1]}
+
+\popoverloadmode
+
+\protect
+
+\continueifinputfile{m-barcodes.mkxl}
+
+\starttext
+ \startTEXpage
+ \barcode[type=isbn,text=978-9490688011]
+ \blank
+ \barcode[type=isbn,text=9780500518724]
+ \stopTEXpage
+\stoptext
+
diff --git a/tex/context/modules/mkxl/m-gnuplot.mkxl b/tex/context/modules/mkxl/m-gnuplot.mkxl
new file mode 100644
index 000000000..e844edd1b
--- /dev/null
+++ b/tex/context/modules/mkxl/m-gnuplot.mkxl
@@ -0,0 +1,97 @@
+%D \module
+%D [ file=m-gnuplot,
+%D version=2020.02.10,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=Gnuplot,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This is a variant on the \GNUPLOT\ terminal code. At some point (when there is a
+%D reason) I will make a proper environment that can be used for embedded code.
+
+\permanent\protected\def\includegnuplotsvgfile[#1]%
+ {\hbox\bgroup
+ \ctxlua{metapost.startsvghashing()}%
+ \includesvgfile[#1]%
+ \ctxlua{metapost.stopsvghashing()}%
+ \egroup}
+
+\startluacode
+
+local modificationtime = lfs.modification
+local longtostring = string.longtostring
+local formatters = string.formatters
+local expandfilename = dir.expandname
+local isfile = lfs.isfile
+
+local runner = sandbox.registerrunner {
+ name = "gnuplot to svg",
+ program = "gnuplot",
+ template = longtostring [[
+ -e "set output '%newname%'; set terminal svg"
+ "%oldname%"
+ ]],
+ checkers = {
+ oldname = "readable",
+ newname = "writable",
+ },
+}
+
+figures.programs.gnuplot = {
+ runner = runner,
+}
+
+local function remap(specification)
+ local oldname = specification.fullname
+ if oldname then
+ local newname = file.replacesuffix(oldname,"svg")
+ local oldtime = modificationtime(oldname) or 0
+ local newtime = modificationtime(newname) or 0
+ if newtime == 0 or oldtime > newtime then
+ runner {
+ newname = expandfilename(newname),
+ oldname = expandfilename(oldname),
+ }
+ end
+ if isfile(newname) then
+ local only = file.nameonly(newname)
+ local name = formatters["svg-%s-inclusion"](only)
+ local code = formatters["\\includegnuplotsvgfile[%s]\\resetbuffer[%s]"](newname,name)
+ buffers.assign(name,code)
+ specification.format = "buffer"
+ specification.fullname = name
+ end
+ end
+ return specification
+end
+
+figures.remappers.gp = { svg = remap }
+
+\stopluacode
+
+\continueifinputfile{m-gnuplot.mkxl}
+
+\startluacode
+io.savedata("m-gnuplot-demo.gp", [[
+set format xy "$%g$"
+
+set title 'This is a plot of $y=\\sin(x)$'
+set xlabel 'This is the $x$ axis'
+set ylabel 'This is the $y$ axis'
+
+plot [0:6.28] [0:1] sin(x)
+]])
+\stopluacode
+
+\starttext
+
+ \externalfigure[m-gnuplot-demo.gp][conversion=svg,width=4cm]
+
+ \externalfigure[m-gnuplot-demo.gp][conversion=svg,width=8cm]
+
+\stoptext
diff --git a/tex/context/modules/mkxl/m-tikz.mkxl b/tex/context/modules/mkxl/m-tikz.mkxl
new file mode 100644
index 000000000..5b1f6e76c
--- /dev/null
+++ b/tex/context/modules/mkxl/m-tikz.mkxl
@@ -0,0 +1,112 @@
+%D \module
+%D [ file=m-tikz,
+%D version=2021.07.12,
+%D title=\CONTEXT\ Extra Modules,
+%D subtitle=TIKZ support,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D A fixed variant of the t-tikz module distributed with tikz. For
+%D practical reasons per 2021 we split the module for \MKIV\ and
+%D \LMTX. (Maybe some day I'll optimize TIKZ a bit.)
+
+\ifdefined\pdflastxpos \else
+ \unprotect
+ \frozen\overloaded\protected\def\pdflastxpos{\numexpr\clf_lastxpos\relax}
+ \frozen\overloaded\protected\def\pdflastypos{\numexpr\clf_lastypos\relax}
+ \protect
+\fi
+
+
+\pushoverloadmode
+
+ \pushcatcodetable
+
+ \setcatcodetable\texcatcodes
+
+ \catcode`\@=11
+ \catcode`\|=12
+ \catcode`\!=12
+
+ \input t-pgf.tex
+ \input t-pgffor.tex
+ \input tikz.code.tex
+
+ \popcatcodetable
+
+\popoverloadmode
+
+\permanent\protected\def\tikzerrormessage#1#2#3%
+ {\writestatus{#1}{#2}}
+
+% For now we need this but we need to educate the user to wrap settings
+% in the wrappers. So some day the next line will go. I need to check what
+% commands are possible outside a picture.
+
+\overloadmode\zerocount
+
+\permanent\protected\def\starttikzsettings
+ {\pushoverloadmode}
+
+\permanent\protected\def\stoptikzsettings
+ {\popoverloadmode}
+
+\permanent\protected\def\starttikzpicture
+ {\dontleavehmode
+ \hcontainer\bgroup
+ % \pushoverloadmode
+ \ifdefined\PackageError\else \let\PackageError\tikzerrormessage \fi
+ \tikzpicture}
+
+\permanent\protected\def\stoptikzpicture
+ {\endtikzpicture
+ % \popoverloadmode
+ \egroup}
+
+% \input t-pgf.tex
+
+\ifx\pgfdefined\undefined
+
+ \let\pgfdefined\relax
+
+ % \input t-pgfcor.tex
+
+ \ifx\pgfcoredefined\undefined
+
+ \let\pgfcoredefined=\relax
+
+ \input t-pgfsys.tex
+
+ \edef\pgfcoreatcode {\the\catcode`\@}
+ \edef\pgfcorebarcode {\the\catcode`\|}
+ \edef\pgfcoreexclaimcode{\the\catcode`\!}
+
+ \catcode`\@=11
+ \catcode`\|=12
+ \catcode`\!=12
+
+ \input pgfcore.code.tex
+
+ \catcode`\@=\pgfcoreatcode
+ \catcode`\|=\pgfcorebarcode
+ \catcode`\!=\pgfcoreexclaimcode
+
+ \let\startpgfpicture \pgfpicture \let\stoppgfpicture \endpgfpicture
+ \let\startpgfscope \pgfscope \let\stoppgfscope \endpgfscope
+ \let\startpgflowlevelscope \pgflowlevelscope \let\stoppgflowlevelscope \endpgflowlevelscope
+ \let\startpgfinterruptpath \pgfinterruptpath \let\stoppgfinterruptpath \endpgfinterruptpath
+ \let\startpgfinterruptpicture \pgfinterruptpicture \let\stoppgfinterruptpicture \endpgfinterruptpicture
+ \let\startpgfinterruptboundingbox\pgfinterruptboundinbox \let\stoppgfinterruptboudingbox\endpgfinterruptboundingbox
+
+ \fi
+
+ \usepgfmodule[shapes,plot]
+
+\fi
+
+\stopmodule