public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Convert specific parts of document
@ 2022-03-14 12:04 ` Balázs Szabó
       [not found]   ` <944c34cc-7875-4bd1-8dd1-b3e702672e32n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Balázs Szabó @ 2022-03-14 12:04 UTC (permalink / raw)
  To: pandoc-discuss


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



I have a markdown file of which I want to convert sometimes only specific 
parts, sometimes the whole document. I know about lua-filters and fenced 
div which I think is a possible approach, but how can I "select" which part 
of the document I'm converting.

Let's say this is my document:
*# This is my title*
*This is some common parts for both documents.*

*:::: DOC1*
*This is a part for Document 1.*
*::::*

*:::: DOC2*
*This is a part for Document 2.*
*::::*

*Some more common parts... *

How can I tell pandoc/lue-filter if I want to create "Document1" for 
example? Can I somehow pass a custom argument from the command line that 
lua-filter can pick up (e.g. DOC1 or full)?

Any other way of achieving this?

-- 
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/944c34cc-7875-4bd1-8dd1-b3e702672e32n%40googlegroups.com.

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

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

* AW: Convert specific parts of document
       [not found]   ` <944c34cc-7875-4bd1-8dd1-b3e702672e32n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-03-14 12:23     ` denis.maier-NSENcxR/0n0
       [not found]       ` <1d0ab3b0b4354449a55049143202534a-NSENcxR/0n0@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: denis.maier-NSENcxR/0n0 @ 2022-03-14 12:23 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 2497 bytes --]

Can’t come up with a piece of code right now, but one way to do this is to check whether a div contains a certain class. If it contains the class just return the element, otherwise `return {}`.

I don’t know if there are easy ways to pass command line parameters to the filter, but I guess you can use the -M flag to add a metadata value (e.g. pandoc file.md -o output.html -M docpart=doc1), and use that in your filter.

Best,
Denis

Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Balázs Szabó
Gesendet: Montag, 14. März 2022 13:05
An: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Betreff: Convert specific parts of document


I have a markdown file of which I want to convert sometimes only specific parts, sometimes the whole document. I know about lua-filters and fenced div which I think is a possible approach, but how can I "select" which part of the document I'm converting.

Let's say this is my document:
# This is my title
This is some common parts for both documents.

:::: DOC1
This is a part for Document 1.
::::

:::: DOC2
This is a part for Document 2.
::::

Some more common parts...

How can I tell pandoc/lue-filter if I want to create "Document1" for example? Can I somehow pass a custom argument from the command line that lua-filter can pick up (e.g. DOC1 or full)?

Any other way of achieving this?
--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/944c34cc-7875-4bd1-8dd1-b3e702672e32n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/944c34cc-7875-4bd1-8dd1-b3e702672e32n%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/1d0ab3b0b4354449a55049143202534a%40unibe.ch.

[-- Attachment #2: Type: text/html, Size: 6661 bytes --]

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

* Re: AW: Convert specific parts of document
       [not found]       ` <1d0ab3b0b4354449a55049143202534a-NSENcxR/0n0@public.gmane.org>
