public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Markdown to docx/odt: is there a way to set image width globally?
@ 2019-10-06 18:11 Andrea Borruso
       [not found] ` <b72a268a-0e47-4cef-b6a5-21e579b390ab-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Andrea Borruso @ 2019-10-06 18:11 UTC (permalink / raw)
  To: pandoc-discuss


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

Hi,
I use this command to produce odt files.

pandoc -o output.odt --reference-doc=myPandocTemplate.odt input.md

For every image in my Md file I must set something like:

![](./imgs/4116_1.png){ width=100% }

Is there some command line parameter that I can use to set image width 
globally, without writing it for every image?

Thank you

-- 
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/b72a268a-0e47-4cef-b6a5-21e579b390ab%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Markdown to docx/odt: is there a way to set image width globally?
       [not found] ` <b72a268a-0e47-4cef-b6a5-21e579b390ab-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-10-06 21:37   ` John MacFarlane
       [not found]     ` <m2zhideetc.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: John MacFarlane @ 2019-10-06 21:37 UTC (permalink / raw)
  To: Andrea Borruso, pandoc-discuss


> Is there some command line parameter that I can use to set image width 
> globally, without writing it for every image?

No, but you could do this with a fairly simple lua filter that
adds this attribute to every image.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Markdown to docx/odt: is there a way to set image width globally?
       [not found]     ` <m2zhideetc.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2019-10-06 22:16       ` Andrea Borruso
       [not found]         ` <258b232f-488e-4e3d-9c47-90c37dfbef48-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Andrea Borruso @ 2019-10-06 22:16 UTC (permalink / raw)
  To: pandoc-discuss


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

Hi John,
and thank you

On Sunday, 6 October 2019 23:37:19 UTC+2, John MacFarlane wrote:
>
> No, but you could do this with a fairly simple lua filter that 
> adds this attribute to every image. 
>

I have no idea on how to use it.

I have tried running "pandoc -o output.odt --lua-filter=imgWidth.lua 
--reference-doc=myPandocTemplate.odt input.md"

function Pandoc()
  pandoc.Image({}, png, "title", {width="100%"})
end

 but it does not set image width to 100%.

Best regards

-- 
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/258b232f-488e-4e3d-9c47-90c37dfbef48%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Markdown to docx/odt: is there a way to set image width globally?
       [not found]         ` <258b232f-488e-4e3d-9c47-90c37dfbef48-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-10-07 14:40           ` EBkysko
       [not found]             ` <1f473739-d7bf-453a-ab3d-1f69eae7803d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: EBkysko @ 2019-10-07 14:40 UTC (permalink / raw)
  To: pandoc-discuss


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

Since the Image element is affected here, you need something like:

Image = function(img) img.attributes.width="100%"; img.attributes.height=
"100%"; return img end

*(NOTE: if the height has already been set, eg by another filter, then only 
setting width to 100% might not be enough, which is why I also put height 
to 100% above; the LaTeX default template will adjust to it by keeping 
aspect ratio and prevent overflow, but I haven't tested what the ODT writer 
will do if height 100% is omitted...)*

If this is the only element to change in this filter, then the filter is:

local filterImageWidth = { Image = function(img) img.attributes.width="100%"
; img.attributes.height="100%"; return img end }

If this is the only filter in your lua file, than the file will simply 
consist of:

return { filterImageWidth }

or

return { { Image = function(img) img.attributes.width="100%"; img.attributes
.height="100%"; return img end } }

You'll see this often written as:

return {
  { Image = function(img)
      img.attributes.width="100%"
      img.attributes.height="100%"
      return img
    end,
  }
}

(which is more manageable if there's instructions)

or, alternatively, you could just write in this lua file:

function Image(img)
  img.attributes.width="100%"
  img.attributes.height="100%"
  return img
end

and Pandoc will construct the return list of filters by itself.

-- 
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/1f473739-d7bf-453a-ab3d-1f69eae7803d%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Markdown to docx/odt: is there a way to set image width globally?
       [not found]             ` <1f473739-d7bf-453a-ab3d-1f69eae7803d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-10-07 14:43               ` EBkysko
  2019-10-07 14:50               ` Andrea Borruso
  1 sibling, 0 replies; 6+ messages in thread
From: EBkysko @ 2019-10-07 14:43 UTC (permalink / raw)
  To: pandoc-discuss


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

Correction for above, since I can't edit my message :* "which is more 
manageable if there's many instructions"*

-- 
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/386ca0ba-242c-4f95-b659-654f96661a63%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Markdown to docx/odt: is there a way to set image width globally?
       [not found]             ` <1f473739-d7bf-453a-ab3d-1f69eae7803d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2019-10-07 14:43               ` EBkysko
@ 2019-10-07 14:50               ` Andrea Borruso
  1 sibling, 0 replies; 6+ messages in thread
From: Andrea Borruso @ 2019-10-07 14:50 UTC (permalink / raw)
  To: pandoc-discuss


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

Hi EBkysko, only to say thank you very very much.

It works!

 

-- 
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/7bc77910-3dd7-4ddf-a3a6-2f7a6a52cd1e%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-10-07 14:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-06 18:11 Markdown to docx/odt: is there a way to set image width globally? Andrea Borruso
     [not found] ` <b72a268a-0e47-4cef-b6a5-21e579b390ab-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-10-06 21:37   ` John MacFarlane
     [not found]     ` <m2zhideetc.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2019-10-06 22:16       ` Andrea Borruso
     [not found]         ` <258b232f-488e-4e3d-9c47-90c37dfbef48-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-10-07 14:40           ` EBkysko
     [not found]             ` <1f473739-d7bf-453a-ab3d-1f69eae7803d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-10-07 14:43               ` EBkysko
2019-10-07 14:50               ` Andrea Borruso

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).