From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/24663 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: BPJ Newsgroups: gmane.text.pandoc Subject: Re: Extract media from different .docx files to same directory Date: Thu, 19 Mar 2020 00:41:46 +0100 Message-ID: References: <01bc2b4a-fa92-4b39-a31c-f95d0abf2272@googlegroups.com> <525ed042-e47c-4fc5-b13f-91560718ba83@googlegroups.com> <6d556139-e107-4ad4-a99d-62b07bd9ad3d@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000023c61105a1299948" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="80068"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCWMVYEK54FRBR7DZLZQKGQE4Y6E3GI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Mar 19 00:42:03 2020 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-ed1-f63.google.com ([209.85.208.63]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jEiK2-000KhN-35 for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 19 Mar 2020 00:42:02 +0100 Original-Received: by mail-ed1-f63.google.com with SMTP id b100sf323575edf.15 for ; Wed, 18 Mar 2020 16:42:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1584574921; cv=pass; d=google.com; s=arc-20160816; b=acUpjZS5cbbl0UE1z8s6zxEM2DeFk+JFhNGSF4sVnDXyG0sXcy/2lEkQ6RnHhajKmq esv+/u0nBeYuDNxLyv6LegLdNKuciCqQ77FVNuqckinqSKyi2mSc5bxvcdv/K1MWDdk/ Dbre0IqT7PXUTQRdR8xux9Nlmoa9sv4YudaTkykP15Bw5NCo2yV2F3e38UN8lgO6kmuz g3ok1ZSTyEalfWpN6dLyXDm/nzxdv6HBQlQGxMcnSilwQ6+j4KCoFu3z/r1lYvgZJhl7 oirAhP8oYEeFQTM9lAdQCE6P8KCTcky2POU5B5/yR1PwJLLqKsgH8vg2PFBSV74lBOSj Py0Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date :from:in-reply-to:references:mime-version:sender:dkim-signature :dkim-signature; bh=f7YmrYvn90i3WO2hfGiviLUe/arlHa3xjM3VG8599Xs=; b=kToEVSQL3dNtGjXxj7WTXvJHqmLNvQu5pMbHoxKU9p44VYJrdZEfDF+glbDd+8k687 oLnNymYlHqUNVK2GsDs0gA5QIjTA+24hTgh822wQqCryCfngxHGfkpuNZbdPwSon/t47 nphH7D5xYFufSHLeoAc4UEj25eYTAttnoCuy602/guY6Jn8i64krQZZpDMAl5lfNbiu6 uf3T7amu5+rni1B82vpif09ovj9sv6LI4m1kS7Z08D5J9vf/Rx7+NL1CB610zet/Mf6e hwPBM3WLjWzd14SaMV5i1rSNFwwhoirgs3pRYlzXcRRrz/CZ0wngBDUx2/0aLTN4swGd ZSzA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Q1ES3clv; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::231 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:references:in-reply-to:from:date:message-id :subject:to:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=f7YmrYvn90i3WO2hfGiviLUe/arlHa3xjM3VG8599Xs=; b=kjQmXtXoPzNvprTGLNSc6yubegaF3V/JXQK1qFWizcJ34wI0MKwiDRwmWXcuVuVWl9 eHXRbdjdmUeVnyABiIQtxdvEgPQeRKh+hV/EkDydAHESBnwed32g8jlaNJFX+ZgQ79XG VUVMprHriyq43FvT1zQJ/jNAqlBwTbYOxhNvauzK5BkPIARWGEtNKrZ0XnyL91MLPYPk sTYk3DL6usofYFZmxKcBwq07ke18goAZQibOF2Yrf57zDXWe6kB5oFy3K+lxaZh55CMZ zpB5AwZbPHO8eHIJs1SUTsRGckTAlBKF+oVur7TcBjYARzdy9qjTMSOkCvfDTSdnY3mB 3qHg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=f7YmrYvn90i3WO2hfGiviLUe/arlHa3xjM3VG8599Xs=; b=uKAV7guuAaMii1EWJKCmZfLrDUqow1pUQ2KnfHyX48kbvekXbFCNSsIIG/u3HpQ7sY C/9U0oeEMDopBaJi5Xv2F7hTEsDiE4S8aqF/+a7sM2iQI6LAtyiz7Ume5H9Yeurmeg9/ 3O+2sLvI1CrYMQrr1fVkyA2+iybXBvkrulFHBreofruVU8nk8BkFHKu8MwaBMWUQOJCW vfic4BBK4aeDXaq+QZGlf+YUDzRMzFxkukpnFlR5i9F9qnUMrwUncvbrln5TJDU2mJ95 itnzu+6nLj9If1SC6i54vNdI+D2UemtL1PYUk3i1OOnXFsGwKfgyrDMpGGYb75ZpJJ9T LtQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:references:in-reply-to:from :date:message-id:subject:to:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=f7YmrYvn90i3WO2hfGiviLUe/arlHa3xjM3VG8599Xs=; b=HOgWPJVninprTGI0DlLAffhM6Duuwhkyu52oidU67aPx0JlkSjG5pnWjp0jCtXqoXy HLthYwXOjolngTL97cOyebSBUyyskFsodWH5GOplLh9qUq9lxEI4d+dSn9NstqUnQSNv ZYyF/zAS53dGh/vjf8gJLJt5kvDGJIZ13TLc3g2XkOi7DaUZ19PS0lHRLLZagkCCSFBb g0JMgTFIdfrv+FpXbmJL3zmRt12UdUZt+XqNklg1peBtYHzngT7Sic2r3EiQ46XAjXW7 mGjE6l1JN3vF01gxIfE9xSLJWpU/2F2UmobsChzT7qD7D++FosslVeRrr2pvf3nH0Lvo xIng== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: ANhLgQ1JbU/pgVQ3T48Nm0FBkkESpZcjEbkAmMXaaeUDRgi7nMy8Ac9f nuyZRW9/rwUJbgGGIKQBFiM= X-Google-Smtp-Source: ADFU+vsX1d9wFBLciXNz7PHTwi5qLmkr4CU7nW4l4I+KdvhTJFHqmWekj+kTGPA20UED1SSnYHBAAg== X-Received: by 2002:a17:906:784c:: with SMTP id p12mr700253ejm.296.1584574921710; Wed, 18 Mar 2020 16:42:01 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:aa7:de0a:: with SMTP id h10ls192469edv.11.gmail; Wed, 18 Mar 2020 16:41:59 -0700 (PDT) X-Received: by 2002:aa7:d551:: with SMTP id u17mr34258edr.69.1584574919227; Wed, 18 Mar 2020 16:41:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584574919; cv=none; d=google.com; s=arc-20160816; b=CgVNpWBe5AITeFkoc4vQhwPLwhx5aUMM49zr61u/a3DSd+sQd5Za4PJuxVgjUYPhjW BoVeKDPUD2s+BncLvKIUCWL57z4CQWD/gY5FxmkpGnN1+sHJS++UzO5Ekga4lFVSRzPX zaw0E7sorVCSDNkHRM1ll/0zGPdKpZpIKi04E722qoo+4jg/Yncj1o9D951GvsMNtjUK 6BuJqBZJwYjlW5J5i5s1L2VZEGbaoY/RyZHny4UOgeWjeLHuyI+ReJJ2NZxzkK+/lfPQ 8/piUqNtz/X/2vzjqdf7nmsxYEn3KXqf8tICHld9zhW6BDR79903HuO1MnZfx79GOuL3 Gq7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Qv+FGXXMa6HACHboI40IntXTzXWakyQx+hcGPs6ZjYM=; b=esVT1eo1KkRt4ad9dJ/vpQVyGPNcqN7i9AiZlnNrWxvr9Qn1shxdKs/EfPNJIyDaNw BPBLyTqiOqzqXcsXte4cCSPWdgEsqhMYXWK6mpYYL1vaodcKyyg5TJcAiaGeBkBShiMY LSllYJ+CWumjUYIPKrzxALsmN7PqWeCm4afUQsoj6XEUc7ASMUo0utggV4wHHICP3t4B hn6ZVN2/MeSi7mTiqeP59/AmeUgk9ohKS4zL7k8iudVei/tSBK6ICJu6jo4rLEY6Wr6V l5DWBOYkqDnJLIpHRWgswqFz27hr/xJZFzte4MZRX29sTQ2kXoCxqorFCOyE3GDMCl6o QGUg== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Q1ES3clv; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::231 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com. [2a00:1450:4864:20::231]) by gmr-mx.google.com with ESMTPS id cw13si33493edb.2.2020.03.18.16.41.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Mar 2020 16:41:59 -0700 (PDT) Received-SPF: pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::231 as permitted sender) client-ip=2a00:1450:4864:20::231; Original-Received: by mail-lj1-x231.google.com with SMTP id g12so398906ljj.3 for ; Wed, 18 Mar 2020 16:41:59 -0700 (PDT) X-Received: by 2002:a2e:9754:: with SMTP id f20mr292275ljj.100.1584574918542; Wed, 18 Mar 2020 16:41:58 -0700 (PDT) In-Reply-To: <6d556139-e107-4ad4-a99d-62b07bd9ad3d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Original-Sender: melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Q1ES3clv; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::231 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:24663 Archived-At: --00000000000023c61105a1299948 Content-Type: text/plain; charset="UTF-8" Also there is no guarantee that the file extension on the Markdown file is `.md`. Some people use `.mkd` or `.txt` and it may even be an `.rst` file so it may be better to use the old and tried generic pattern `%.[^%.]*$`, which matches any extension, to match the file extension. Den ons 18 mars 2020 23:37EBkysko skrev: > ah, yes, good, that way we're sure we iterate on a fixed list, a snapshot > before the changes. > > so with this, and a check on the mime type, we get something like : > > > ----- > 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 _,f in ipairs(pandoc.mediabag.list()) do > local fp = f.path > local mt, contents = pandoc.mediabag.lookup(fp) > if mt:match("^[^/]*") == "image" then > local fpnew = prefixName(fp) > pandoc.mediabag.insert(fpnew, mt, contents) > pandoc.mediabag.delete(fp) > end > end > end > ----- > > > -- > 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/6d556139-e107-4ad4-a99d-62b07bd9ad3d%40googlegroups.com > > . > -- 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/CADAJKhBfF-_hkBLJ0M5AnAL4aWJMs03JDbNj3wjjD7P6_-6fcA%40mail.gmail.com. --00000000000023c61105a1299948 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Also there is no guarantee that the file extension on the= Markdown file is `.md`. Some people use `.mkd` or `.txt` and it may even b= e an `.rst` file so it may be better to use the old and tried generic patte= rn `%.[^%.]*$`, which matches any extension, to match the file extension.