@ 2022-03-14 13:03         ` Bastien DUMONT
  2022-03-14 13:39           ` AW: " denis.maier-NSENcxR/0n0
  2022-03-14 14:32         ` Balázs Szabó
  1 sibling, 1 reply; 7+ messages in thread
From: Bastien DUMONT @ 2022-03-14 13:03 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

I think that the easiest way to specify what divs are to be handled is to pass an environment variable instead of using -M. For instance, if the variable name is TOPRINT, retrieving its value is as easy as calling `pandoc.system.environment().TOPRINT`.

Le Monday 14 March 2022 à 12:23:49PM, denis.maier-NSENcxR/0n0@public.gmane.org a écrit :
> Can’t come up with a piece of code right now, but one way to do this is to
> check whether a div contains a certain class. If it contains the class just
> return the element, otherwise `return {}`.
> 
>  
> 
> I don’t know if there are easy ways to pass command line parameters to the
> filter, but I guess you can use the -M flag to add a metadata value (e.g.
> pandoc file.md -o output.html -M docpart=doc1), and use that in your filter.
> 
>  
> 
> Best,
> 
> Denis
> 
>  
> 
> Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im
> Auftrag von Balázs Szabó
> Gesendet: Montag, 14. März 2022 13:05
> An: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> Betreff: Convert specific parts of document
> 
>  
> 
> I have a markdown file of which I want to convert sometimes only specific
> parts, sometimes the whole document. I know about lua-filters and fenced div
> which I think is a possible approach, but how can I "select" which part of the
> document I'm converting.
> 
> Let's say this is my document:
> 
> # This is my title
> 
> This is some common parts for both documents.
> 
>  
> 
> :::: DOC1
> 
> This is a part for Document 1.
> 
> ::::
> 
>  
> 
> :::: DOC2
> 
> This is a part for Document 2.
> 
> ::::
> 
>  
> 
> Some more common parts...
> 
> How can I tell pandoc/lue-filter if I want to create "Document1" for example?
> Can I somehow pass a custom argument from the command line that lua-filter can
> pick up (e.g. DOC1 or full)?
> 
> Any other way of achieving this?
> 
> --
> 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/944c34cc-7875-4bd1-8dd1-b3e702672e32n%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 [3]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit [4]https://groups.google.com/d/msgid/
> pandoc-discuss/1d0ab3b0b4354449a55049143202534a%40unibe.ch.
> 
> References:
> 
> [1] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [2] https://groups.google.com/d/msgid/pandoc-discuss/944c34cc-7875-4bd1-8dd1-b3e702672e32n%40googlegroups.com?utm_medium=email&utm_source=footer
> [3] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [4] https://groups.google.com/d/msgid/pandoc-discuss/1d0ab3b0b4354449a55049143202534a%40unibe.ch?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/Yi89KZyN/fh3ThNo%40localhost.


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

* AW: AW: Convert specific parts of document
  2022-03-14 13:03         ` Bastien DUMONT
