Skip to content

Commit

Permalink
Improve
Browse files Browse the repository at this point in the history
  • Loading branch information
ZwerOxotnik committed May 27, 2024
1 parent 63ba28e commit 2765c61
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 74 deletions.
50 changes: 0 additions & 50 deletions .github/workflows/autoPublish.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .scripts/zip_mod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
(set -o igncr) 2>/dev/null && set -o igncr; # This comment is required.
### The above line ensures that the script can be run on Cygwin/Linux even with Windows CRNL.
### Run this script after updating the mod to prepare a zip of it.

main() {
### Check commands
if ! command -v git &> /dev/null; then
echo "Please install/use git https://git-scm.com/downloads"
fi
local has_errors=false
if ! command -v 7z &> /dev/null; then
echo "Please install 7-Zip https://www.7-zip.org/download.html"
local has_errors=true
fi
if [ $has_errors = true ] ; then
exit 1
fi


### mod_folder is a mod directory with info.json
local init_dir=`pwd`

echo "Target folder: ${init_dir}"


### Prepare zip
### https://www.7-zip.org/download.html
local name="sitelen_pona_lua"
if command -v git &> /dev/null; then
git clean -xdf
fi
7z a -xr'!.*' "${init_dir}/${name}.zip" "${init_dir}"
}
main
12 changes: 11 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "zip mod",
"type": "shell",
"command": "bash",
"args": [".scripts/zip_mod.sh"],
"group": "build",
"presentation": {
"reveal": "silent",
}
},
{
"label": "Luacheck",
"type": "shell",
"command": "luacheck",
"args": ["${file}"],
"group": "test"
},
}
]
}
43 changes: 20 additions & 23 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ M.ConScriptParts_to_string(parts: ConScriptPart[], new_line_characters="\r\n"):

---@class ConScriptModule : module
local M = {
_VERSION = "0.2.0",
_VERSION = "0.2.1",
_LICENSE = "MIT",
_SOURCE = "https://github.com/ZwerOxotnik/sitelen_pona_lua",
_URL = "https://github.com/ZwerOxotnik/sitelen_pona_lua"
Expand Down Expand Up @@ -361,6 +361,7 @@ function M.ligature(language, font, parts)
local ligature_length = 0
local ligature_lexicon = _ligature_lexicon
local i = 0
while true do
while true do
if i == #parts_copy then
return parts_copy, #parts_copy ~= #parts
Expand All @@ -372,14 +373,14 @@ function M.ligature(language, font, parts)
ligature_length = 0
ligature_lexicon = _ligature_lexicon
original_text = ""
goto skip
break -- it's continue actually
end

if part.original == "-" then
if ligature_length > 0 then
ligature_length = ligature_length + 1
end
goto skip
break -- it's continue actually
end

ligature_lexicon = ligature_lexicon[part.result_text] or _ligature_lexicon
Expand All @@ -390,15 +391,15 @@ function M.ligature(language, font, parts)
ligature_lexicon = ligature_lexicon[part.result_text]
if ligature_lexicon == nil then
ligature_lexicon = _ligature_lexicon
goto skip
break -- it's continue actually
end
end

ligature_length = ligature_length + 1

original_text = original_text .. part.original .. " "
if type(ligature_lexicon) ~= "table" then
goto skip
if type(ligature_lexicon) == "table" then
break -- it's continue actually
end

local prev_i = i - ligature_length + 1
Expand All @@ -411,8 +412,7 @@ function M.ligature(language, font, parts)
original = original_text,
is_add_space = part.is_add_space
}

::skip::
end
end
end

Expand All @@ -432,24 +432,21 @@ function M.ConScriptParts_to_string(parts, new_line_characters)
if part.is_new_line then
r_i = r_i + 1
results[r_i] = new_line_characters
goto continue
end

r_i = r_i + 1
if part.result_text then
results[r_i] = part.result_text
is_ConScript_part = true
else
results[r_i] = part.original
is_ConScript_part = false
end

if not is_ConScript_part and part.is_add_space then
r_i = r_i + 1
results[r_i] = " "
end
if part.result_text then
results[r_i] = part.result_text
is_ConScript_part = true
else
results[r_i] = part.original
is_ConScript_part = false
end

::continue::
if not is_ConScript_part and part.is_add_space then
r_i = r_i + 1
results[r_i] = " "
end
end
end

return table.concat(results, "")
Expand Down

0 comments on commit 2765c61

Please sign in to comment.