summaryrefslogtreecommitdiff
path: root/mod/scripts/context
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2011-08-28 13:09:10 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2011-08-28 13:09:10 +0200
commitaf128c93d64e2a4e49cb7e6a7eca569cf122d0da (patch)
tree8064390353ecdda74f847ac75750e769485efa7c /mod/scripts/context
parenta7b6795708c093c5ce5f32fab79516feabd83171 (diff)
downloadcontext-rst-af128c93d64e2a4e49cb7e6a7eca569cf122d0da.tar.gz
moved external parser to mtx script
Diffstat (limited to 'mod/scripts/context')
-rw-r--r--mod/scripts/context/lua/mtx-rst.lua64
1 files changed, 64 insertions, 0 deletions
diff --git a/mod/scripts/context/lua/mtx-rst.lua b/mod/scripts/context/lua/mtx-rst.lua
new file mode 100644
index 0000000..2b3841a
--- /dev/null
+++ b/mod/scripts/context/lua/mtx-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>
+-- CREATED: 2011-08-28 12:43:49+0200
+--------------------------------------------------------------------------------
+--
+
+scripts = scripts or { }
+scripts.rst = { }
+
+environment.loadluafile("rst_parser")
+
+local ea = environment.argument
+
+local helpinfo = [[
+===============================================================
+ The reStructuredText module, command line interface.
+ © 2010--2011 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" and true or false
+ 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
+