@ 2022-03-14 13:39           ` denis.maier-NSENcxR/0n0
  0 siblings, 0 replies; 7+ messages in thread
From: denis.maier-NSENcxR/0n0 @ 2022-03-14 13:39 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Cool, that's nice to know!

> -----Ursprüngliche Nachricht-----
> Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-
> discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Bastien DUMONT
> Gesendet: Montag, 14. März 2022 14:04
> An: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> Betreff: Re: AW: Convert specific parts of document
> 
> I think that the easiest way to specify what divs are to be handled is to pass
> an environment variable instead of using -M. For instance, if the variable
> name is TOPRINT, retrieving its value is as easy as calling
> `pandoc.system.environment().TOPRINT`.
> 
> Le Monday 14 March 2022 à 12:23:49PM, denis.maier-NSENcxR/0n0@public.gmane.org a écrit :
> > Can’t come up with a piece of code right now, but one way to do this
> > is to check whether a div contains a certain class. If it contains the
> > class just return the element, otherwise `return {}`.
> >
> >
> >
> > I don’t know if there are easy ways to pass command line parameters to
> > the filter, but I guess you can use the -M flag to add a metadata value (e.g.
> > pandoc file.md -o output.html -M docpart=doc1), and use that in your
> filter.
> >
> >
> >
> > Best,
> >
> > Denis
> >
> >
> >
> > Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-
> discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> > Im Auftrag von Balázs Szabó
> > Gesendet: Montag, 14. März 2022 13:05
> > An: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> > Betreff: Convert specific parts of document
> >
> >
> >
> > I have a markdown file of which I want to convert sometimes only
> > specific parts, sometimes the whole document. I know about lua-filters
> > and fenced div which I think is a possible approach, but how can I
> > "select" which part of the document I'm converting.
> >
> > Let's say this is my document:
> >
> > # This is my title
> >
> > This is some common parts for both documents.
> >
> >
> >
> > :::: DOC1
> >
> > This is a part for Document 1.
> >
> > ::::
> >
> >
> >
> > :::: DOC2
> >
> > This is a part for Document 2.
> >
> > ::::
> >
> >
> >
> > Some more common parts...
> >
> > How can I tell pandoc/lue-filter if I want to create "Document1" for
> example?
> > Can I somehow pass a custom argument from the command line that
> > lua-filter can pick up (e.g. DOC1 or full)?
> >
> > Any other way of achieving this?
> >
> > --
> > 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/944c34cc-7875-4bd1-8dd1-
> b3e702672e32n%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 [3]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > To view this discussion on the web visit
> > [4]https://groups.google.com/d/msgid/
> > pandoc-discuss/1d0ab3b0b4354449a55049143202534a%40unibe.ch.
> >
> > References:
> >
> > [1] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> > [2]
> > https://groups.google.com/d/msgid/pandoc-discuss/944c34cc-7875-4bd1-
> 8d
> > d1-
> b3e702672e32n%40googlegroups.com?utm_medium=email&utm_source=fo
> oter
> > [3] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> > [4]
> > https://groups.google.com/d/msgid/pandoc-
> discuss/1d0ab3b0b4354449a5504
> > 9143202534a%40unibe.ch?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/Yi89KZyN/fh3ThNo%40localhost.

-- 
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/fe9a922128a149749c8f7f00fde4c75a%40unibe.ch.


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

* Re: Convert specific parts of document
       [not found]       ` <1d0ab3b0b4354449a55049143202534a-NSENcxR/0n0@public.gmane.org>
  2022-03-14 13:03         ` Bastien DUMONT
@ 2022-03-14 14:32         ` Balázs Szabó
       [not found]           ` <d3092493-038f-484f-896e-83b3b20cb38bn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  1 sibling, 1 reply; 7+ messages in thread
From: Balázs Szabó @ 2022-03-14 14:32 UTC (permalink / raw)
  To: pandoc-discuss


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

Checking the div class is working nicely, thanks!

Using metadata probably is the way to go, but I'm not sure how to get my 
custom metadata value in the .lua script, do you have some quick example 
how to use it?

On Monday, March 14, 2022 at 1:23:56 PM UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:

> Can’t come up with a piece of code right now, but one way to do this is to 
> check whether a div contains a certain class. If it contains the class just 
> return the element, otherwise `return {}`.
>
>  
>
> I don’t know if there are easy ways to pass command line parameters to the 
> filter, but I guess you can use the -M flag to add a metadata value (e.g. 
> pandoc file.md -o output.html -M docpart=doc1), and use that in your filter.
>
>  
>
> Best,
>
> Denis
>
>  
>
> *Von:* pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> *Im 
> Auftrag von *Balázs Szabó
> *Gesendet:* Montag, 14. März 2022 13:05
> *An:* pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> *Betreff:* Convert specific parts of document
>
>  
>
> I have a markdown file of which I want to convert sometimes only specific 
> parts, sometimes the whole document. I know about lua-filters and fenced 
> div which I think is a possible approach, but how can I "select" which part 
> of the document I'm converting.
>
> Let's say this is my document:
>
> *# This is my title*
>
> *This is some common parts for both documents.*
>
>  
>
> *:::: DOC1*
>
> *This is a part for Document 1.*
>
> *::::*
>
>  
>
> *:::: DOC2*
>
> *This is a part for Document 2.*
>
> *::::*
>
>  
>
> *Some more common parts... *
>
> How can I tell pandoc/lue-filter if I want to create "Document1" for 
> example? Can I somehow pass a custom argument from the command line that 
> lua-filter can pick up (e.g. DOC1 or full)?
>
> Any other way of achieving this?
>
> -- 
> 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/944c34cc-7875-4bd1-8dd1-b3e702672e32n%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/944c34cc-7875-4bd1-8dd1-b3e702672e32n%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/d3092493-038f-484f-896e-83b3b20cb38bn%40googlegroups.com.

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

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

* Re: Convert specific parts of document
       [not found]           ` <d3092493-038f-484f-896e-83b3b20cb38bn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-03-14 15:08             ` Bastien DUMONT
  2022-03-14 15:16               ` Balázs Szabó
  0 siblings, 1 reply; 7+ messages in thread
