public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Help writing a lua filter to modify parent attributes
@ 2021-07-31  2:02 Leena Murgai
       [not found] ` <d852c6c9-9685-47b6-ae19-c505976dc220n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Leena Murgai @ 2021-07-31  2:02 UTC (permalink / raw)
  To: pandoc-discuss


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

Hi there,

I'm converting a my book from LaTeX to HTML. Given the LaTeX:

\begin{figure}
\includegraphics[width=\textwidth]{file_path}
\caption{caption_text}
\label{unique_name}
\end{figure}

The HTML for my figures comes out something like:

<figure>
<img src="file_path" id="unique_name"/><figcaption>caption_text</figcaption>
</figure>

I want to write a filter that searches for a given unique_name from a list 
of them and adds class="fullwidth" to the direct parent <figure> node. A 
quick search makes me think I can't do this using CSS - please let me know 
if I'm wrong.

I think the easiest way to do this would be to write a lua filter (since 
I'm already using some in the conversion to help with cross references) but 
all this is outside my wheelhouse. Again, if I'm wrong and there's an 
easier way I've missed, please let me know.

Any thoughts/advice would be appreciated.

Best,
Leena

-- 
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/d852c6c9-9685-47b6-ae19-c505976dc220n%40googlegroups.com.

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

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

* Re: Help writing a lua filter to modify parent attributes
       [not found] ` <d852c6c9-9685-47b6-ae19-c505976dc220n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-08-02 10:51   ` bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg
  2021-08-03 22:42     ` Leena Murgai
  0 siblings, 1 reply; 6+ messages in thread
From: bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg @ 2021-08-02 10:51 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Hi,

I think that it's a good occasion to learn, for your case is quite simple. I would put a list of identifiers in an environment variable or a pandoc metadata and write a Lua filter with an Image function that does the job you've described (by reading the "identifier" attribute of each Image and adding "fullwidth" to its "classes" attribute if the value of "identifier" is part of your name list). Please read a basic Lua tutorial and this page: https://pandoc.org/lua-filters.html.

Best,

Bastien

Le Friday 30 July 2021 à 07:02:46PM, Leena Murgai a écrit :
> Hi there,
> 
> I'm converting a my book from LaTeX to HTML. Given the LaTeX:
> 
> \begin{figure}
> \includegraphics[width=\textwidth]{file_path}
> \caption{caption_text}
> \label{unique_name}
> \end{figure}
> 
> The HTML for my figures comes out something like:
> 
> <figure>
> <img src="file_path" id="unique_name"/><figcaption>caption_text</figcaption>
> </figure>
> 
> I want to write a filter that searches for a given unique_name from a list of
> them and adds class="fullwidth" to the direct parent <figure> node. A quick
> search makes me think I can't do this using CSS - please let me know if I'm
> wrong.
> 
> I think the easiest way to do this would be to write a lua filter (since I'm
> already using some in the conversion to help with cross references) but all
> this is outside my wheelhouse. Again, if I'm wrong and there's an easier way
> I've missed, please let me know.
> 
> Any thoughts/advice would be appreciated.
> 
> Best,
> Leena
> 
> --
> 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 [1]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit [2]https://groups.google.com/d/msgid/
> pandoc-discuss/d852c6c9-9685-47b6-ae19-c505976dc220n%40googlegroups.com.
> 
> References:
> 
> [1] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [2] https://groups.google.com/d/msgid/pandoc-discuss/d852c6c9-9685-47b6-ae19-c505976dc220n%40googlegroups.com?utm_medium=email&utm_source=footer

-- 
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/YQfORsN5u8Sd/6MG%40localhost.


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

