From 50ac9dc677b44b87897cc6b2f340f641dc31460e Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Wed, 14 May 2025 17:28:31 +0200 Subject: declare file-wide variable as --- .../semantic-markdown/semantic-markdown.lua | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to '_extensions') 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 = "[.=]?" -- TODO: cover non-ASCII Unicode characters -- @see ---- curie_prefix - CURIE prefix component as set of chars +--- CURIE_PREFIX - CURIE prefix component as set of chars --- @see -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 = "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.."]*" ---- 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 = 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 = 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 = ":".._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 = ":" --- 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 ---local curie_re = re.compile("("..curie_prefix..")?:(".._ref..")?") +--local CURIE_re = 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) -- cgit v1.2.3