From af128c93d64e2a4e49cb7e6a7eca569cf122d0da Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 28 Aug 2011 13:09:10 +0200 Subject: moved external parser to mtx script --- mod/tex/context/third/rst/rst_parser.lua | 60 ++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 26 deletions(-) (limited to 'mod/tex/context/third/rst/rst_parser.lua') 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), --- 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 -- cgit v1.2.3