* Re: Help writing a lua filter to modify parent attributes
  2021-08-02 10:51   ` bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg
@ 2021-08-03 22:42     ` Leena Murgai
       [not found]       ` <6650d64d-88c9-4056-a525-787e78164434n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Leena Murgai @ 2021-08-03 22:42 UTC (permalink / raw)
  To: pandoc-discuss


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

Thanks for your reply Bastien. If I've understood your advice correctly 
(and simplifying with a single hardcoded identifier) you suggest something 
like

function Image(el)
  if el.identifier == "unique_name" then
    el.classes[1] = 'fullwidth'
    return el;
  end
end

The problem I have is that I want to modify the parent <figure> rather than 
the <img> itself, so I want the output to be

<figure class="fullwidth">
<img src="file_path" id="unique_name"/><figcaption>caption_text</figcaption>
</figure>

rather than

<figure>
<img src="file_path" 
id="unique_name" class="fullwidth"/><figcaption>caption_text</figcaption>
</figure>

Again, any advice appreciated.

Cheers,
Leena
On Monday, 2 August 2021 at 03:52:58 UTC-7 Bastien Dumont wrote:

> Hi,
>
> I think that it's a good occasion to learn, for your case is quite simple. 
> I would put a list of identifiers in an environment variable or a pandoc 
> metadata and write a Lua filter with an Image function that does the job 
> you've described (by reading the "identifier" attribute of each Image and 
> adding "fullwidth" to its "classes" attribute if the value of "identifier" 
> is part of your name list). Please read a basic Lua tutorial and this page: 
> https://pandoc.org/lua-filters.html.
>
> Best,
>
> Bastien
>
> Le Friday 30 July 2021 à 07:02:46PM, Leena Murgai a écrit :
> > Hi there,
> > 
> > I'm converting a my book from LaTeX to HTML. Given the LaTeX:
> > 
> > \begin{figure}
> > \includegraphics[width=\textwidth]{file_path}
> > \caption{caption_text}
> > \label{unique_name}
> > \end{figure}
> > 
> > The HTML for my figures comes out something like:
> > 
> > <figure>
> > <img src="file_path" 
> id="unique_name"/><figcaption>caption_text</figcaption>
> > </figure>
> > 
> > I want to write a filter that searches for a given unique_name from a 
> list of
> > them and adds class="fullwidth" to the direct parent <figure> node. A 
> quick
> > search makes me think I can't do this using CSS - please let me know if 
> I'm
> > wrong.
> > 
> > I think the easiest way to do this would be to write a lua filter (since 
> I'm
> > already using some in the conversion to help with cross references) but 
> all
> > this is outside my wheelhouse. Again, if I'm wrong and there's an easier 
> way
> > I've missed, please let me know.
> > 
> > Any thoughts/advice would be appreciated.
> > 
> > Best,
> > Leena
> > 
> > --
> > 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 [1]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > To view this discussion on the web visit [2]
> https://groups.google.com/d/msgid/
> > pandoc-discuss/d852c6c9-9685-47b6-ae19-c505976dc220n%40googlegroups.com.
> > 
> > References:
> > 
> > [1] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> > [2] 
> https://groups.google.com/d/msgid/pandoc-discuss/d852c6c9-9685-47b6-ae19-c505976dc220n%40googlegroups.com?utm_medium=email&utm_source=footer
>
>

-- 
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/6650d64d-88c9-4056-a525-787e78164434n%40googlegroups.com.

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

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

* Re: Help writing a lua filter to modify parent attributes
       [not found]       ` <6650d64d-88c9-4056-a525-787e78164434n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-08-04  1:01         ` Leena Murgai
       [not found]           ` <bdf6cd45-2d69-49e8-952d-e2fa814f4c59n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Leena Murgai @ 2021-08-04  1:01 UTC (permalink / raw)
  To: pandoc-discuss


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

I think I want something like

function Para(el)
  if (#el.c == 1 and el.c[1].t == "Image" and 
el.c[1].identifier=="unique_name") then
    el.classes[1] = "fullwidth"
    return el
  end
end

but Para doesn't have the attribute classes Mmm...
On Tuesday, 3 August 2021 at 15:42:01 UTC-7 Leena Murgai wrote:

