summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/languages/languages-goodies.tex
blob: fbbfafc34a1b5662a046b2b7784d096af229db3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
% language=uk

\environment languages-environment

\startcomponent languages-goodies

\startchapter[title=Goodies][color=darkorange]

\startsection[title=Introduction]

There are some features that will only be used in rare cases. They were often
implemented as experiment but found useful enough to keep around.

\stopsection

\startsection[title=Spell checking]

There are some means to check the spelling of words in your document but get it
right: \CONTEXT\ is not a spell|-|checker. These features were added in order to
be able to do some quick checking of documents written by multiple authors. There
are currently three options and we only show a simple examples.

First you need to load word lists. These are either text files with just words
separated by spacing.

\starttyping[color=maincolor]
foobar  foo-bar  foo=bar  foo{}{}{}bar  foo{}{}{bar}
\stoptyping

All these words become \type {foobar} which means that one can use words with
discretionary specifications. A text list is loaded with:

\startbuffer
\loadspellchecklist[en][t:/manuals/lua/words-en.txt]
\stopbuffer

\typebuffer \getbuffer

Instead you can load a \LUA\ file with words. Here we use the same structure that
we use for the spell checker provided for \SCITE:

\starttyping[color=maincolor]
return {
    max   = 9,
    min   = 6,
    n     = 2,
    words = {
        ["barfoo"]    = "Barfoo"
        ["foobarred"] = "foobarred",
    }
}
\stoptyping

We use the same load command (you can also load bytecode files with suffix \type
{luc} this way):

\startbuffer
\loadspellchecklist[nl][t:/scite/data/context/lexers/data/spell-nl.lua]
\stopbuffer

\typebuffer \getbuffer

Usage boils down to enabling the checker. If needed we can add more methods. The
first method colors the known and unknown colors. Words shorter then the
threshold of 4 will be skipped.

\startbuffer
\setupspellchecking[state=start,method=1]
\en Is this written right or is this wromg?\par % m -> n error
\nl Is dit goed geschreven of niet?\par
\setupspellchecking[state=stop]
\stopbuffer

\typebuffer \startpacked \getbuffer \stoppacked

You can change the colors:

\starttyping
\definecolor[word:yes]    [g=.75]
\definecolor[word:no]     [r=.75]
\stoptyping

The second method doesn't show anything but produces a file \type
{jobname.words}) with used words. The \type {found} value of \type {list} is used
as key in the produced table.

\startbuffer
\setupspellchecking[state=start,method=2,list=found]
\en Is this written right or is this wrong?\par
\nl Is dit goed geschreven of niet?\par
\setupspellchecking[state=stop]
\stopbuffer

\typebuffer \startpacked \getbuffer \stoppacked

The produced table is:

\typefile{\jobname.words}

The result can be traced with a module:

\startbuffer
\usemodule[s-languages-words]

\showwords
\stopbuffer

\typebuffer

This shows up as:

\getbuffer

The third mechanism colors languages differently. We only defined a few colors:

\starttyping
\definecolor[word:en]     [b=.75]
\definecolor[word:de]     [r=.75]
\definecolor[word:nl]     [g=.75]
\definecolor[word:unknown][r=.75,g=.75]
\stoptyping

but you can of course define a color for your favourite language in a similar way.

\startbuffer
\setupspellchecking[state=start,method=3]
\en Is this written right or is this wrong?\par
\nl Is dit goed geschreven of niet?\par
\setupspellchecking[state=stop]
\stopbuffer

\typebuffer \startpacked \getbuffer \stoppacked

\stopsection

\stopchapter

\stopcomponent