Den ons 18 mars 2020 23:37EBkysko <ebkysko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
ah, yes, good, that way we= 9;re sure we iterate on a fixed list, a snapshot before the changes.
<= div>
so with this, and a check on the mime type, we get somet= hing like :


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

local
function prefixName(s)
=C2=A0
retur= n s:
gsub("([^/]*)$", outputfile .. "_%1")
end

function Image(img<= span style=3D"color:#660">)
=C2=A0 img=
.src =3D prefi= xName(i= mg.src<= /span>)
=C2= =A0
return img
end

function Pandoc(doc)
=C2=A0
for _,f in ipairs(pandoc.mediabag.list()) do
=C2=A0 =C2=A0
<= span style=3D"color:#008">local
fp =3D f<= span style=3D"color:#660">.path
=C2=A0= =C2=A0
local mt, contents =3D pandoc.mediabag.lookup(fp)
=C2=A0 =C2=A0
if mt:match("^[^/]*") =3D=3D "image= " = then
=C2=A0 =C2=A0 =C2=A0
local
fpnew = =3D prefixName= (fp)
=C2=A0= =C2=A0 =C2=A0 pandoc
.mediabag.insert(fpnew, mt, contents)
=C2=A0 =C2=A0 =C2=A0 pandoc
.mediabag.delete(fp)
=C2=A0 =C2=A0
end
=C2=A0
<= span style=3D"color:#008">end

<= span style=3D"color:#008">end

<= span style=3D"color:#660">-----



--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pandoc-discuss+unsubscribe-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.org= m.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6d556139-e107= -4ad4-a99d-62b07bd9ad3d%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.= google.com/d/msgid/pandoc-discuss/CADAJKhBfF-_hkBLJ0M5AnAL4aWJMs03JDbNj3wjj= D7P6_-6fcA%40mail.gmail.com.
--00000000000023c61105a1299948--