* how to add numberLines by default in lua filter
@ 2021-04-10 13:25 rrraf
[not found] ` <6e0ddb7a-4a21-4375-ac3a-75c3570d70bdn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: rrraf @ 2021-04-10 13:25 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 1144 bytes --]
Hi,
I'm using the lua filter include-code-files which include code from a file
in a code block. The attributes of the original code block are preserved,
and so the class numberLines can be used. I would like to modify the lua
filter to add the numberLines class by default, but I'm struggling.
This line:
https://github.com/pandoc/lua-filters/blob/master/include-code-files/include-code-files.lua#L56
is where the attributes of the original codeblock are passed, using
cb.attr. I've tried different things, but can't get it to work. So, my
question is: how can I add the class numberLines to the cb attributes
before it is passed to pandoc.CodeBlock so that the generating code block
lines are numbered?
Thanks in advance!
--
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/6e0ddb7a-4a21-4375-ac3a-75c3570d70bdn%40googlegroups.com.
[-- Attachment #1.2: Type: text/html, Size: 1530 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: how to add numberLines by default in lua filter
[not found] ` <6e0ddb7a-4a21-4375-ac3a-75c3570d70bdn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-04-10 20:07 ` Albert Krewinkel
0 siblings, 0 replies; 2+ messages in thread
From: Albert Krewinkel @ 2021-04-10 20:07 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
rrraf <rblists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
> I'm using the lua filter include-code-files which include code from a file
> in a code block. The attributes of the original code block are preserved,
> and so the class numberLines can be used. I would like to modify the lua
> filter to add the numberLines class by default, but I'm struggling.
>
> This line:
> https://github.com/pandoc/lua-filters/blob/master/include-code-files/include-code-files.lua#L56
> is where the attributes of the original codeblock are passed, using
> cb.attr. I've tried different things, but can't get it to work. So, my
> question is: how can I add the class numberLines to the cb attributes
> before it is passed to pandoc.CodeBlock so that the generating code block
> lines are numbered?
The missing puzzle piece for you is probably that `cb.attributes` is a
shorthand for `cb.attr.attributes`, and that the element's classes are
in `cb.attr.classes` or, shorter, `cb.classes`. Thus, running
cb.classes:insert 'numberLines'
will modify the `cb.attr` element. Inserting that line anywhere before
the `return` should give the desired effect.
--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-10 20:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-10 13:25 how to add numberLines by default in lua filter rrraf
[not found] ` <6e0ddb7a-4a21-4375-ac3a-75c3570d70bdn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-04-10 20:07 ` Albert Krewinkel
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).