| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
local err = gregoriotex.module.err |
| 25 |
local warn = gregoriotex.module.warn |
| 26 |
local info = gregoriotex.module.info |
| 27 |
local log = gregoriotex.module.log |
| 28 |
|
| 29 |
local catcode_at_letter = luatexbase.catcodetables['gre@atletter'] |
| 30 |
local number_to_letter = gregoriotex.number_to_letter |
| 31 |
local special_characters = {} |
| 32 |
local next_special = 0 |
| 33 |
|
| 34 |
function gregoriotex.define_special_character(sequence) |
| 35 |
local substitution = special_characters[sequence] |
| 36 |
if substitution == nil then |
| 37 |
substitution = string.gsub(tostring(next_special), '[0-9]', number_to_letter) |
| 38 |
special_characters[sequence] = substitution |
| 39 |
next_special = next_special + 1 |
| 40 |
end |
| 41 |
tex.print(catcode_at_letter, |
| 42 |
string.format([[\gdef\gre@special@%s]], substitution)) |
| 43 |
end |
| 44 |
|
| 45 |
function gregoriotex.undefine_special_character(sequence) |
| 46 |
local substitution = special_characters[sequence] |
| 47 |
if substitution ~= nil then |
| 48 |
special_characters[sequence] = nil |
| 49 |
tex.print(catcode_at_letter, |
| 50 |
string.format([[\let\gre@special@%s\undefined\relax ]], substitution)) |
| 51 |
end |
| 52 |
end |
| 53 |
|
| 54 |
function gregoriotex.special_character(sequence) |
| 55 |
local substitution = special_characters[sequence] |
| 56 |
if substitution ~= nil then |
| 57 |
tex.print(catcode_at_letter, string.format([[\gre@special@%s\relax ]], substitution)) |
| 58 |
else |
| 59 |
tex.print(sequence) |
| 60 |
end |
| 61 |
end |