From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32565 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephan Meijer Newsgroups: gmane.text.pandoc Subject: Re: Image styling md -> docx Date: Tue, 9 May 2023 05:14:41 -0700 (PDT) Message-ID: References: <8b721e7e-adfd-4a87-b4fa-fe1a2822b9c9n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_11498_1204489105.1683634481003" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23698"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCYOPL5A34MBBMXS5CRAMGQEPOS2A3Q-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue May 09 14:14:46 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-ot1-f61.google.com ([209.85.210.61]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pwMEv-0005vp-PM for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 09 May 2023 14:14:45 +0200 Original-Received: by mail-ot1-f61.google.com with SMTP id 46e09a7af769-6aaf4506af3sf2462873a34.2 for ; Tue, 09 May 2023 05:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1683634484; x=1686226484; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=sYYTJMddb3yqo2X+wMd/3ovHx+PIQ8emjOlX/PacNDM=; b=c73F4jXCxd7unNqlgwWzklsX8f3SrmBG+7Kmtjo3mkLHC1jAR636SdMToJBlUI9VMT lp1tn/a5txe27ZJ61FEh3boCfHhPbJE3rHlVVn2qU2XsZXrzcjlSE5KSh1y/YE51U/gl Dz0rVkZtSuOdtQE5DTdV5JiBXa5/Vljur3nPVabGLEe6wY+DsFSVbnlFPuD/Xkv5N4zp VMEIiaAmBdhJWcAflqrMk8lral6PG864BDTgcuOWuDahcz16iOshoMHryn4eVSExnmJ7 Wy9iwGe7wE7T+t3wxCOpd/LCO+ucaNzbmDZ1vGZbTsofotPqY5f3okLlwFXSspIwL8N8 GC2w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stephanmeijer-com.20221208.gappssmtp.com; s=20221208; t=1683634484; x=1686226484; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=sYYTJMddb3yqo2X+wMd/3ovHx+PIQ8emjOlX/PacNDM=; b=piKRKxIaR5P4pVeLlC2xegGYYxkC/j8l5Iec7xamMWLWWT2Zid0IX1O5hKoLfo1NU4 0Sl3ZSQ6GfXKRbHlNWH314v1+sA9m84M+PiPvWUfrknrz6xdxHBlalzU54adDGmpmbMu uD9YYr+xyfK1jmgQpdeRIPwBWy3z0InZMIUOrUortb4dU+SdY7M3KrQKPGZu96792GMP mmsszvyAnkScPOBP8jJkvdbzXQQzDj27CKssnb5PLOrL3+6NL7ERVAM2Ch72gkN5uzPq Q1XYDzuJta1TzXMkItU8ssY84gJnfGlkNAheK1jJjOrPsqAoFNOivlQm4DBM2cTuLYxk abcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683634484; x=1686226484; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-sender:mime-version:subject:references:in-reply-to :message-id:to:from:date:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=sYYTJMddb3yqo2X+wMd/3ovHx+PIQ8emjOlX/PacNDM=; b=i2J4ZOn98DbdR/6nGhY5OmR7jnONTLmYW9HL9bWtaxvAS5ZMX7FF/ZZuEaDIb9y6by RbiyfCdttojnt+4POnZ0EXRzQmO7anEasGg7gPq6JMN6/47CFgA6nlCzljPrHaIC6+QI LtUrP9lBsOsxnesiwywc9w410M8n5uaym7Wv/AyzTosiEF9Kw2msgkrWZfOQzKl4NvyY 3POjCNP+RbEGDvzlrhehhTjvng8zwzDbHTtmRdN28EK9/8+Z/AAhZM3FBmK0bw91Nbym 8uysvaD4QEU0RVcIcuogvlzN+Mg4oOhRS+vZop/7dJ+eMXbGWJ Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AC+VfDyTE6xDT9ZG8GbgjcpxtrSX/HQy2y96N51srRiGbwwk3c8QX8Bv 1RIDkcsGiVF2+u0cBOVjMow= X-Google-Smtp-Source: ACHHUZ5MgknP//W0nMb9gfZ4B/NtMCK3lY9KliMok7CD0Wt5iFCjKhxD8qADf4rpiAvxj2UwKy/zLw== X-Received: by 2002:a9d:740c:0:b0:6a6:6bf:c616 with SMTP id n12-20020a9d740c000000b006a606bfc616mr673815otk.4.1683634484760; Tue, 09 May 2023 05:14:44 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6870:c7a8:b0:195:f2c8:685e with SMTP id dy40-20020a056870c7a800b00195f2c8685els341051oab.1.-pod-prod-09-us; Tue, 09 May 2023 05:14:42 -0700 (PDT) X-Received: by 2002:aca:3382:0:b0:38d:e097:ac91 with SMTP id z124-20020aca3382000000b0038de097ac91mr622120oiz.6.1683634481717; Tue, 09 May 2023 05:14:41 -0700 (PDT) In-Reply-To: <8b721e7e-adfd-4a87-b4fa-fe1a2822b9c9n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Original-Sender: me-nPKYAObcRdo6Blr+0TYHagC/G2K4zDHf@public.gmane.org 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:32565 Archived-At: ------=_Part_11498_1204489105.1683634481003 Content-Type: multipart/alternative; boundary="----=_Part_11499_2094474166.1683634481003" ------=_Part_11499_2094474166.1683634481003 Content-Type: text/plain; charset="UTF-8" Hi, This would indeed be significantly harder than conversion the other way around. Your approach using RawInline is probably the best one. GPT4 tells me it is possible in Docx this way (xml): . Then possibly you could try a filter like this? 1. function Image (img) 2. 3. align = 'left' 4. for k, v in pairs(img.classes) do 5. if v == 'center' then 6. align = 'center' 7. elseif v == 'right' then 8. align = 'right' 9. end 10. end 11. 12. border_code = '' 13. 14. ret_img = { 15. pandoc.RawInline('openxml', string.format('', align)), 16. pandoc.RawInline('openxml', ''), 17. pandoc.RawInline('openxml', border_code), 18. img, 19. pandoc.RawInline('openxml', ''), 20. } 21. 22. return ret_img 23. end Hope I was of any help Stephan. On Thursday, 27 April 2023 at 15:29:12 UTC+2 Oskar Wood Hansen wrote: > When i convert from markdown to docx I would like to use a luafilter to > add styling to my images. I have a css snippet that does the styling I want > within obsidian, but this doesnt affect pandoc conversion to docx. I also > have another luafiler that emables to center-align the images i want (I > haven't written it my self). Ideally I'd like to have another luafilter, > that enables me to toggle the custom styling (add borders) to my images. > > The working luafilter to align: > > function Image (img) > > align = 'left' > for k, v in pairs(img.classes) do > if v == 'center' then > align = 'center' > elseif v == 'right' then > align = 'right' > end > end > > ret_img = { > pandoc.RawInline('openxml', string.format(' w:val="%s"/>', align)), > img > } > > return ret_img > end > > > which allows me to add ![text that isnt transferred to docx > anyway](imgpath.png){.center}. > > The CCS to add border styling is simple: > img { > border: 1px solid #d8d5d4; > padding: 5px; > border-radius: 5px; > } > > I would also like to be able to invoke that with for instance .border. > > I've been searching for a full day, trying different things out - so I > hope my possible rookie question is acceptable. > > also once again praise to talber and jgm and co! > -- 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/cbcc1adb-41bd-449a-9fc3-f3410f1e6e5bn%40googlegroups.com. ------=_Part_11499_2094474166.1683634481003 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi,

This would indeed be significantly harder than con= version the other way around.

Your approach usin= g RawInline is probably the best one.

GPT4 tells= me it is possible in Docx this way (xml):

<w:pict> <v:shape id=3D"_x0000_i1025" <= span style=3D"box-sizing: border-box; color: rgb(0, 0, 102);">type= =3D"#_x0000_= t75" = style=3D"width:300pt;height:200pt"> <v:imagedata r:id=3D"rId5" <= span style=3D"box-sizing: border-box; color: rgb(0, 0, 102);">o:title=3D"Image D= escription"/> <w10:wrap type=3D"square" anchorx= =3D"column"<= /span> ancho= ry=3D= "line"/> <v:stroke color=3D"black" weight= =3D"1pt"/> <!-- Specify the border color and weight here -->= ; </v:shape> </w:pict>
<= div>.
Then possibly you could try a filter like this?

=
  1. function Image (img)
  2. =C2=A0
  3. align =3D 'left'<= /font>
  4. for k, v in pairs(img.classes) do
  5. if v <= span style=3D"box-sizing: border-box; color: rgb(102, 204, 102);">=3D=3D 'ce= nter' then
  6. align =3D 'center'
    =
  7. elseif v =3D=3D 'right' then
  8. <= li style=3D"box-sizing: border-box; vertical-align: top;">
    align = =3D 'righ= t'
  9. end
  10. end
  11. =C2=A0
  12. border_code =3D '<v:stroke color=3D= "black" weight=3D"1pt"/>'
  13. =C2=A0
  14. ret_img =3D {
  15. pandoc.RawInline('openxml', string.format('<w:pPr= ><w:jc w:val=3D"%s"/></w:pPr>', align)),
  16. pandoc<= span style=3D"box-sizing: border-box; color: rgb(102, 204, 102);">.R= awInline= (= 'openxml', '<w:pict><v:shape type=3D"#_x0000_t75">'),=
  17. = pandoc.RawInline('openxml', border_code),
  18. img,
  19. pandoc.RawInlin= e('openxm= l', ),
  20. }
  21. =C2=A0
  22. return ret_img
  23. end

Hope I was of= any help

Stephan.

On Thursday, 27 April 2023 at 15:29:12 UTC+2 Oskar Wood Hansen wrote:
=
When i conve= rt from markdown to docx I would like to use a luafilter to add styling to = my images. I have a css snippet that does the styling I want within obsidia= n, but this doesnt affect pandoc conversion to docx. I also have another lu= afiler that emables to center-align the images i want (I haven't writte= n it my self). Ideally I'd like to have another luafilter, that enables= me to toggle the custom styling (add borders) to my images.

=
The working luafilter to align:

function Image (img)
=C2=A0 align =3D 'left'
=C2=A0 for k, v in pairs(img.classes) do
=C2=A0 =C2=A0 if<= /span> v =3D=3D 'center' then
=C2=A0 =C2=A0 =C2= =A0 align =3D 'center'<= /span>
=C2=A0 =C2=A0 elseif v =3D=3D 'right' then
=C2=A0 =C2=A0 =C2=A0 align =3D 'right'
=C2=A0 =C2=A0 end
=C2=A0 end
= =C2=A0
=C2=A0 ret_img = =3D {
=C2=A0 =C2=A0 =C2= =A0pandoc.RawInline('openxm= l', string.format('<w:pPr><w:jc w:val=3D"%s&= quot;/></w:pPr>', alig= n)),
=C2=A0 =C2=A0 =C2=A0= img
=C2=A0 }
=
=C2=A0 return ret_img
end


which allows me to add ![text that isnt transferred to docx anyway]= (imgpath.png){.center}.

The CCS to add border styling is simple:
= img {
=C2=A0 border: 1px solid #d8d5d4;
=C2=A0 padding: 5px;
=C2= =A0 border-radius: 5px;
}

I would also like to be able to invoke = that with for instance .border.

I've been searching for a full d= ay, trying different things out - so I hope my possible rookie question is = acceptable.

also once again praise to talber = and jgm and co!

--
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/cbcc1adb-41bd-449a-9fc3-f3410f1e6e5bn%40googlegroups.= com.
------=_Part_11499_2094474166.1683634481003-- ------=_Part_11498_1204489105.1683634481003--