aboutsummaryrefslogtreecommitdiff
path: root/_extensions
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2025-05-14 17:28:31 +0200
committerJonas Smedegaard <dr@jones.dk>2025-05-14 17:28:31 +0200
commit50ac9dc677b44b87897cc6b2f340f641dc31460e (patch)
tree5c9b343ce01a7f90f28daa8af4546c900076ccac /_extensions
parent3555b9ce3e004fef9fdbd3b3ce87f8d70dc63902 (diff)
declare file-wide variable as <const>
Diffstat (limited to '_extensions')
-rw-r--r--_extensions/ruc-play/semantic-markdown/semantic-markdown.lua44
1 files changed, 22 insertions, 22 deletions
diff --git a/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua b/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua
index f076950..ef55076 100644
--- a/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua
+++ b/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua
@@ -128,34 +128,34 @@ local ElementTypeIsEnclosure = {
Strong = true,
}
---- curie_type_prefix - `typeof` or `resource` attribute CURIE hint
-local curie_type_prefix = "[.=]?"
+--- CURIE_TYPE_PREFIX - `typeof` or `resource` attribute CURIE hint
+local CURIE_TYPE_PREFIX <const> = "[.=]?"
-- TODO: cover non-ASCII Unicode characters
-- @see <https://www.lua.org/manual/5.4/manual.html#6.5>
---- curie_prefix - CURIE prefix component as set of chars
+--- CURIE_PREFIX - CURIE prefix component as set of chars
--- @see <https://www.w3.org/TR/2010/NOTE-curie-20101216/>
-local _name_start_char = "A-Z_a-z"
-local _name_char = _name_start_char.."-0-9"
-local _ref = "[".._name_start_char.."][".._name_char.."]*"
-local curie_prefix = "[".._name_start_char.."_-][".._name_char.."]*"
+local _NAME_START_CHAR <const> = "A-Z_a-z"
+local _NAME_CHAR <const> = _NAME_START_CHAR.."-0-9"
+local _REF <const> = "[".._NAME_START_CHAR.."][".._NAME_CHAR.."]*"
+local CURIE_PREFIX <const> = "[".._NAME_START_CHAR.."_-][".._NAME_CHAR.."]*"
---- curie_long - CURIE with prefix and reference as set of chars
-local curie_long = curie_prefix..":".._ref
+--- CURIE_LONG - CURIE with prefix and reference as set of chars
+local CURIE_LONG <const> = CURIE_PREFIX..":".._REF
---- curie_no_ref - CURIE with only prefix as set of chars
-local curie_no_ref = curie_prefix..":"
+--- CURIE_NO_REF - CURIE with only prefix as set of chars
+local CURIE_NO_REF <const> = CURIE_PREFIX..":"
---- curie_local - CURIE with only name as set of chars
-local curie_local = ":".._ref
+--- CURIE_LOCAL - CURIE with only name as set of chars
+local CURIE_LOCAL <const> = ":".._REF
---- curie_default - CURIE without prefix or name as char
-local curie_default = ":"
+--- CURIE_DEFAULT - CURIE without prefix or name as char
+local CURIE_DEFAULT <const> = ":"
--- TODO: curie_re - CURIE as `LPeg.re` regex object
+-- TODO: CURIE_re - CURIE as `LPeg.re` regex object
-- TODO: test and replace above curie* patterns
-- @see <https://pandoc.org/lua-filters.html#global-variables>
---local curie_re = re.compile("("..curie_prefix..")?:(".._ref..")?")
+--local CURIE_re <const> = re.compile("("..CURIE_PREFIX..")?:(".._REF..")?")
-- FIXME: define RDF context same as RDFa
-- TODO: maybe support overriding context with a JSON-LD URI
@@ -187,7 +187,7 @@ local curie_default = ":"
local function Namespaces(blocks)
-- paragraph with only a braced prefix-only CURIE, colon and one word
- local curie_pattern = "^{"..curie_type_prefix..curie_prefix.."}:$"
+ local curie_pattern = "^{"..CURIE_TYPE_PREFIX..CURIE_PREFIX.."}:$"
if #blocks.content == 3
and blocks.content[1].t == "Str"
and blocks.content[2].t == "Space"
@@ -407,10 +407,10 @@ local function Statements (block)
-- in braced enclosure, leaving it
-- TODO: support mixed-use enclosure
if encl == Enclosure.BRACED then
- local curie_pattern1 = "^"..curie_type_prefix..curie_long.."}"
- local curie_pattern2 = "^"..curie_type_prefix..curie_no_ref.."}"
- local curie_pattern3 = "^"..curie_type_prefix..curie_local.."}"
- local curie_pattern4 = "^"..curie_type_prefix..curie_default.."}"
+ local curie_pattern1 = "^"..CURIE_TYPE_PREFIX..CURIE_LONG.."}"
+ local curie_pattern2 = "^"..CURIE_TYPE_PREFIX..CURIE_NO_REF.."}"
+ local curie_pattern3 = "^"..CURIE_TYPE_PREFIX..CURIE_LOCAL.."}"
+ local curie_pattern4 = "^"..CURIE_TYPE_PREFIX..CURIE_DEFAULT.."}"
local _, nextpos1 = el.text:find(curie_pattern1, pos)
local _, nextpos2 = el.text:find(curie_pattern2, pos)
local _, nextpos3 = el.text:find(curie_pattern3, pos)