public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: EBkysko <ebkysko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: Extract media from different .docx files to same directory
Date: Wed, 18 Mar 2020 05:00:58 -0700 (PDT)	[thread overview]
Message-ID: <01bc2b4a-fa92-4b39-a31c-f95d0abf2272@googlegroups.com> (raw)
In-Reply-To: <d4ebfb5f-13a8-49d8-9a54-2a40dd0d9482-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 1464 bytes --]

I hoped "--id-prefix" would work, but no go, it only works for footnotes.

Here's a *crude* solution as a Lua filter to prefix the images with the md 
output file name (I used "--extract-media" option in my tests) :

----------
local outputfile = PANDOC_STATE.output_file:gsub("%.md", "")

local function prefixName(s)
  return s:gsub("([^/]*)$", outputfile .. "_%1")
end

function Image(img)
  img.src = prefixName(img.src)
  return img
end

function Pandoc(doc)
  for fp, mt, contents in pandoc.mediabag.items() do
    local fpnew = prefixName(fp)
    pandoc.mediabag.insert(fpnew, mt, contents)
    pandoc.mediabag.delete(fp)
  end
end
----------

I thought changing the mediabag files names would suffice, but I also 
needed to make change in Image.
You could use something else for the prefix (eg sha1 hashes of image 
content, which would avoid duplicates under different names).
Maybe one could simple do a file rename in the mediabag, instead of 
creating a new one and deleting old one.
As I said, it's crude. Maybe I missed a simpler solution.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/01bc2b4a-fa92-4b39-a31c-f95d0abf2272%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 9546 bytes --]

  parent reply	other threads:[~2020-03-18 12:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-17 17:33 growig mail
     [not found] ` <d4ebfb5f-13a8-49d8-9a54-2a40dd0d9482-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-03-18 12:00   ` EBkysko [this message]
     [not found]     ` <01bc2b4a-fa92-4b39-a31c-f95d0abf2272-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-03-18 13:15       ` EBkysko
     [not found]         ` <525ed042-e47c-4fc5-b13f-91560718ba83-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-03-18 20:19           ` BPJ
     [not found]             ` <CADAJKhABAeRjQ9RAKbxo+-OPgd5NfCqiy1XP-iDCgKaTkxXYVg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-03-18 22:36               ` EBkysko
     [not found]                 ` <6d556139-e107-4ad4-a99d-62b07bd9ad3d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-03-18 23:41                   ` BPJ
     [not found]                     ` <CADAJKhBfF-_hkBLJ0M5AnAL4aWJMs03JDbNj3wjjD7P6_-6fcA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-03-18 23:54                       ` EBkysko
     [not found]                         ` <a74b610a-732f-4595-9b93-7773542ad4c0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-08-19  9:44                           ` Mario Valle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=01bc2b4a-fa92-4b39-a31c-f95d0abf2272@googlegroups.com \
    --to=ebkysko-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).