languages-goodies.tex /size: 3459 b    last modification: 2023-12-21 09:43
1% language=us
2
3\startcomponent languages-goodies
4
5\environment languages-environment
6
7\startchapter[title=Goodies][color=darkorange]
8
9\startsection[title=Introduction]
10
11There are some features that will only be used in rare cases. They were often
12implemented as experiment but found useful enough to keep around.
13
14\stopsection
15
16\startsection[title=Spell checking]
17
18There are some means to check the spelling of words in your document but get it
19right: \CONTEXT\ is not a spell|-|checker. These features were added in order to
20be able to do some quick checking of documents written by multiple authors. There
21are currently three options and we only show a simple examples.
22
23First you need to load word lists. These are either text files with just words
24separated by spacing.
25
26\starttyping[color=maincolor]
27foobar  foo-bar  foo=bar  foo{}{}{}bar  foo{}{}{bar}
28\stoptyping
29
30All these words become \type {foobar} which means that one can use words with
31discretionary specifications. A text list is loaded with:
32
33\startbuffer
34\loadspellchecklist[en][t:/manuals/lua/words-en.txt]
35\stopbuffer
36
37\typebuffer \getbuffer
38
39Instead you can load a \LUA\ file with words. Here we use the same structure that
40we use for the spell checker provided for \SCITE:
41
42\starttyping[color=maincolor]
43return {
44    max   = 9,
45    min   = 6,
46    n     = 2,
47    words = {
48        ["barfoo"]    = "Barfoo"
49        ["foobarred"] = "foobarred",
50    }
51}
52\stoptyping
53
54We use the same load command (you can also load bytecode files with suffix \type
55{luc} this way):
56
57\startbuffer
58\loadspellchecklist[nl][t:/scite/data/context/lexers/data/spell-nl.lua]
59\stopbuffer
60
61\typebuffer \getbuffer
62
63Usage boils down to enabling the checker. If needed we can add more methods. The
64first method colors the known and unknown colors. Words shorter then the
65threshold of 4 will be skipped.
66
67\startbuffer
68\setupspellchecking[state=start,method=1]
69\en Is this written right or is this wromg?\par % m -> n error
70\nl Is dit goed geschreven of niet?\par
71\setupspellchecking[state=stop]
72\stopbuffer
73
74\typebuffer \startpacked \getbuffer \stoppacked
75
76You can change the colors:
77
78\starttyping
79\definecolor[word:yes]    [g=.75]
80\definecolor[word:no]     [r=.75]
81\stoptyping
82
83The second method doesn't show anything but produces a file \type
84{jobname.words}) with used words. The \type {found} value of \type {list} is used
85as key in the produced table.
86
87\startbuffer
88\setupspellchecking[state=start,method=2,list=found]
89\en Is this written right or is this wrong?\par
90\nl Is dit goed geschreven of niet?\par
91\setupspellchecking[state=stop]
92\stopbuffer
93
94\typebuffer \startpacked \getbuffer \stoppacked
95
96The produced table is:
97
98\typefile{\jobname.words}
99
100The result can be traced with a module:
101
102\startbuffer
103\usemodule[s-languages-words]
104
105\showwords
106\stopbuffer
107
108\typebuffer
109
110This shows up as:
111
112\getbuffer
113
114The third mechanism colors languages differently. We only defined a few colors:
115
116\starttyping
117\definecolor[word:en]     [b=.75]
118\definecolor[word:de]     [r=.75]
119\definecolor[word:nl]     [g=.75]
120\definecolor[word:unknown][r=.75,g=.75]
121\stoptyping
122
123but you can of course define a color for your favourite language in a similar way.
124
125\startbuffer
126\setupspellchecking[state=start,method=3]
127\en Is this written right or is this wrong?\par
128\nl Is dit goed geschreven of niet?\par
129\setupspellchecking[state=stop]
130\stopbuffer
131
132\typebuffer \startpacked \getbuffer \stoppacked
133
134\stopsection
135
136\stopchapter
137
138\stopcomponent
139