summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-12-02 23:27:13 +0000
committerKarl Berry <karl@freefriends.org>2012-12-02 23:27:13 +0000
commitdf141e41c79cc6a9b97f9ac0de97b19054849e9b (patch)
tree7986468b5110a67480f1857af4ee509aed857295 /Master/texmf-dist/tex/lualatex
parent8c4fc53986e6136d225c9c93382bca6607071fea (diff)
new lualatex package spelling (1dec12)
git-svn-id: svn://tug.org/texlive/trunk@28425 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/lualatex')
-rw-r--r--Master/texmf-dist/tex/lualatex/spelling/spelling.sty140
1 files changed, 140 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/lualatex/spelling/spelling.sty b/Master/texmf-dist/tex/lualatex/spelling/spelling.sty
new file mode 100644
index 00000000000..c363e53c129
--- /dev/null
+++ b/Master/texmf-dist/tex/lualatex/spelling/spelling.sty
@@ -0,0 +1,140 @@
+%%% spelling.sty
+%%% Copyright 2012 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}
+ [2012/11/30 v0.1 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}
+\directlua name {spelling}{dofile('spelling.lua')}
+% 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].read_bad_strings('\luaescapestring{#1}')
+ }%
+}
+% Provide command for reading-in a list of good spellings.
+\newcommand*{\spellingreadgood}[1]{%
+ \directlua{
+ pkg_spelling_stage[1].read_good_strings('\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})
+ }%
+}
+% Try to read a list of bad spellings from file `\jobname.spb'.
+\IfFileExists{\jobname.spb}{%
+ \spellingreadbad{\jobname.spb}%
+}{%
+}
+% Try to read a list of good spellings from file `\jobname.spg'.
+\IfFileExists{\jobname.spg}{%
+ \spellingreadgood{\jobname.spg}%
+}{%
+}
+% Enable visual feedback.
+\spellinghighlight{on}
+% Enable text ouput at the end of the LuaTeX run.
+\spellingoutput{on}
+% Enable text extraction.
+\spellingextract{on}