> Thanks for your reply Bastien. If I've understood your advice correctly 
> (and simplifying with a single hardcoded identifier) you suggest something 
> like
>
> function Image(el)
>   if el.identifier == "unique_name" then
>     el.classes[1] = 'fullwidth'
>     return el;
>   end
> end
>
> The problem I have is that I want to modify the parent <figure> rather 
> than the <img> itself, so I want the output to be
>
> <figure class="fullwidth">
> <img src="file_path" 
> id="unique_name"/><figcaption>caption_text</figcaption>
> </figure>
>
> rather than
>
> <figure>
> <img src="file_path" 
> id="unique_name" class="fullwidth"/><figcaption>caption_text</figcaption>
> </figure>
>
> Again, any advice appreciated.
>
> Cheers,
> Leena
> On Monday, 2 August 2021 at 03:52:58 UTC-7 Bastien Dumont wrote:
>
>> Hi, 
>>
>> I think that it's a good occasion to learn, for your case is quite 
>> simple. I would put a list of identifiers in an environment variable or a 
>> pandoc metadata and write a Lua filter with an Image function that does the 
>> job you've described (by reading the "identifier" attribute of each Image 
>> and adding "fullwidth" to its "classes" attribute if the value of 
>> "identifier" is part of your name list). Please read a basic Lua tutorial 
>> and this page: https://pandoc.org/lua-filters.html. 
>>
>> Best, 
>>
>> Bastien 
>>
>> Le Friday 30 July 2021 à 07:02:46PM, Leena Murgai a écrit : 
>> > Hi there, 
>> > 
>> > I'm converting a my book from LaTeX to HTML. Given the LaTeX: 
>> > 
>> > \begin{figure} 
>> > \includegraphics[width=\textwidth]{file_path} 
>> > \caption{caption_text} 
>> > \label{unique_name} 
>> > \end{figure} 
>> > 
>> > The HTML for my figures comes out something like: 
>> > 
>> > <figure> 
>> > <img src="file_path" 
>> id="unique_name"/><figcaption>caption_text</figcaption> 
>> > </figure> 
>> > 
>> > I want to write a filter that searches for a given unique_name from a 
>> list of 
>> > them and adds class="fullwidth" to the direct parent <figure> node. A 
>> quick 
>> > search makes me think I can't do this using CSS - please let me know if 
>> I'm 
>> > wrong. 
>> > 
>> > I think the easiest way to do this would be to write a lua filter 
>> (since I'm 
>> > already using some in the conversion to help with cross references) but 
>> all 
>> > this is outside my wheelhouse. Again, if I'm wrong and there's an 
>> easier way 
>> > I've missed, please let me know. 
>> > 
>> > Any thoughts/advice would be appreciated. 
>> > 
>> > Best, 
>> > Leena 
>> > 
>> > -- 
>> > 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 [1]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>> > To view this discussion on the web visit [2]
>> https://groups.google.com/d/msgid/ 
>> > pandoc-discuss/d852c6c9-9685-47b6-ae19-c505976dc220n%40googlegroups.com. 
>>
>> > 
>> > References: 
>> > 
>> > [1] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 
>> > [2] 
>> https://groups.google.com/d/msgid/pandoc-discuss/d852c6c9-9685-47b6-ae19-c505976dc220n%40googlegroups.com?utm_medium=email&utm_source=footer 
>>
>>

-- 
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/bdf6cd45-2d69-49e8-952d-e2fa814f4c59n%40googlegroups.com.

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

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