From: Bastien DUMONT @ 2022-03-14 15:08 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

If you want to pass the argument through a metadata on the command line (for instance with "-M docpart=doc1"), you can write:

```
local docpart = ''

local function Meta(meta)
  if meta.docpart then
    docpart = meta.docpart
  end
end

local function Div(div)
  (...)
end

-- By default, the Meta function is called after Div,
-- so the following is required.
return {
  { Meta = Meta },
  { Div = Div }
}
```

Don't forget to 

Le Monday 14 March 2022 à 07:32:17AM, Balázs Szabó a écrit :
> Checking the div class is working nicely, thanks!
> 
> Using metadata probably is the way to go, but I'm not sure how to get my custom
> metadata value in the .lua script, do you have some quick example how to use
> it?
> 
> On Monday, March 14, 2022 at 1:23:56 PM UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
> 
> 
>     Can’t come up with a piece of code right now, but one way to do this is to
>     check whether a div contains a certain class. If it contains the class just
>     return the element, otherwise `return {}`.
> 
>      
> 
>     I don’t know if there are easy ways to pass command line parameters to the
>     filter, but I guess you can use the -M flag to add a metadata value (e.g.
>     pandoc file.md -o output.html -M docpart=doc1), and use that in your
>     filter.
> 
>      
> 
>     Best,
> 
>     Denis
> 
>      
> 
>     Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag
>     von Balázs Szabó
>     Gesendet: Montag, 14. März 2022 13:05
>     An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>     Betreff: Convert specific parts of document
> 
>      
> 
>     I have a markdown file of which I want to convert sometimes only specific
>     parts, sometimes the whole document. I know about lua-filters and fenced
>     div which I think is a possible approach, but how can I "select" which part
>     of the document I'm converting.
> 
>     Let's say this is my document:
> 
>     # This is my title
> 
>     This is some common parts for both documents.
> 
>      
> 
>     :::: DOC1
> 
>     This is a part for Document 1.
> 
>     ::::
> 
>      
> 
>     :::: DOC2
> 
>     This is a part for Document 2.
> 
>     ::::
> 
>      
> 
>     Some more common parts...
> 
>     How can I tell pandoc/lue-filter if I want to create "Document1" for
>     example? Can I somehow pass a custom argument from the command line that
>     lua-filter can pick up (e.g. DOC1 or full)?
> 
>     Any other way of achieving this?
> 
>     --
>     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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>     To view this discussion on the web visit [1] https://groups.google.com/d/
>     msgid/pandoc-discuss/
>     944c34cc-7875-4bd1-8dd1-b3e702672e32n%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 [2]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit [3]https://groups.google.com/d/msgid/
> pandoc-discuss/d3092493-038f-484f-896e-83b3b20cb38bn%40googlegroups.com.
> 
> References:
> 
> [1] https://groups.google.com/d/msgid/pandoc-discuss/944c34cc-7875-4bd1-8dd1-b3e702672e32n%40googlegroups.com?utm_medium=email&utm_source=footer
> [2] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [3] https://groups.google.com/d/msgid/pandoc-discuss/d3092493-038f-484f-896e-83b3b20cb38bn%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/Yi9aIEXoyjaRAYCT%40localhost.


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

* Re: Convert specific parts of document
  2022-03-14 15:08             ` Bastien DUMONT
@ 2022-03-14 15:16               ` Balázs Szabó
  0 siblings, 0 replies; 7+ messages in thread
From: Balázs Szabó @ 2022-03-14 15:16 UTC (permalink / raw)
  To: pandoc-discuss


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

Great, works perfectly:)

Thanks to both of you!

On Monday, March 14, 2022 at 4:08:15 PM UTC+1 Bastien Dumont wrote:

