summaryrefslogtreecommitdiff
path: root/src/mtx-t-rst.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2014-03-01 22:47:25 +0100
committerPhilipp Gesang <phg@phi-gamma.net>2014-03-01 22:47:25 +0100
commit7d1114cd66025cc18535f3cdab3105e66bbda48d (patch)
treeeca33193cdbb0d7923527b0c0bfb58cd893036b6 /src/mtx-t-rst.lua
parent7652729ada000906e5e6b2b4d0c5dea01c73c29d (diff)
downloadcontext-rst-7d1114cd66025cc18535f3cdab3105e66bbda48d.tar.gz
adopt more conventional directory structure
Diffstat (limited to 'src/mtx-t-rst.lua')
-rw-r--r--src/mtx-t-rst.lua64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/mtx-t-rst.lua b/src/mtx-t-rst.lua
new file mode 100644
index 0000000..6735b1d
--- /dev/null
+++ b/src/mtx-t-rst.lua
@@ -0,0 +1,64 @@
+#!/usr/bin/env texlua
+--------------------------------------------------------------------------------
+-- FILE: mtx-rst.lua
+-- USAGE: mtxrun --script rst --if=input.rst --of=output.tex
+-- DESCRIPTION: context script interface for the reStructuredText module
+-- REQUIREMENTS: latest ConTeXt MkIV
+-- AUTHOR: Philipp Gesang (Phg), <megas.kapaneus@gmail.com>
+-- CHANGED: 2013-03-27 00:25:32+0100
+--------------------------------------------------------------------------------
+--
+
+scripts = scripts or { }
+scripts.rst = { }
+
+environment.loadluafile("rst_parser")
+
+local ea = environment.argument
+
+local helpinfo = [[
+===============================================================
+ The reStructuredText module, command line interface.
+ © 2010--2013 Philipp Gesang. License: 2-clause BSD.
+ Home: <https://bitbucket.org/phg/context-rst/>
+===============================================================
+
+USAGE:
+
+ mtxrun --script rst --if=input.rst --of=output.tex
+
+Mandatory arguments:
+
+ “infile.rst” is your input file containing reST markup.
+ “outfile.tex” is the target file that the TeX-code will be
+ written to.
+
+Optional arguments:
+ --et=bool “expandtab”, should tab chars (“\t”, “\v”) be
+ converted to spaces?
+ --sw=int “shiftwidth”, tab stop modulo factor.
+
+===============================================================
+]]
+
+local application = logs.application {
+ name = "mtx-rst",
+ banner = "The reStructuredText module for ConTeXt, hg-rev 125+",
+ helpinfo = helpinfo,
+}
+
+scripts.rst.input = ea("if")
+scripts.rst.output = ea("of")
+
+if scripts.rst.input and scripts.rst.output then
+ local expandtab = ea("et") == "true" and true
+ local shiftwidth = ea("sw")
+ local debug = ea("debug") == "true"
+ if expandtab then thirddata.rst.expandtab = true end
+ if shiftwdith then thirddata.rst.shiftwidth = tonumber(shiftwidth) end
+ if debug then thirddata.rst_helpers.rst_debug = debug end
+ thirddata.rst.standalone(scripts.rst.input, scripts.rst.output)
+else
+ application.help()
+end
+