From e9f267fd4c8414d6146c5fee0dbe459613dd0f3b Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Tue, 4 Apr 2023 03:01:33 +0000 Subject: CTAN sync 202304040301 --- macros/luatex/latex/scikgtex/README | 21 -------------- macros/luatex/latex/scikgtex/README.md | 20 ++++++++++++++ macros/luatex/latex/scikgtex/scikgtex.lua | 44 ++++++++++++++++++++---------- macros/luatex/latex/scikgtex/scikgtex.pdf | Bin 0 -> 958167 bytes macros/luatex/latex/scikgtex/scikgtex.sty | 34 ++++++++++++++++------- 5 files changed, 73 insertions(+), 46 deletions(-) delete mode 100644 macros/luatex/latex/scikgtex/README create mode 100644 macros/luatex/latex/scikgtex/README.md create mode 100644 macros/luatex/latex/scikgtex/scikgtex.pdf (limited to 'macros/luatex/latex') diff --git a/macros/luatex/latex/scikgtex/README b/macros/luatex/latex/scikgtex/README deleted file mode 100644 index e754496c6f..0000000000 --- a/macros/luatex/latex/scikgtex/README +++ /dev/null @@ -1,21 +0,0 @@ -SciKGTeX -------------- -AUTHOR - Christof Bless, christofbless@gmail.com - -DESCRIPTION - Scientific Knowledge Graph TeX (SciKgTeX) is a LuaLaTeX package which makes - it possible to annotate specific research contributions in scientific documents. - 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 - -VERSION - 2.1.1 (13.11.2022) - -LICENSE - This work is published under MIT License. https://opensource.org/licenses/MIT - - Copyright (C) 2022 Christof Bless diff --git a/macros/luatex/latex/scikgtex/README.md b/macros/luatex/latex/scikgtex/README.md new file mode 100644 index 0000000000..36dc96ca8e --- /dev/null +++ b/macros/luatex/latex/scikgtex/README.md @@ -0,0 +1,20 @@ +SciKGTeX +------------- +AUTHOR + Christof Bless, christofbless@gmail.com + +DESCRIPTION + Scientific Knowledge Graph TeX (SciKgTeX) is a LuaLaTeX package which makes + it possible to annotate specific research contributions in scientific documents. + 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. + For more information on how to use the package consult documentation SciKGTeX.pdf. + +VERSION + 2.2.0 (03.04.2023) + +LICENSE + This work is published under MIT License. https://opensource.org/licenses/MIT + + Copyright (C) 2022 Christof Bless 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 = [[]] -XMP.XMP_BOTTOM = [[ -]] +XMP.XMP_BOTTOM = [[]] XMP.PACKET_END = [[]] 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(' ') + if i==1 then + if #sorted_contributions > 1 then + self:add_line(' ') + else + self:add_line(' ') + end + end self:add_line( ' ', self.paper.id .. "/" ..contribution.id @@ -611,10 +620,13 @@ function XMP:generate_xmp_string(lb_char) ) end self:add_line(' ') - self:add_line(' ') + if i == #sorted_contributions then + self:add_line(' ') + end end self:add_line(' ') end + self:add_line('') 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 Binary files /dev/null and b/macros/luatex/latex/scikgtex/scikgtex.pdf 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)% }% }% -- cgit v1.2.3