From 4e006be646fba8dde7284cfe4c18f0222e8298ad Mon Sep 17 00:00:00 2001 From: sanine Date: Mon, 19 Dec 2022 03:42:29 -0600 Subject: add help page and hidden mode --- language.lua | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'language.lua') diff --git a/language.lua b/language.lua index cf6725f..b6a2f77 100644 --- a/language.lua +++ b/language.lua @@ -53,8 +53,12 @@ end local function parse_syllables(str) local syllables = {} for line in lines(str) do - line = string.gsub(line, "%s", "") - table.insert(syllables, string_to_array(line)) + if string.match(line, "^%s*$") then + -- ignore blank lines + else + line = string.gsub(line, "%s", "") + table.insert(syllables, string_to_array(line)) + end end return syllables end @@ -70,13 +74,17 @@ local function parse_orthography(str, phonemes) -- trim whitespace line = string.gsub(line, "%s*$", "") local pattern, replace = string.match(line, "(.*)=(.*)") - pattern = string.gsub(pattern, "%%(.)", function(class) - if phonemes[class] == nil then - return '%' .. class - end - return '[' .. table.concat(phonemes[class], '') .. ']' - end) - table.insert(rules, { pattern=pattern, replace=replace }) + if not pattern then + -- ??? + else + pattern = string.gsub(pattern, "%%(.)", function(class) + if phonemes[class] == nil then + return '%' .. class + end + return '[' .. table.concat(phonemes[class], '') .. ']' + end) + table.insert(rules, { pattern=pattern, replace=replace }) + end end end return rules -- cgit v1.2.1