summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-04-04 20:14:07 +0000
committerKarl Berry <karl@freefriends.org>2023-04-04 20:14:07 +0000
commite125f15c0029ec8a90e2a6f738d99d5583f8d011 (patch)
tree1c030779db5b4a3d1bcc287406a32e534a83ad2f /Master/texmf-dist/tex
parent261243b388f0561e9089b1eafed6b2e32a7c3987 (diff)
scikgtex (4apr23)
git-svn-id: svn://tug.org/texlive/trunk@66764 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/lualatex/scikgtex/scikgtex.lua44
-rw-r--r--Master/texmf-dist/tex/lualatex/scikgtex/scikgtex.sty34
2 files changed, 53 insertions, 25 deletions
diff --git a/Master/texmf-dist/tex/lualatex/scikgtex/scikgtex.lua b/Master/texmf-dist/tex/lualatex/scikgtex/scikgtex.lua
index 94bd0c1f40d..8703d66666a 100644
--- a/Master/texmf-dist/tex/lualatex/scikgtex/scikgtex.lua
+++ b/Master/texmf-dist/tex/lualatex/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/Master/texmf-dist/tex/lualatex/scikgtex/scikgtex.sty b/Master/texmf-dist/tex/lualatex/scikgtex/scikgtex.sty
index 9f94c11a1b4..6e605e6a66b 100644
--- a/Master/texmf-dist/tex/lualatex/scikgtex/scikgtex.sty
+++ b/Master/texmf-dist/tex/lualatex/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)%
}%
}%