* Re: Help writing a lua filter to modify parent attributes
       [not found]           ` <bdf6cd45-2d69-49e8-952d-e2fa814f4c59n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-08-04  8:41             ` Bastien DUMONT
  2021-08-04 16:54               ` Leena Murgai
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien DUMONT @ 2021-08-04  8:41 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Oh, sorry, I hadn't thought of that. If I understand correctly the source code here[1], you can't modify the figure element in Pandoc, so a little of post-processing via an external script would be necessary in order to move the class attribute from img to figure.

[1]: https://github.com/jgm/pandoc/blob/407de98b5e3971c84c7e89de5f2a9d317b4d4557/src/Text/Pandoc/Writers/HTML.hs#L681

Le Tuesday 03 August 2021 à 06:01:07PM, Leena Murgai a écrit :
> I think I want something like
> 
> function Para(el)
>   if (#el.c == 1 and el.c[1].t == "Image" and el.c[1].identifier==
> "unique_name") then
>     el.classes[1] = "fullwidth"
>     return el
>   end
> end
> 
> but Para doesn't have the attribute classes Mmm...
> On Tuesday, 3 August 2021 at 15:42:01 UTC-7 Leena Murgai wrote:
> 
>     Thanks for your reply Bastien. If I've understood your advice correctly
>     (and simplifying with a single hardcoded identifier) you suggest something
>     like
> 
>     function Image(el)
>       if el.identifier == "unique_name" then
>         el.classes[1] = 'fullwidth'
>         return el;
>       end
>     end
> 
>     The problem I have is that I want to modify the parent <figure> rather than
>     the <img> itself, so I want the output to be
> 
>     <figure class="fullwidth">
>     <img src="file_path" id="unique_name"/><figcaption>caption_text</
>     figcaption>
>     </figure>
> 
>     rather than
> 
>     <figure>
>     <img src="file_path" id="unique_name" class="fullwidth"/><figcaption>
>     caption_text</figcaption>
>     </figure>
> 
>     Again, any advice appreciated.
> 
>     Cheers,
>     Leena
>     On Monday, 2 August 2021 at 03:52:58 UTC-7 Bastien Dumont wrote:
> 
>         Hi,
> 
>         I think that it's a good occasion to learn, for your case is quite
>         simple. I would put a list of identifiers in an environment variable or
>         a pandoc metadata and write a Lua filter with an Image function that
>         does the job you've described (by reading the "identifier" attribute of
>         each Image and adding "fullwidth" to its "classes" attribute if the
>         value of "identifier" is part of your name list). Please read a basic
>         Lua tutorial and this page: [1]https://pandoc.org/lua-filters.html.
> 
>         Best,
> 
>         Bastien
> 
>         Le Friday 30 July 2021 à 07:02:46PM, Leena Murgai a écrit :
>         > Hi there,
>         >
>         > I'm converting a my book from LaTeX to HTML. Given the LaTeX:
>         >
>         > \begin{figure}
>         > \includegraphics[width=\textwidth]{file_path}
>         > \caption{caption_text}
>         > \label{unique_name}
>         > \end{figure}
>         >
>         > The HTML for my figures comes out something like:
>         >
>         > <figure>
>         > <img src="file_path" id="unique_name"/><figcaption>caption_text</
>         figcaption>
>         > </figure>
>         >
>         > I want to write a filter that searches for a given unique_name from a
>         list of
>         > them and adds class="fullwidth" to the direct parent <figure> node. A
>         quick
>         > search makes me think I can't do this using CSS - please let me know
>         if I'm
>         > wrong.
>         >
>         > I think the easiest way to do this would be to write a lua filter
>         (since I'm
>         > already using some in the conversion to help with cross references)
>         but all
>         > this is outside my wheelhouse. Again, if I'm wrong and there's an
>         easier way
>         > I've missed, please let me know.
>         >
>         > Any thoughts/advice would be appreciated.
>         >
>         > Best,
>         > Leena
>         >
>         > --
>         > 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 [1]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>         > To view this discussion on the web visit [2][2]https://
>         groups.google.com/d/msgid/
>         > pandoc-discuss/d852c6c9-9685-47b6-ae19-c505976dc220n%[3]
>         40googlegroups.com.
>         >
>         > References:
>         >
>         > [1] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>         > [2] [4]https://groups.google.com/d/msgid/pandoc-discuss/
>         d852c6c9-9685-47b6-ae19-c505976dc220n%40googlegroups.com?utm_medium=
>         email&utm_source=footer
> 
> 
> --
> 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 [5]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit [6]https://groups.google.com/d/msgid/
> pandoc-discuss/bdf6cd45-2d69-49e8-952d-e2fa814f4c59n%40googlegroups.com.
> 
> References:
> 
> [1] https://pandoc.org/lua-filters.html
> [2] https://groups.google.com/d/msgid/
> [3] http://40googlegroups.com/
> [4] https://groups.google.com/d/msgid/pandoc-discuss/d852c6c9-9685-47b6-ae19-c505976dc220n%40googlegroups.com?utm_medium=email&utm_source=footer
> [5] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [6] https://groups.google.com/d/msgid/pandoc-discuss/bdf6cd45-2d69-49e8-952d-e2fa814f4c59n%40googlegroups.com?utm_medium=email&utm_source=footer

-- 
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/YQpSxI93dShAGsat%40localhost.


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

* Re: Help writing a lua filter to modify parent attributes
  2021-08-04  8:41             ` Bastien DUMONT