> If you want to pass the argument through a metadata on the command line 
> (for instance with "-M docpart=doc1"), you can write:
>
> ```
> local docpart = ''
>
> local function Meta(meta)
> if meta.docpart then
> docpart = meta.docpart
> end
> end
>
> local function Div(div)
> (...)
> end
>
> -- By default, the Meta function is called after Div,
> -- so the following is required.
> return {
> { Meta = Meta },
> { Div = Div }
> }
> ```
>
> Don't forget to 
>
> Le Monday 14 March 2022 à 07:32:17AM, Balázs Szabó a écrit :
> > Checking the div class is working nicely, thanks!
> > 
> > Using metadata probably is the way to go, but I'm not sure how to get my 
> custom
> > metadata value in the .lua script, do you have some quick example how to 
> use
> > it?
> > 
> > On Monday, March 14, 2022 at 1:23:56 PM UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
> > 
> > 
> > Can’t come up with a piece of code right now, but one way to do this is 
> to
> > check whether a div contains a certain class. If it contains the class 
> just
> > return the element, otherwise `return {}`.
> > 
> >  
> > 
> > I don’t know if there are easy ways to pass command line parameters to 
> the
> > filter, but I guess you can use the -M flag to add a metadata value (e.g.
> > pandoc file.md -o output.html -M docpart=doc1), and use that in your
> > filter.
> > 
> >  
> > 
> > Best,
> > 
> > Denis
> > 
> >  
> > 
> > Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im 
> Auftrag
> > von Balázs Szabó
> > Gesendet: Montag, 14. März 2022 13:05
> > An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> > Betreff: Convert specific parts of document
> > 
> >  
> > 
> > I have a markdown file of which I want to convert sometimes only specific
> > parts, sometimes the whole document. I know about lua-filters and fenced
> > div which I think is a possible approach, but how can I "select" which 
> part
> > of the document I'm converting.
> > 
> > Let's say this is my document:
> > 
> > # This is my title
> > 
> > This is some common parts for both documents.
> > 
> >  
> > 
> > :::: DOC1
> > 
> > This is a part for Document 1.
> > 
> > ::::
> > 
> >  
> > 
> > :::: DOC2
> > 
> > This is a part for Document 2.
> > 
> > ::::
> > 
> >  
> > 
> > Some more common parts...
> > 
> > How can I tell pandoc/lue-filter if I want to create "Document1" for
> > example? Can I somehow pass a custom argument from the command line that
> > lua-filter can pick up (e.g. DOC1 or full)?
> > 
> > Any other way of achieving this?
> > 
> > --
> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > To view this discussion on the web visit [1] 
> https://groups.google.com/d/
> > msgid/pandoc-discuss/
> > 944c34cc-7875-4bd1-8dd1-b3e702672e32n%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 [2]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > To view this discussion on the web visit [3]
> https://groups.google.com/d/msgid/
> > pandoc-discuss/d3092493-038f-484f-896e-83b3b20cb38bn%40googlegroups.com.
> > 
> > References:
> > 
> > [1] 
> https://groups.google.com/d/msgid/pandoc-discuss/944c34cc-7875-4bd1-8dd1-b3e702672e32n%40googlegroups.com?utm_medium=email&utm_source=footer
> > [2] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> > [3] 
> https://groups.google.com/d/msgid/pandoc-discuss/d3092493-038f-484f-896e-83b3b20cb38bn%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/a9844b43-5e86-431b-8ecc-120881669890n%40googlegroups.com.

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

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

end of thread, other threads:[~2022-03-14 15:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <AQHYN5usYeBo96ATQEC3N3nrt7vrQKy+zBLQ>
2022-03-14 12:04 ` Convert specific parts of document Balázs Szabó
     [not found]   ` <944c34cc-7875-4bd1-8dd1-b3e702672e32n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-03-14 12:23     ` AW: " denis.maier-NSENcxR/0n0
     [not found]       ` <1d0ab3b0b4354449a55049143202534a-NSENcxR/0n0@public.gmane.org>
2022-03-14 13:03         ` Bastien DUMONT
2022-03-14 13:39           ` AW: " denis.maier-NSENcxR/0n0
2022-03-14 14:32         ` Balázs Szabó
     [not found]           ` <d3092493-038f-484f-896e-83b3b20cb38bn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-03-14 15:08             ` Bastien DUMONT
2022-03-14 15:16               ` Balázs Szabó

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