summaryrefslogtreecommitdiff
path: root/mod/tex/context/third/rst/rst_parser.lua
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/tex/context/third/rst/rst_parser.lua
parenta7b6795708c093c5ce5f32fab79516feabd83171 (diff)
downloadcontext-rst-af128c93d64e2a4e49cb7e6a7eca569cf122d0da.tar.gz
moved external parser to mtx script
Diffstat (limited to 'mod/tex/context/third/rst/rst_parser.lua')
-rw-r--r--mod/tex/context/third/rst/rst_parser.lua60
1 files changed, 34 insertions, 26 deletions
diff --git a/mod/tex/context/third/rst/rst_parser.lua b/mod/tex/context/third/rst/rst_parser.lua
index 045d322..283ebf2 100644
--- a/mod/tex/context/third/rst/rst_parser.lua
+++ b/mod/tex/context/third/rst/rst_parser.lua
@@ -4,35 +4,24 @@
-- USAGE: refer to doc/documentation.rst
-- DESCRIPTION: https://bitbucket.org/phg/context-rst/overview
-- AUTHOR: Philipp Gesang (Phg), <megas.kapaneus@gmail.com>
--- VERSION: 0.3
--- CHANGED: 2011-05-08 17:55:54+0200
+-- VERSION: 0.6
+-- CHANGED: 2011-08-28 12:44:03+0200
--------------------------------------------------------------------------------
--
-local rst
-local optional_setups
thirddata = thirddata or { }
thirddata.rst = { }
thirddata.rst_helpers = { }
+
+environment.loadluafile"rst_helpers"
+environment.loadluafile"rst_directives"
+environment.loadluafile"rst_setups"
+environment.loadluafile"rst_context"
+
+local rst = thirddata.rst
local helpers = thirddata.rst_helpers
-if context then
- --thirddata.rst_setups = optional_setups
-
- environment.loadluafile("rst_helpers")
- environment.loadluafile("rst_directives")
- environment.loadluafile("rst_setups" )
- environment.loadluafile("rst_context")
-
- rst = rst_context
- optional_setups = thirddata.rst_setups
-else
- --helpers = require "rst_helpers"
- require "rst_helpers"
- rst_directives = require "rst_directives"
- optional_setups = require "rst_setups"
- rst = require "rst_context"
-end
+local optional_setups = thirddata.rst_setups
rst.strip_BOM = false
rst.expandtab = false
@@ -53,7 +42,7 @@ local warn = function(str, ...)
end
str = str .. string.format(" |%6s", string.strip(tostring(j)))
end
- io.write(str .. " |\n")
+ iowrite(str .. " |\n")
return 0
end
@@ -65,6 +54,8 @@ local P, R, S, V, match
local utf = unicode.utf8
+local iowrite = io.write
+
local eol = P"\n"
state = {}
@@ -1465,8 +1456,8 @@ local function get_setups (inline)
return setups
end
-local function main()
- local testdata = load_file(arg[1])
+function thirddata.rst.standalone (infile, outfile)
+ local testdata = load_file(infile)
if testdata == 1 then return 1 end
local processeddata = parser:match(testdata)
@@ -1486,7 +1477,7 @@ local function main()
]]
if processeddata then
- save_file(arg[2], processeddata)
+ save_file(outfile, processeddata)
else
return 1
end
@@ -1534,7 +1525,24 @@ function thirddata.rst.do_rst_snippet(txt)
end
end
+local usage_info = [[
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ rstConTeXt
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Functionality has been moved, the reST converter can now be
+accessed via mtxrun:
+
+ $mtxrun --script rst
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+]]
+
+local function main()
+ iowrite("\n"..usage_info.."\n")
+ return -1
+end
-if not context then
+if not (context or scripts) then
return main()
end