@ 2021-08-04 16:54               ` Leena Murgai
  0 siblings, 0 replies; 6+ messages in thread
From: Leena Murgai @ 2021-08-04 16:54 UTC (permalink / raw)
  To: pandoc-discuss


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

Yes, I thought as much. Thanks for confirming.

I guess my choices are to modify my (working) css to change the behaviour 
of <figure> and <img> elements or post-process the html output. It would be 
nice to understand if this is worth raising as an issue. Issue #3177 
<https://github.com/jgm/pandoc/issues/3177> is related. I'm thinking I'll 
likely be able to do what I originally wanted with a future release of 
pandoc so writing a script that I can discard later (as you suggest) is 
probably the best option.

Cheers.
On Wednesday, 4 August 2021 at 01:42:44 UTC-7 Bastien Dumont wrote:

> Oh, sorry, I hadn't thought of that. If I understand correctly the source 
> code here[1], you can't modify the figure element in Pandoc, so a little of 
> post-processing via an external script would be necessary in order to move 
> the class attribute from img to figure.
>
> [1]: 
> https://github.com/jgm/pandoc/blob/407de98b5e3971c84c7e89de5f2a9d317b4d4557/src/Text/Pandoc/Writers/HTML.hs#L681
>
> Le Tuesday 03 August 2021 à 06:01:07PM, Leena Murgai a écrit :
> > I think I want something like
> > 
> > function Para(el)
> > if (#el.c == 1 and el.c[1].t == "Image" and el.c[1].identifier==
> > "unique_name") then
> > el.classes[1] = "fullwidth"
> > return el
> > end
> > end
> > 
> > but Para doesn't have the attribute classes Mmm...
> > On Tuesday, 3 August 2021 at 15:42:01 UTC-7 Leena Murgai wrote:
> > 
> > Thanks for your reply Bastien. If I've understood your advice correctly
> > (and simplifying with a single hardcoded identifier) you suggest 
> something
> > like
> > 
> > function Image(el)
> >   if el.identifier == "unique_name" then
> >     el.classes[1] = 'fullwidth'
> >     return el;
> >   end
> > end
> > 
> > The problem I have is that I want to modify the parent <figure> rather 
> than
> > the <img> itself, so I want the output to be
> > 
> > <figure class="fullwidth">
> > <img src="file_path" id="unique_name"/><figcaption>caption_text</
> > figcaption>
> > </figure>
> > 
> > rather than
> > 
> > <figure>
> > <img src="file_path" id="unique_name" class="fullwidth"/><figcaption>
> > caption_text</figcaption>
> > </figure>
> > 
> > Again, any advice appreciated.
> > 
> > Cheers,
> > Leena
> > On Monday, 2 August 2021 at 03:52:58 UTC-7 Bastien Dumont wrote:
> > 
> > Hi,
> > 
> > I think that it's a good occasion to learn, for your case is quite
> > simple. I would put a list of identifiers in an environment variable or
> > a pandoc metadata and write a Lua filter with an Image function that
> > does the job you've described (by reading the "identifier" attribute of
> > each Image and adding "fullwidth" to its "classes" attribute if the
> > value of "identifier" is part of your name list). Please read a basic
> > Lua tutorial and this page: [1]https://pandoc.org/lua-filters.html.
> > 
> > Best,
> > 
> > Bastien
> > 
> > Le Friday 30 July 2021 à 07:02:46PM, Leena Murgai a écrit :
> > > Hi there,
> > >
> > > I'm converting a my book from LaTeX to HTML. Given the LaTeX:
> > >
> > > \begin{figure}
> > > \includegraphics[width=\textwidth]{file_path}
> > > \caption{caption_text}
> > > \label{unique_name}
> > > \end{figure}
> > >
> > > The HTML for my figures comes out something like:
> > >
> > > <figure>
> > > <img src="file_path" id="unique_name"/><figcaption>caption_text</
> > figcaption>
> > > </figure>
> > >
> > > I want to write a filter that searches for a given unique_name from a
> > list of
> > > them and adds class="fullwidth" to the direct parent <figure> node. A
> > quick
> > > search makes me think I can't do this using CSS - please let me know
> > if I'm
> > > wrong.
> > >
> > > I think the easiest way to do this would be to write a lua filter
> > (since I'm
> > > already using some in the conversion to help with cross references)
> > but all
> > > this is outside my wheelhouse. Again, if I'm wrong and there's an
> > easier way
> > > I've missed, please let me know.
> > >
> > > Any thoughts/advice would be appreciated.
> > >
> > > Best,
> > > Leena
> > >
> > > --
> > > 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 [1]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > > To view this discussion on the web visit [2][2]https://
> > groups.google.com/d/msgid/
> > > pandoc-discuss/d852c6c9-9685-47b6-ae19-c505976dc220n%[3]
> > 40googlegroups.com.
> > >
> > > References:
> > >
> > > [1] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> > > [2] [4]https://groups.google.com/d/msgid/pandoc-discuss/
> > d852c6c9-9685-47b6-ae19-c505976dc220n%40googlegroups.com?utm_medium=
> > email&utm_source=footer
> > 
> > 
> > --
> > 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 [5]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > To view this discussion on the web visit [6]
> https://groups.google.com/d/msgid/
> > pandoc-discuss/bdf6cd45-2d69-49e8-952d-e2fa814f4c59n%40googlegroups.com.
> > 
> > References:
> > 
> > [1] https://pandoc.org/lua-filters.html
> > [2] https://groups.google.com/d/msgid/
> > [3] http://40googlegroups.com/
> > [4] 
> https://groups.google.com/d/msgid/pandoc-discuss/d852c6c9-9685-47b6-ae19-c505976dc220n%40googlegroups.com?utm_medium=email&utm_source=footer
> > [5] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> > [6] 
> https://groups.google.com/d/msgid/pandoc-discuss/bdf6cd45-2d69-49e8-952d-e2fa814f4c59n%40googlegroups.com?utm_medium=email&utm_source=footer
>
>

-- 
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/c2126ef8-f672-4a9b-a1dc-e919928689c9n%40googlegroups.com.

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

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

end of thread, other threads:[~2021-08-04 16:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-31  2:02 Help writing a lua filter to modify parent attributes Leena Murgai
     [not found] ` <d852c6c9-9685-47b6-ae19-c505976dc220n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-08-02 10:51   ` bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg
2021-08-03 22:42     ` Leena Murgai
     [not found]       ` <6650d64d-88c9-4056-a525-787e78164434n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-08-04  1:01         ` Leena Murgai
     [not found]           ` <bdf6cd45-2d69-49e8-952d-e2fa814f4c59n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-08-04  8:41             ` Bastien DUMONT
2021-08-04 16:54               ` Leena Murgai

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