From 56f470fca333e41c62f976db64efab40f91c1954 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Wed, 5 Aug 2020 13:29:14 +0200 Subject: newfunction checkxmlid(id). it should be some way extended to \label, \cite and the like --- ekdosis.dtx | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/ekdosis.dtx b/ekdosis.dtx index 29c3626..c7c2a67 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -5416,6 +5416,16 @@ local function xmlidfound(element) return false end +local function checkxmlid(str) + if string.find(str, "^[0-9]") + or string.find(str, "[:; ]") + then + return false + else + return true + end +end + -- Witnesses listWit = {} idsRend = {} @@ -5477,7 +5487,14 @@ function ekdosis.newwitness(id, then tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" ..id.. - "\" already exists as a xml:id. " + "\" already exists as an xml:id. " + .. + "Please pick another id.}}") + elseif not checkxmlid(id) + then + tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" + ..id.. + "\" is not a valid xml:id. " .. "Please pick another id.}}") else @@ -5510,7 +5527,14 @@ function ekdosis.newhand(id, witid, siglum, description) then tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" ..id.. - "\" already exists as a xml:id. " + "\" already exists as an xml:id. " + .. + "Please pick another id.}}") + elseif not checkxmlid(id) + then + tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" + ..id.. + "\" is not a valid xml:id. " .. "Please pick another id.}}") else @@ -5560,9 +5584,16 @@ function ekdosis.newscholar(id, siglum) then tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" ..id.. - "\" already exists as a xml:id. " + "\" already exists as an xml:id. " .. "Please pick another id.}}") + elseif not checkxmlid(id) + then + tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" + ..id.. + "\" is not a valid xml:id. " + .. + "Please pick another id.}}") else table.insert(xmlids, {xmlid = id}) table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end) @@ -6616,9 +6647,16 @@ function ekdosis.newscholar(id, siglum) then tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" ..id.. - "\" already exists as a xml:id. " + "\" already exists as an xml:id. " .. "Please pick another id.}}") + elseif not checkxmlid(id) + then + tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" + ..id.. + "\" is not a valid xml:id. " + .. + "Please pick another id.}}") else table.insert(xmlids, {xmlid = id}) table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end) @@ -6641,10 +6679,17 @@ local function build_envdiv(str) then tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" ..div.. - "\" already exists as a xml:id. " + "\" already exists as an xml:id. " .. "ekdosis has generated some random id.}}") return "div-"..math.random(1000,9999) + elseif not checkxmlid(id) + then + tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" + ..id.. + "\" is not a valid xml:id. " + .. + "Please pick another id.}}") else table.insert(xmlids, {xmlid = div}) table.sort(xmlids, function(a ,b) return(#a.xmlid > #b.xmlid) end) -- cgit v1.2.3