summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-02-13 23:22:28 +0000
committerKarl Berry <karl@freefriends.org>2013-02-13 23:22:28 +0000
commit469e41303044d048cec1de7cf5d814b9f2b5e52e (patch)
tree6c5aefbb73aa821e171c8beef63723044c2c5476 /Master/texmf-dist/tex/luatex
parenta19e8fc23c74d8bb5f11c0fb7c135ab7e108c36a (diff)
spelling (13feb13)
git-svn-id: svn://tug.org/texlive/trunk@29102 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex')
-rw-r--r--Master/texmf-dist/tex/luatex/spelling/spelling.sty149
1 files changed, 149 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/luatex/spelling/spelling.sty b/Master/texmf-dist/tex/luatex/spelling/spelling.sty
new file mode 100644
index 00000000000..d73661ee1ea
--- /dev/null
+++ b/Master/texmf-dist/tex/luatex/spelling/spelling.sty
@@ -0,0 +1,149 @@
+%%% spelling.sty
+%%% Copyright 2012, 2013 Stephan Hennig
+%%
+%% This work may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License, either version 1.3 of this license
+%% or (at your option) any later version. The latest version of this
+%% license is in http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% See file README for more information.
+%%
+\ProvidesPackage{spelling}
+ [2013/02/12 v0.3 Aid spell-checking (SH)]
+\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+% Test for the LuaTeX engine.
+\RequirePackage{ifluatex}
+\ifluatex
+\else
+\PackageError{spelling}{LuaTeX engine required}{You could try with the
+ `lualatex' command.}
+\fi
+\RequirePackage{ifthen}
+\RequirePackage{luatexbase}
+% Load main Lua file.
+\directlua name {spelling}{
+ % The main Lua file is not a module, so we must pass a full path to
+ % `dofile`.
+ local f = kpse.find_file('spelling.lua', 'lua')
+ dofile(f)
+}
+% Words are extracted after pages have been built. In lack of a proper
+% Lua call-back, we're hooking into shipout from the LaTeX side.
+\RequirePackage{atbegshi}
+\AtBeginShipout{%
+ \directlua name {spelling-atbeginshipout}{cb_AtBeginShipout_pkg_spelling(\the\AtBeginShipoutBox)}%
+}
+% Provide command for reading-in a list of bad spellings.
+\newcommand*{\spellingreadbad}[1]{%
+ \directlua{
+ pkg_spelling_stage[1].parse_bad_plain_list_file('\luaescapestring{#1}')
+ }%
+}
+% Provide command for reading-in a list of good spellings.
+\newcommand*{\spellingreadgood}[1]{%
+ \directlua{
+ pkg_spelling_stage[1].parse_good_plain_list_file('\luaescapestring{#1}')
+ }%
+}
+% Provide command for reading bad spellings from a LanguageTool XML
+% file.
+\newcommand*{\spellingreadLT}[1]{%
+ \directlua{
+ pkg_spelling_stage[1].parse_XML_LanguageTool_file('\luaescapestring{#1}')
+ }%
+}
+% Provide command for enabling/disabling visual feedback.
+\newcommand*{\spellinghighlight}[1]{%
+ \ifthenelse{\equal{#1}{on}}{%
+ \directlua{
+ pkg_spelling_stage[2].enable_word_highlighting()
+ }%
+ }{%
+ \directlua{
+ pkg_spelling_stage[2].disable_word_highlighting()
+ }%
+ }%
+}
+% Provide command for setting visual feedback colour.
+\newcommand*{\spellinghighlightcolor}[1]{%
+ \directlua{
+ pkg_spelling_stage[2].set_highlight_color('\luaescapestring{#1}')
+ }%
+}
+% Provide command for enabling/disabling text ouput.
+\newcommand*{\spellingoutput}[1]{%
+ \ifthenelse{\equal{#1}{on}}{%
+ \directlua{
+ pkg_spelling_stage[4].enable_text_output()
+ }%
+ }{%
+ \directlua{
+ pkg_spelling_stage[4].disable_text_output()
+ }%
+ }%
+}
+% Provide command for setting text output file name.
+\newcommand*{\spellingoutputname}[1]{%
+ \directlua{
+ pkg_spelling_stage[4].set_output_file_name('\luaescapestring{#1}')
+ }%
+}
+% Provide command for setting text output file line length.
+\newcommand*{\spellingoutputlinelength}[1]{%
+ \directlua{
+ pkg_spelling_stage[4].set_output_line_length('\luaescapestring{#1}')
+ }%
+}
+% Provide command for setting text output EOL character.
+\newcommand*{\spellingoutputeol}[1]{%
+ \directlua{
+ pkg_spelling_stage[4].set_output_eol('\luaescapestring{#1}')
+ }%
+}
+% Provide command for enabling/disabling text extraction.
+\newcommand*{\spellingextract}[1]{%
+ \ifthenelse{\equal{#1}{on}}{%
+ \directlua{
+ pkg_spelling_stage[2].enable_text_tagging()
+ }%
+ }{%
+ \directlua{
+ pkg_spelling_stage[2].disable_text_tagging()
+ }%
+ }%
+}
+% Provide command to declare code point mappings.
+\newcommand*{\spellingmapping}[2]{%
+ \directlua{
+ local r = pkg_spelling_stage[2].set_mapping(\luaescapestring{#1}, '\luaescapestring{#2}')
+ if r == false then
+ texio.write_nl('package spelling: invalid mapping: \luaescapestring{#1} => \luaescapestring{#2}')
+ end
+ }%
+}
+% Provide command to clear all existing code point mappings.
+\newcommand*{\spellingclearallmappings}{%
+ \directlua{
+ pkg_spelling_stage[2].clear_all_mappings()
+ }%
+}
+% Provide command to specify table paragraph behaviour.
+\newcommand*{\spellingtablepar}[1]{%
+ \directlua{
+ pkg_spelling_stage[3].set_table_paragraphs(\luaescapestring{#1})
+ }%
+}
+%
+% Read bad and good spellings from default sources.
+\directlua{
+ pkg_spelling_stage[1].parse_default_bad_and_good()
+}%
+%
+% Enable visual feedback.
+\spellinghighlight{on}
+% Enable text ouput at the end of the LuaTeX run.
+\spellingoutput{on}
+% Enable text extraction.
+\spellingextract{on}