summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/scikgtex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-04-04 03:01:33 +0000
committerNorbert Preining <norbert@preining.info>2023-04-04 03:01:33 +0000
commite9f267fd4c8414d6146c5fee0dbe459613dd0f3b (patch)
tree83fb57a85aee532d8ccb344a7a808a446c31054d /macros/luatex/latex/scikgtex
parent3b4a242af88203c2f3f551d46161bdd037c0d127 (diff)
CTAN sync 202304040301
Diffstat (limited to 'macros/luatex/latex/scikgtex')
-rw-r--r--macros/luatex/latex/scikgtex/README.md (renamed from macros/luatex/latex/scikgtex/README)5
-rw-r--r--macros/luatex/latex/scikgtex/scikgtex.lua44
-rw-r--r--macros/luatex/latex/scikgtex/scikgtex.pdfbin0 -> 958167 bytes
-rw-r--r--macros/luatex/latex/scikgtex/scikgtex.sty34
4 files changed, 55 insertions, 28 deletions
diff --git a/macros/luatex/latex/scikgtex/README b/macros/luatex/latex/scikgtex/README.md
index e754496c6f..36dc96ca8e 100644
--- a/macros/luatex/latex/scikgtex/README
+++ b/macros/luatex/latex/scikgtex/README.md
@@ -9,11 +9,10 @@ DESCRIPTION
SciKGTeX will enrich the document by adding the marked contributions to PDF metadata
in a structured XMP format which can be picked up by Search Engines and
Knowledge Graphs.
- More information on how to use the package can be found here:
- https://github.com/Christof93/SciKGTeX#readme
+ For more information on how to use the package consult documentation SciKGTeX.pdf.
VERSION
- 2.1.1 (13.11.2022)
+ 2.2.0 (03.04.2023)
LICENSE
This work is published under MIT License. https://opensource.org/licenses/MIT
diff --git a/macros/luatex/latex/scikgtex/scikgtex.lua b/macros/luatex/latex/scikgtex/scikgtex.lua
index 94bd0c1f40..8703d66666 100644
--- a/macros/luatex/latex/scikgtex/scikgtex.lua
+++ b/macros/luatex/latex/scikgtex/scikgtex.lua
@@ -21,8 +21,7 @@ XMP.lines = {}
XMP.namespaces = {}
XMP.property_ns = {}
XMP.XMP_TOP = [[<x:xmpmeta xmlns:x="adobe:ns:meta/">]]
-XMP.XMP_BOTTOM = [[</rdf:RDF>
-</x:xmpmeta>]]
+XMP.XMP_BOTTOM = [[</x:xmpmeta>]]
XMP.PACKET_END = [[<?xpacket end="r"?>]]
local UUID = {}
@@ -379,11 +378,15 @@ function SciKGTeX:warn_unused_command()
end
end
-function SciKGTeX:print_entity(uri, label)
- if label ~= "" then
- tex.print(string.format('\\href{%s}{%s}',uri , label))
- else
+function SciKGTeX:print_entity(uri, label, hyperrefloaded)
+ if label ~= "" and hyperrefloaded then
+ tex.print(string.format('\\href{%s}{%s}', uri , label))
+ elseif label ~= "" then
+ tex.print(label)
+ elseif hyperrefloaded then
tex.print(string.format('\\url{%s}',uri))
+ else
+ tex.print(uri)
end
end
@@ -595,7 +598,13 @@ function XMP:generate_xmp_string(lb_char)
end
for i, cb_id in pairs(sorted_contributions) do
contribution = self.paper.contributions[cb_id]
- self:add_line(' <orkg:hasResearchContribution>')
+ if i==1 then
+ if #sorted_contributions > 1 then
+ self:add_line(' <orkg:hasResearchContribution rdf:parseType="Collection">')
+ else
+ self:add_line(' <orkg:hasResearchContribution>')
+ end
+ end
self:add_line(
' <orkg:ResearchContribution rdf:about="https://www.orkg.org/orkg/paper/%s">',
self.paper.id .. "/" ..contribution.id
@@ -611,10 +620,13 @@ function XMP:generate_xmp_string(lb_char)
)
end
self:add_line(' </orkg:ResearchContribution>')
- self:add_line(' </orkg:hasResearchContribution>')
+ if i == #sorted_contributions then
+ self:add_line(' </orkg:hasResearchContribution>')
+ end
end
self:add_line(' </rdf:Description>')
end
+ self:add_line('</rdf:RDF>')
self:add_line(self.XMP_BOTTOM)
self:add_line(self.PACKET_END)
@@ -622,11 +634,11 @@ function XMP:generate_xmp_string(lb_char)
end
-function XMP:attach_metadata_pdfstream()
+function XMP:attach_metadata_pdfstream(metadata_type)
local xmp_string = self:generate_xmp_string()
local new_pdf = pdf.obj {
type = 'stream',
- attr = '/Type/Metadata /Subtype/XML',
+ attr = '/Type /'..metadata_type..' /Subtype /XML',
immediate = true,
compresslevel = 0,
string = xmp_string,
@@ -654,12 +666,14 @@ end, 'at_end')
-- Writing metadata packets
luatexbase.add_to_callback('finish_pdffile', function()
if XMP.paper then
- local metadata_obj = XMP:attach_metadata_pdfstream()
+ if CONFORM_TO_PDFA then
+ catalog_key='SciKGMetadata'
+ else
+ catalog_key='Metadata'
+ end
+ local metadata_obj = XMP:attach_metadata_pdfstream(catalog_key)
local catalog = pdf.getcatalog() or ''
- pdf.setcatalog(catalog..string.format('/Metadata %s 0 R', metadata_obj))
- --if SciKGTeX.PRODUCE_XMP_FILE then
- -- XMP:dump_metadata()
- --end
+ pdf.setcatalog(catalog..string.format('/%s %s 0 R', catalog_key, metadata_obj))
end
end, 'finish')
diff --git a/macros/luatex/latex/scikgtex/scikgtex.pdf b/macros/luatex/latex/scikgtex/scikgtex.pdf
new file mode 100644
index 0000000000..ec91d95a48
--- /dev/null
+++ b/macros/luatex/latex/scikgtex/scikgtex.pdf
Binary files differ
diff --git a/macros/luatex/latex/scikgtex/scikgtex.sty b/macros/luatex/latex/scikgtex/scikgtex.sty
index 9f94c11a1b..6e605e6a66 100644
--- a/macros/luatex/latex/scikgtex/scikgtex.sty
+++ b/macros/luatex/latex/scikgtex/scikgtex.sty
@@ -16,10 +16,10 @@
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{scikgtex}[2022/11/13 v2.1.1]
-
+%
\def\useignorespacesandallpars#1\ignorespaces\fi{%
#1\fi\ignorespacesandallpars}
-
+%
\makeatletter
\def\ignorespacesandallpars{%
\@ifnextchar\par
@@ -27,15 +27,23 @@
{}%
}
\makeatother
-
+%
\RequirePackage{suffix}
-\RequirePackage{hyperref}
-
+%% init variable which checks if hyperref is loaded.
+\newcommand{\hyperrefloaded}{null}%
+%
\errorcontextlines=5
-
-\directlua {
- SciKGTeX = require('scikgtex')
+%
+\directlua {%
+ SciKGTeX = require('scikgtex')%
+ CONFORM_TO_PDFA = false%
+}
+\DeclareOption{compatibility}{
+ \directlua {%
+ CONFORM_TO_PDFA = true%
+ }
}
+\ProcessOptions\relax
\newcommand{\addmetaproperty}[2][]{%
\directlua{%
@@ -102,12 +110,18 @@
}%
\ignorespaces
}%
-
+%
\newcommand{\uri}[2]{%
+ \ifcsname href\endcsname%
+ \renewcommand{\hyperrefloaded}{true}%
+ \else%
+ \renewcommand{\hyperrefloaded}{false}%
+ \fi%
+%
\directlua{%
local label = "\luaescapestring{\unexpanded{#2}}"%
local uri = "\luaescapestring{\unexpanded{#1}}"%
- SciKGTeX:print_entity(uri, label)%
+ SciKGTeX:print_entity(uri, label, \hyperrefloaded)%
}%
}%