From 7f537e9195a4c6edcffefc823646615006a7f034 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Sat, 11 May 2024 01:36:34 +0200 Subject: [PATCH] Fix image paths in JATS --- data/{filters/unify-image-paths.lua => custom/jats.lua} | 8 ++++++-- data/defaults/jats.yaml | 8 ++------ 2 files changed, 8 insertions(+), 8 deletions(-) rename data/{filters/unify-image-paths.lua => custom/jats.lua} (83%) diff --git a/data/filters/unify-image-paths.lua b/data/custom/jats.lua similarity index 83% rename from data/filters/unify-image-paths.lua rename to data/custom/jats.lua index a6887be..53e3ebc 100644 --- a/data/filters/unify-image-paths.lua +++ b/data/custom/jats.lua @@ -19,7 +19,7 @@ local function unnest (filepath, contents) return newpath end -function Pandoc (doc) +function Writer (doc, opts) -- Ensure that all images have been fetched. doc = mediabag.fill(doc) local newpath @@ -30,10 +30,14 @@ function Pandoc (doc) mediabag.delete(fp) mediabag.insert(newpath, mt, contents) end - return doc:walk { + doc = doc:walk { Image = function (img) img.src = updated_filepath[img.src] or img.src return img end } + pandoc.mediabag.write('paper.jats') + return pandoc.write(doc, 'jats_publishing+element_citations', opts) end + +Template = pandoc.template.default 'jats' diff --git a/data/defaults/jats.yaml b/data/defaults/jats.yaml index f8e846f..c490360 100644 --- a/data/defaults/jats.yaml +++ b/data/defaults/jats.yaml @@ -1,6 +1,6 @@ -to: jats_publishing+element_citations +to: jats.lua output-file: paper.jats/paper.jats -extract-media: paper.jats + filters: - # Handle `\ref`, `\label`, and `\autoref` commands @@ -18,7 +18,3 @@ filters: # do it here for that reason. type: lua path: orcid-uri.lua - - - # Ensure that images are placed on the top-level, not in subfolders. - type: lua - path: unify-image-paths.lua