summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/spelling/spelling-stage-3.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/scripts/spelling/spelling-stage-3.lua')
-rwxr-xr-xMaster/texmf-dist/scripts/spelling/spelling-stage-3.lua46
1 files changed, 21 insertions, 25 deletions
diff --git a/Master/texmf-dist/scripts/spelling/spelling-stage-3.lua b/Master/texmf-dist/scripts/spelling/spelling-stage-3.lua
index dfee2fed283..436fe6422fd 100755
--- a/Master/texmf-dist/scripts/spelling/spelling-stage-3.lua
+++ b/Master/texmf-dist/scripts/spelling/spelling-stage-3.lua
@@ -25,7 +25,7 @@
--
-- @author Stephan Hennig
-- @copyright 2012, 2013 Stephan Hennig
--- @release version 0.3
+-- @release version 0.4
--
-- @trick Prevent LuaDoc from looking past here for module description.
--[[ Trick LuaDoc into entering 'module' mode without using that command.
@@ -37,12 +37,13 @@ module(...)
local M = {}
--- Import helper module.
-local __recurse = require 'spelling-recurse'
-local __recurse_node_list = __recurse.recurse_node_list
+-- Import external modules.
+local recurse = require('spelling-recurse')
-- Function short-cuts.
+local recurse_node_list = recurse.recurse_node_list
+
local tabinsert = table.insert
local tabremove = table.remove
@@ -59,20 +60,11 @@ local USER_DEFINED = node.subtype('user_defined')
-- Text document data structure.
local __text_document
--
--- ID of user-defined whatsit nodes.
-local __whatsit_uid
-
-
---- Set module resources.
--- Make various resources, that are provided by external code, available
--- to this module.
+-- ID of user-defined whatsit nodes marking the start of a word.
+local __uid_start_tag
--
--- @param res Ressource table.
-local function set_resources(res)
- __text_document = res.text_document
- __whatsit_uid = res.whatsit_uid
-end
-M.set_resources = set_resources
+-- ID of user-defined whatsit nodes marking the end of a word.
+local __uid_end_tag
--- Module options.
@@ -199,11 +191,8 @@ local function __visit_node(head, n)
-- Test for node containing a word string.
if nid == WHATSIT then
-- Test for word string tag.
- if (n.subtype == USER_DEFINED) and (n.user_id == __whatsit_uid) then
- -- End tag?
- if n.value ~= '' then
- __finish_current_word(n)
- end
+ if (n.subtype == USER_DEFINED) and (n.user_id == __uid_end_tag) then
+ __finish_current_word(n)
-- Test for paragraph start.
elseif n.subtype == LOCAL_PAR then
__finish_current_paragraph()
@@ -247,7 +236,7 @@ local __cb_store_words = {
--
-- @param head Node list.
local function __process_node_list(head)
- __recurse_node_list(head, __cb_store_words)
+ recurse_node_list(head, __cb_store_words)
-- Clean-up left-over word and/or paragraph.
__finish_current_paragraph()
end
@@ -258,10 +247,11 @@ local __is_active_storage
--- Call-back function that processes the node list.
--- <i>This is a global function!</i>
+-- <i>This function is not made available in the module table, but in
+-- the global package table!</i>
--
-- @param head Node list.
-function cb_AtBeginShipout_pkg_spelling(box)
+local function cb_AtBeginShipout(box)
if __is_active_storage then
__process_node_list(tex.box[box])
end
@@ -288,6 +278,12 @@ M.disable_text_storage = disable_text_storage
--- Module initialisation.
--
local function __init()
+ -- Get local references to package ressources.
+ __text_document = PKG_spelling.res.text_document
+ __uid_start_tag = PKG_spelling.res.whatsit_ids.start_tag
+ __uid_end_tag = PKG_spelling.res.whatsit_ids.end_tag
+ -- Make \AtBeginShipout function available in package table.
+ PKG_spelling.cb_AtBeginShipout = cb_AtBeginShipout
-- Create empty paragraph management stack.
__is_vlist_paragraph = {}
-- Remember call-back status.