From c8ad87c59dec9e50d88e6314199b5fef24f9335c Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sat, 10 May 2025 14:14:33 +0200 Subject: resolve block element only once --- _extensions/ruc-play/semantic-markdown/semantic-markdown.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 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 0ce1dcd..ef02b83 100644 --- a/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua +++ b/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua @@ -133,13 +133,14 @@ local function Namespaces(blocks) and blocks.content[2].t == "Space" and blocks.content[1].text:match(curie_pattern) then + local el = blocks.content[3] -- default namespace, misparsed as a citation - if blocks.content[3].t == "Cite" - and #blocks.content[3].content == 1 + if el.t == "Cite" + and #el.content == 1 -- TODO: maybe check case-insensitively - and blocks.content[3].content[1].text == "@default" + and el.content[1].text == "@default" then -- FIXME: add CURIE to metadata return {} @@ -147,11 +148,11 @@ local function Namespaces(blocks) -- namespace local proto_pattern = "^https?:" - if blocks.content[3].t == "Str" + if el.t == "Str" -- TODO: maybe check case-insensitively -- TODO: relax to match URI syntax without hardcoded protocols - and blocks.content[3].text:match(proto_pattern) + and el.text:match(proto_pattern) then -- FIXME: add CURIE and URI to metadata return {} -- cgit v1.2.3