From 78d44502d0e4dc5179b703189da54bc3dfe0d306 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 4 May 2011 17:44:12 +0200 Subject: confirming to Lua module namespace; alternate code from Wolfgang (resting for now) --- mod/tex/context/third/rst/rst_parser.lua | 44 +++++++++++++++++--------------- 1 file changed, 24 insertions(+), 20 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 b0a02e6..ec9366e 100644 --- a/mod/tex/context/third/rst/rst_parser.lua +++ b/mod/tex/context/third/rst/rst_parser.lua @@ -1,38 +1,42 @@ #!/usr/bin/env texlua -------------------------------------------------------------------------------- -- FILE: rst-parser.lua --- USAGE: ./rst-parser.lua --- DESCRIPTION: --- OPTIONS: --- --- REQUIREMENTS: --- +-- USAGE: refer to doc/documentation.rst +-- DESCRIPTION: https://bitbucket.org/phg/context-rst/overview -- AUTHOR: Philipp Gesang (Phg), --- VERSION: 1.0 --- CREATED: 31/08/10 11:53:49 CEST +-- VERSION: 0.3 +-- CREATED: 2011-05-04 17:41:15+0200 -------------------------------------------------------------------------------- -- -rst = {} -helpers = {} -optional_setups = {} +local rst +local helpers = {} +local optional_setups if context then + thirddata = thirddata or { } + thirddata.rst = { } + thirddata.rst_helpers = helpers + --thirddata.rst_setups = optional_setups + environment.loadluafile("rst_helpers") + environment.loadluafile("rst_directives") environment.loadluafile("rst_setups" ) environment.loadluafile("rst_context") - rst = rst_context - helpers = helpers - optional_setups = optional_setups + + rst = rst_context + optional_setups = thirddata.rst_setups else - rst = require "rst_context" - helpers = require "rst_helpers" + rst = require "rst_context" + helpers = require "rst_helpers" optional_setups = require "rst_setups" + rst_directives = require "rst_directives" end - -local rst_debug = true +helpers.rst_debug = false local warn = function(str, ...) - if not rst_debug then return false end + if not helpers.rst_debug then return false end local slen = #str + 3 str = "*["..str.."]" for i,j in ipairs({...}) do @@ -1374,7 +1378,7 @@ local function get_setups (inline) \setupcolors[state=start] \setupinteraction[state=start,focus=standard,color=darkgreen,contrastcolor=darkgreen] -\setupbodyfontenvironment [default] [em=italic] +%\setupbodyfontenvironment [default] [em=italic] \sethyphenatedurlnormal{:=?&} \sethyphenatedurlbefore{?&} \sethyphenatedurlafter {:=/-} @@ -1443,7 +1447,7 @@ do strip_comments = Cs((comment + 1)^0) end -function rst.do_rst_file(fname) +function thirddata.rst.do_rst_file(fname) local rst_parser = parser local raw_data = load_file(fname) local processed = rst_parser:match(raw_data) @@ -1457,7 +1461,7 @@ function rst.do_rst_file(fname) end end -function rst.do_rst_snippet(txt) +function thirddata.rst.do_rst_snippet(txt) local processed = parser:match(txt) local setups = get_setups(true) local tmp_file = tex.jobname .. "–rst_temporary.tex.tmp" -- cgit v1.2.3