public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Modify writer or extensions inside a filter
@ 2021-04-15 14:08 'Angel Joaniquet' via pandoc-discuss
       [not found] ` <509d7700-5cb3-4382-9276-c4b2e2a0c3e5n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: 'Angel Joaniquet' via pandoc-discuss @ 2021-04-15 14:08 UTC (permalink / raw)
  To: pandoc-discuss

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


I'm trying to make a filter to transform some features of org-mode to 
GitLab-markdown (not supported by Pandoc out of the box), in particular, 
the math blocks.

The filter should work when transforming to `markdown`, but instead of 
giving the markdown format for the math blocks (enclosed by `$$...$$`), it 
should write the blocks as 

    ```  math
    a + b = c
    ``` 

The preces I have now is 

In org-mode, the math blocks are simply the latex code:

```
\begin{equation}
a + b = c
\end{equation}
```

this is parsed as a pandoc AST `RawBlock` with format `latex`. I then 
remove the first (`\begin{equation}`) an last line (`\end{equation}`), and 
construct a pandoc `CodeBlock` with atrributes `{"math"}`, so the 
`CodeBlock` object displays in AST as

```
CodeBlock ("",["math"],[]) "a + b = c\n"
```

and then I let Pandoc create the markdown document, and the written result 
is 

    ``` {.math}
    a + b = c
    ``` 



**The question:**  
I want the bare `math`, not `{.math}` written, without the use of CLI 
options. 


I am aware that this can be done setting the Writer extension 
`fenced_code_attributes` to false (eg. `$pandoc -w 
markdown-fenced_code_attributes ...`), but I would much prefer this done 
inside the filter. 

Or is it possible to set the extensions inside the filter?


Here is my atempted lua-filter:

``` lua
function RawBlock(rb)
   if rb.format == "latex" then
      local text = rb.text
      split_text =  split(text, "[^\n]*")
      if split_text[1] == '\\begin{equation}'  and 
split_text[#split_text-1] == '\\end{equation}' then
         table.remove(split_text, #split_text-1)
         table.remove(split_text, 1)
         text = table.concat(split_text, "\n")
         local cb = pandoc.CodeBlock()
         cb.attr = {"",{"math"}}
         cb.text = text
         return cb
      end
   end
end
```


Kind regards, 

Angel




-- 
-----------------------------------------------------------------------------------------------

La información contenida en este mensaje es de carácter privado y 
confidencial, dirigiéndose
exclusivamente al destinatario mencionado en el 
encabezamiento. Si usted ha recibido este mensaje por
error, le informamos 
que no debe revelar, copiar, distribuir o usarlo en ningún sentido ya que 
está
prohibido por la legislación vigente. Rogamos lo comunique al 
remitente y borre dicho mensaje y
cualquier documento adjunto que pudiera 
contener. Los datos personales que usted facilite por correo
electrónico 
podrán ser tratados por Zitro SARL con el fin de responder a su consulta o 
atender su
solicitud, así como gestionar la relación comercial, contractual 
o precontractual con usted. La base
legitimadora de este tratamiento es el 
interés legítimo de Zitro, así como el mantenimiento de la
relación 
contractual o de medidas precontractuales. No se cederán datos a terceros, 
salvo obligación
legal. Sus datos serán conservados durante todo el plazo 
de duración de la relación entre usted y Zitro y,
una vez terminada la 
misma, durante el plazo que determine la legislación aplicable en cada 
momento.
Usted podrá ejercitar en todo momento los derechos reconocidos en 
la normativa de protección de
datos, así como contactar con Zitro a través 
de la siguiente dirección: info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org 
<mailto:info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org>.

The information contained in this message is 
private and confidential, speaking exclusively to the
recipient mentioned 
in the heading. If you have received this message by mistake, we inform you 
that
you should not disclose, copy, distribute or use it in any way because 
it is prohibited by current law.
Please notify the sender and delete the 
message and any attachment that might contain. The personal
data you 
provide by email may be processed by Zitro SARL for the purpose of 
responding to your query
or attending to your request, and to manage the 
commercial, contractual or pre-contractual
relationship with you. The 
legitimizing basis of this processing is the legitimate interest of Zitro, 
and the
maintenance of the contractual relationship or pre-contractual 
measures. No data will be passed to
third parties unless there is a legal 
obligation to do so. Your data will be retained throughout the term of
your 
relationship with Zitro and, once that is terminated, for the term legally 
required at any specific
time. You may exercise your rights, as recognized 
in data protection legislation, at any time, and you
may contact Zitro at 
the following email address: info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org 
<mailto:info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org>.

-- 
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/509d7700-5cb3-4382-9276-c4b2e2a0c3e5n%40googlegroups.com.

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

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

* Re: Modify writer or extensions inside a filter
       [not found] ` <509d7700-5cb3-4382-9276-c4b2e2a0c3e5n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-04-15 14:20   ` 'Angel Joaniquet' via pandoc-discuss
       [not found]     ` <50d9ae1b-95a0-445f-9ab2-5b1fe2cc992fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: 'Angel Joaniquet' via pandoc-discuss @ 2021-04-15 14:20 UTC (permalink / raw)
  To: pandoc-discuss

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

The lua split function is this


```lua
function split(str,pat)
   local tbl = {}
   str:gsub(pat, function(x) tbl[#tbl+1]=x end)
   return tbl
end
```

El jueves, 15 de abril de 2021 a las 16:08:23 UTC+2, Angel Joaniquet 
escribió:

>
> I'm trying to make a filter to transform some features of org-mode to 
> GitLab-markdown (not supported by Pandoc out of the box), in particular, 
> the math blocks.
>
> The filter should work when transforming to `markdown`, but instead of 
> giving the markdown format for the math blocks (enclosed by `$$...$$`), it 
> should write the blocks as 
>
>     ```  math
>     a + b = c
>     ``` 
>
> The preces I have now is 
>
> In org-mode, the math blocks are simply the latex code:
>
> ```
> \begin{equation}
> a + b = c
> \end{equation}
> ```
>
> this is parsed as a pandoc AST `RawBlock` with format `latex`. I then 
> remove the first (`\begin{equation}`) an last line (`\end{equation}`), and 
> construct a pandoc `CodeBlock` with atrributes `{"math"}`, so the 
> `CodeBlock` object displays in AST as
>
> ```
> CodeBlock ("",["math"],[]) "a + b = c\n"
> ```
>
> and then I let Pandoc create the markdown document, and the written result 
> is 
>
>     ``` {.math}
>     a + b = c
>     ``` 
>
>
>
> **The question:**  
> I want the bare `math`, not `{.math}` written, without the use of CLI 
> options. 
>
>
> I am aware that this can be done setting the Writer extension 
> `fenced_code_attributes` to false (eg. `$pandoc -w 
> markdown-fenced_code_attributes ...`), but I would much prefer this done 
> inside the filter. 
>
> Or is it possible to set the extensions inside the filter?
>
>
> Here is my atempted lua-filter:
>
> ``` lua
> function RawBlock(rb)
>    if rb.format == "latex" then
>       local text = rb.text
>       split_text =  split(text, "[^\n]*")
>       if split_text[1] == '\\begin{equation}'  and 
> split_text[#split_text-1] == '\\end{equation}' then
>          table.remove(split_text, #split_text-1)
>          table.remove(split_text, 1)
>          text = table.concat(split_text, "\n")
>          local cb = pandoc.CodeBlock()
>          cb.attr = {"",{"math"}}
>          cb.text = text
>          return cb
>       end
>    end
> end
> ```
>
>
> Kind regards, 
>
> Angel
>
>
>
>
-- 
-----------------------------------------------------------------------------------------------

La información contenida en este mensaje es de carácter privado y 
confidencial, dirigiéndose
exclusivamente al destinatario mencionado en el 
encabezamiento. Si usted ha recibido este mensaje por
error, le informamos 
que no debe revelar, copiar, distribuir o usarlo en ningún sentido ya que 
está
prohibido por la legislación vigente. Rogamos lo comunique al 
remitente y borre dicho mensaje y
cualquier documento adjunto que pudiera 
contener. Los datos personales que usted facilite por correo
electrónico 
podrán ser tratados por Zitro SARL con el fin de responder a su consulta o 
atender su
solicitud, así como gestionar la relación comercial, contractual 
o precontractual con usted. La base
legitimadora de este tratamiento es el 
interés legítimo de Zitro, así como el mantenimiento de la
relación 
contractual o de medidas precontractuales. No se cederán datos a terceros, 
salvo obligación
legal. Sus datos serán conservados durante todo el plazo 
de duración de la relación entre usted y Zitro y,
una vez terminada la 
misma, durante el plazo que determine la legislación aplicable en cada 
momento.
Usted podrá ejercitar en todo momento los derechos reconocidos en 
la normativa de protección de
datos, así como contactar con Zitro a través 
de la siguiente dirección: info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org 
<mailto:info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org>.

The information contained in this message is 
private and confidential, speaking exclusively to the
recipient mentioned 
in the heading. If you have received this message by mistake, we inform you 
that
you should not disclose, copy, distribute or use it in any way because 
it is prohibited by current law.
Please notify the sender and delete the 
message and any attachment that might contain. The personal
data you 
provide by email may be processed by Zitro SARL for the purpose of 
responding to your query
or attending to your request, and to manage the 
commercial, contractual or pre-contractual
relationship with you. The 
legitimizing basis of this processing is the legitimate interest of Zitro, 
and the
maintenance of the contractual relationship or pre-contractual 
measures. No data will be passed to
third parties unless there is a legal 
obligation to do so. Your data will be retained throughout the term of
your 
relationship with Zitro and, once that is terminated, for the term legally 
required at any specific
time. You may exercise your rights, as recognized 
in data protection legislation, at any time, and you
may contact Zitro at 
the following email address: info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org 
<mailto:info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org>.

-- 
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/50d9ae1b-95a0-445f-9ab2-5b1fe2cc992fn%40googlegroups.com.

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

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

* Re: Modify writer or extensions inside a filter
       [not found]     ` <50d9ae1b-95a0-445f-9ab2-5b1fe2cc992fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-04-16 11:41       ` mb21
       [not found]         ` <c01112ea-3fd0-42c7-86ae-6e1806671b7bn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: mb21 @ 2021-04-16 11:41 UTC (permalink / raw)
  To: pandoc-discuss


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

cross-posting 
of https://stackoverflow.com/questions/67109880/is-it-posible-to-enable-extensions-on-pandoc-filters

Why do you prefer to set this in the filter instead of on the writer? I 
don't think there's a way to do that... because the filter just outputs an 
AST again, and what you're trying to change is happening in the writer...

On Thursday, April 15, 2021 at 4:20:32 PM UTC+2 Angel Joaniquet wrote:

> The lua split function is this
>
>
> ```lua
> function split(str,pat)
>    local tbl = {}
>    str:gsub(pat, function(x) tbl[#tbl+1]=x end)
>    return tbl
> end
> ```
>
> El jueves, 15 de abril de 2021 a las 16:08:23 UTC+2, Angel Joaniquet 
> escribió:
>
>>
>> I'm trying to make a filter to transform some features of org-mode to 
>> GitLab-markdown (not supported by Pandoc out of the box), in particular, 
>> the math blocks.
>>
>> The filter should work when transforming to `markdown`, but instead of 
>> giving the markdown format for the math blocks (enclosed by `$$...$$`), it 
>> should write the blocks as 
>>
>>     ```  math
>>     a + b = c
>>     ``` 
>>
>> The preces I have now is 
>>
>> In org-mode, the math blocks are simply the latex code:
>>
>> ```
>> \begin{equation}
>> a + b = c
>> \end{equation}
>> ```
>>
>> this is parsed as a pandoc AST `RawBlock` with format `latex`. I then 
>> remove the first (`\begin{equation}`) an last line (`\end{equation}`), and 
>> construct a pandoc `CodeBlock` with atrributes `{"math"}`, so the 
>> `CodeBlock` object displays in AST as
>>
>> ```
>> CodeBlock ("",["math"],[]) "a + b = c\n"
>> ```
>>
>> and then I let Pandoc create the markdown document, and the written 
>> result is 
>>
>>     ``` {.math}
>>     a + b = c
>>     ``` 
>>
>>
>>
>> **The question:**  
>> I want the bare `math`, not `{.math}` written, without the use of CLI 
>> options. 
>>
>>
>> I am aware that this can be done setting the Writer extension 
>> `fenced_code_attributes` to false (eg. `$pandoc -w 
>> markdown-fenced_code_attributes ...`), but I would much prefer this done 
>> inside the filter. 
>>
>> Or is it possible to set the extensions inside the filter?
>>
>>
>> Here is my atempted lua-filter:
>>
>> ``` lua
>> function RawBlock(rb)
>>    if rb.format == "latex" then
>>       local text = rb.text
>>       split_text =  split(text, "[^\n]*")
>>       if split_text[1] == '\\begin{equation}'  and 
>> split_text[#split_text-1] == '\\end{equation}' then
>>          table.remove(split_text, #split_text-1)
>>          table.remove(split_text, 1)
>>          text = table.concat(split_text, "\n")
>>          local cb = pandoc.CodeBlock()
>>          cb.attr = {"",{"math"}}
>>          cb.text = text
>>          return cb
>>       end
>>    end
>> end
>> ```
>>
>>
>> Kind regards, 
>>
>> Angel
>>
>>
>>
>>

-- 
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/c01112ea-3fd0-42c7-86ae-6e1806671b7bn%40googlegroups.com.

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

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

* Re: Modify writer or extensions inside a filter
       [not found]         ` <c01112ea-3fd0-42c7-86ae-6e1806671b7bn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-04-16 12:00           ` 'Angel Joaniquet' via pandoc-discuss
       [not found]             ` <03f7ab59-6b1a-451e-8528-4b164d439dc4n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: 'Angel Joaniquet' via pandoc-discuss @ 2021-04-16 12:00 UTC (permalink / raw)
  To: pandoc-discuss

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

cross-posting of  
https://stackoverflow.com/questions/67109880/is-it-posible-to-enable-extensions-on-pandoc-filters#comment118648930_67109880

The reason is that I want to have all in one file, to diminish the 
cognitive load


El viernes, 16 de abril de 2021 a las 13:41:58 UTC+2, mb21 escribió:

> cross-posting of 
> https://stackoverflow.com/questions/67109880/is-it-posible-to-enable-extensions-on-pandoc-filters
>
> Why do you prefer to set this in the filter instead of on the writer? I 
> don't think there's a way to do that... because the filter just outputs an 
> AST again, and what you're trying to change is happening in the writer...
>
> On Thursday, April 15, 2021 at 4:20:32 PM UTC+2 Angel Joaniquet wrote:
>
>> The lua split function is this
>>
>>
>> ```lua
>> function split(str,pat)
>>    local tbl = {}
>>    str:gsub(pat, function(x) tbl[#tbl+1]=x end)
>>    return tbl
>> end
>> ```
>>
>> El jueves, 15 de abril de 2021 a las 16:08:23 UTC+2, Angel Joaniquet 
>> escribió:
>>
>>>
>>> I'm trying to make a filter to transform some features of org-mode to 
>>> GitLab-markdown (not supported by Pandoc out of the box), in particular, 
>>> the math blocks.
>>>
>>> The filter should work when transforming to `markdown`, but instead of 
>>> giving the markdown format for the math blocks (enclosed by `$$...$$`), it 
>>> should write the blocks as 
>>>
>>>     ```  math
>>>     a + b = c
>>>     ``` 
>>>
>>> The preces I have now is 
>>>
>>> In org-mode, the math blocks are simply the latex code:
>>>
>>> ```
>>> \begin{equation}
>>> a + b = c
>>> \end{equation}
>>> ```
>>>
>>> this is parsed as a pandoc AST `RawBlock` with format `latex`. I then 
>>> remove the first (`\begin{equation}`) an last line (`\end{equation}`), and 
>>> construct a pandoc `CodeBlock` with atrributes `{"math"}`, so the 
>>> `CodeBlock` object displays in AST as
>>>
>>> ```
>>> CodeBlock ("",["math"],[]) "a + b = c\n"
>>> ```
>>>
>>> and then I let Pandoc create the markdown document, and the written 
>>> result is 
>>>
>>>     ``` {.math}
>>>     a + b = c
>>>     ``` 
>>>
>>>
>>>
>>> **The question:**  
>>> I want the bare `math`, not `{.math}` written, without the use of CLI 
>>> options. 
>>>
>>>
>>> I am aware that this can be done setting the Writer extension 
>>> `fenced_code_attributes` to false (eg. `$pandoc -w 
>>> markdown-fenced_code_attributes ...`), but I would much prefer this done 
>>> inside the filter. 
>>>
>>> Or is it possible to set the extensions inside the filter?
>>>
>>>
>>> Here is my atempted lua-filter:
>>>
>>> ``` lua
>>> function RawBlock(rb)
>>>    if rb.format == "latex" then
>>>       local text = rb.text
>>>       split_text =  split(text, "[^\n]*")
>>>       if split_text[1] == '\\begin{equation}'  and 
>>> split_text[#split_text-1] == '\\end{equation}' then
>>>          table.remove(split_text, #split_text-1)
>>>          table.remove(split_text, 1)
>>>          text = table.concat(split_text, "\n")
>>>          local cb = pandoc.CodeBlock()
>>>          cb.attr = {"",{"math"}}
>>>          cb.text = text
>>>          return cb
>>>       end
>>>    end
>>> end
>>> ```
>>>
>>>
>>> Kind regards, 
>>>
>>> Angel
>>>
>>>
>>>
>>>
-- 
-----------------------------------------------------------------------------------------------

La información contenida en este mensaje es de carácter privado y 
confidencial, dirigiéndose
exclusivamente al destinatario mencionado en el 
encabezamiento. Si usted ha recibido este mensaje por
error, le informamos 
que no debe revelar, copiar, distribuir o usarlo en ningún sentido ya que 
está
prohibido por la legislación vigente. Rogamos lo comunique al 
remitente y borre dicho mensaje y
cualquier documento adjunto que pudiera 
contener. Los datos personales que usted facilite por correo
electrónico 
podrán ser tratados por Zitro SARL con el fin de responder a su consulta o 
atender su
solicitud, así como gestionar la relación comercial, contractual 
o precontractual con usted. La base
legitimadora de este tratamiento es el 
interés legítimo de Zitro, así como el mantenimiento de la
relación 
contractual o de medidas precontractuales. No se cederán datos a terceros, 
salvo obligación
legal. Sus datos serán conservados durante todo el plazo 
de duración de la relación entre usted y Zitro y,
una vez terminada la 
misma, durante el plazo que determine la legislación aplicable en cada 
momento.
Usted podrá ejercitar en todo momento los derechos reconocidos en 
la normativa de protección de
datos, así como contactar con Zitro a través 
de la siguiente dirección: info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org 
<mailto:info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org>.

The information contained in this message is 
private and confidential, speaking exclusively to the
recipient mentioned 
in the heading. If you have received this message by mistake, we inform you 
that
you should not disclose, copy, distribute or use it in any way because 
it is prohibited by current law.
Please notify the sender and delete the 
message and any attachment that might contain. The personal
data you 
provide by email may be processed by Zitro SARL for the purpose of 
responding to your query
or attending to your request, and to manage the 
commercial, contractual or pre-contractual
relationship with you. The 
legitimizing basis of this processing is the legitimate interest of Zitro, 
and the
maintenance of the contractual relationship or pre-contractual 
measures. No data will be passed to
third parties unless there is a legal 
obligation to do so. Your data will be retained throughout the term of
your 
relationship with Zitro and, once that is terminated, for the term legally 
required at any specific
time. You may exercise your rights, as recognized 
in data protection legislation, at any time, and you
may contact Zitro at 
the following email address: info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org 
<mailto:info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org>.

-- 
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/03f7ab59-6b1a-451e-8528-4b164d439dc4n%40googlegroups.com.

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

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

* Re: Modify writer or extensions inside a filter
       [not found]             ` <03f7ab59-6b1a-451e-8528-4b164d439dc4n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-04-16 13:56               ` Albert Krewinkel
       [not found]                 ` <87sg3qqqn9.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Albert Krewinkel @ 2021-04-16 13:56 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

You could take full control of the output by creating the desired block yourself.

E.g., instead of local cb = pandoc.CodeBlock() ff., you could write

return pandoc.RawBlock('markdown',
  string.format('``` math\n%s\n```\n', text)
)

So you'd basically be creating the Markdown yourself, which is
relatively safe in the case of code blocks (assuming that the math
doesn't contain ```, which would be very unusual).

HTH,
Albert


'Angel Joaniquet' via pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> writes:

> cross-posting of
> https://stackoverflow.com/questions/67109880/is-it-posible-to-enable-extensions-on-pandoc-filters#comment118648930_67109880
>
> The reason is that I want to have all in one file, to diminish the
> cognitive load
>
>
> El viernes, 16 de abril de 2021 a las 13:41:58 UTC+2, mb21 escribió:
>
>> cross-posting of
>> https://stackoverflow.com/questions/67109880/is-it-posible-to-enable-extensions-on-pandoc-filters
>>
>> Why do you prefer to set this in the filter instead of on the writer? I
>> don't think there's a way to do that... because the filter just outputs an
>> AST again, and what you're trying to change is happening in the writer...
>>
>> On Thursday, April 15, 2021 at 4:20:32 PM UTC+2 Angel Joaniquet wrote:
>>
>>> The lua split function is this
>>>
>>>
>>> ```lua
>>> function split(str,pat)
>>>    local tbl = {}
>>>    str:gsub(pat, function(x) tbl[#tbl+1]=x end)
>>>    return tbl
>>> end
>>> ```
>>>
>>> El jueves, 15 de abril de 2021 a las 16:08:23 UTC+2, Angel Joaniquet
>>> escribió:
>>>
>>>>
>>>> I'm trying to make a filter to transform some features of org-mode to
>>>> GitLab-markdown (not supported by Pandoc out of the box), in particular,
>>>> the math blocks.
>>>>
>>>> The filter should work when transforming to `markdown`, but instead of
>>>> giving the markdown format for the math blocks (enclosed by `$$...$$`), it
>>>> should write the blocks as
>>>>
>>>>     ```  math
>>>>     a + b = c
>>>>     ```
>>>>
>>>> The preces I have now is
>>>>
>>>> In org-mode, the math blocks are simply the latex code:
>>>>
>>>> ```
>>>> \begin{equation}
>>>> a + b = c
>>>> \end{equation}
>>>> ```
>>>>
>>>> this is parsed as a pandoc AST `RawBlock` with format `latex`. I then
>>>> remove the first (`\begin{equation}`) an last line (`\end{equation}`), and
>>>> construct a pandoc `CodeBlock` with atrributes `{"math"}`, so the
>>>> `CodeBlock` object displays in AST as
>>>>
>>>> ```
>>>> CodeBlock ("",["math"],[]) "a + b = c\n"
>>>> ```
>>>>
>>>> and then I let Pandoc create the markdown document, and the written
>>>> result is
>>>>
>>>>     ``` {.math}
>>>>     a + b = c
>>>>     ```
>>>>
>>>>
>>>>
>>>> **The question:**
>>>> I want the bare `math`, not `{.math}` written, without the use of CLI
>>>> options.
>>>>
>>>>
>>>> I am aware that this can be done setting the Writer extension
>>>> `fenced_code_attributes` to false (eg. `$pandoc -w
>>>> markdown-fenced_code_attributes ...`), but I would much prefer this done
>>>> inside the filter.
>>>>
>>>> Or is it possible to set the extensions inside the filter?
>>>>
>>>>
>>>> Here is my atempted lua-filter:
>>>>
>>>> ``` lua
>>>> function RawBlock(rb)
>>>>    if rb.format == "latex" then
>>>>       local text = rb.text
>>>>       split_text =  split(text, "[^\n]*")
>>>>       if split_text[1] == '\\begin{equation}'  and
>>>> split_text[#split_text-1] == '\\end{equation}' then
>>>>          table.remove(split_text, #split_text-1)
>>>>          table.remove(split_text, 1)
>>>>          text = table.concat(split_text, "\n")
>>>>          local cb = pandoc.CodeBlock()
>>>>          cb.attr = {"",{"math"}}
>>>>          cb.text = text
>>>>          return cb
>>>>       end
>>>>    end
>>>> end
>>>> ```
>>>>
>>>>
>>>> Kind regards,
>>>>
>>>> Angel
>>>>
>>>>
>>>>
>>>>
> --
> -----------------------------------------------------------------------------------------------
>
> La información contenida en este mensaje es de carácter privado y
> confidencial, dirigiéndose
> exclusivamente al destinatario mencionado en el
> encabezamiento. Si usted ha recibido este mensaje por
> error, le informamos
> que no debe revelar, copiar, distribuir o usarlo en ningún sentido ya que
> está
> prohibido por la legislación vigente. Rogamos lo comunique al
> remitente y borre dicho mensaje y
> cualquier documento adjunto que pudiera
> contener. Los datos personales que usted facilite por correo
> electrónico
> podrán ser tratados por Zitro SARL con el fin de responder a su consulta o
> atender su
> solicitud, así como gestionar la relación comercial, contractual
> o precontractual con usted. La base
> legitimadora de este tratamiento es el
> interés legítimo de Zitro, así como el mantenimiento de la
> relación
> contractual o de medidas precontractuales. No se cederán datos a terceros,
> salvo obligación
> legal. Sus datos serán conservados durante todo el plazo
> de duración de la relación entre usted y Zitro y,
> una vez terminada la
> misma, durante el plazo que determine la legislación aplicable en cada
> momento.
> Usted podrá ejercitar en todo momento los derechos reconocidos en
> la normativa de protección de
> datos, así como contactar con Zitro a través
> de la siguiente dirección: info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org
> <mailto:info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org>.
>
> The information contained in this message is
> private and confidential, speaking exclusively to the
> recipient mentioned
> in the heading. If you have received this message by mistake, we inform you
> that
> you should not disclose, copy, distribute or use it in any way because
> it is prohibited by current law.
> Please notify the sender and delete the
> message and any attachment that might contain. The personal
> data you
> provide by email may be processed by Zitro SARL for the purpose of
> responding to your query
> or attending to your request, and to manage the
> commercial, contractual or pre-contractual
> relationship with you. The
> legitimizing basis of this processing is the legitimate interest of Zitro,
> and the
> maintenance of the contractual relationship or pre-contractual
> measures. No data will be passed to
> third parties unless there is a legal
> obligation to do so. Your data will be retained throughout the term of
> your
> relationship with Zitro and, once that is terminated, for the term legally
> required at any specific
> time. You may exercise your rights, as recognized
> in data protection legislation, at any time, and you
> may contact Zitro at
> the following email address: info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org
> <mailto:info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org>.


--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124

-- 
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/87sg3qqqn9.fsf%40zeitkraut.de.


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

* Re: Modify writer or extensions inside a filter
       [not found]                 ` <87sg3qqqn9.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
@ 2021-04-19 11:33                   ` 'Angel Joaniquet' via pandoc-discuss
  2021-04-19 14:49                   ` BPJ
  1 sibling, 0 replies; 7+ messages in thread
From: 'Angel Joaniquet' via pandoc-discuss @ 2021-04-19 11:33 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

Thanks, I will do this then.

El vie, 16 abr 2021 a las 15:56, Albert Krewinkel (<
albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>) escribió:

> You could take full control of the output by creating the desired block
> yourself.
>
> E.g., instead of local cb = pandoc.CodeBlock() ff., you could write
>
> return pandoc.RawBlock('markdown',
>   string.format('``` math\n%s\n```\n', text)
> )
>
> So you'd basically be creating the Markdown yourself, which is
> relatively safe in the case of code blocks (assuming that the math
> doesn't contain ```, which would be very unusual).
>
> HTH,
> Albert
>
>
> 'Angel Joaniquet' via pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> writes:
>
> > cross-posting of
> >
> https://stackoverflow.com/questions/67109880/is-it-posible-to-enable-extensions-on-pandoc-filters#comment118648930_67109880
> >
> > The reason is that I want to have all in one file, to diminish the
> > cognitive load
> >
> >
> > El viernes, 16 de abril de 2021 a las 13:41:58 UTC+2, mb21 escribió:
> >
> >> cross-posting of
> >>
> https://stackoverflow.com/questions/67109880/is-it-posible-to-enable-extensions-on-pandoc-filters
> >>
> >> Why do you prefer to set this in the filter instead of on the writer? I
> >> don't think there's a way to do that... because the filter just outputs
> an
> >> AST again, and what you're trying to change is happening in the
> writer...
> >>
> >> On Thursday, April 15, 2021 at 4:20:32 PM UTC+2 Angel Joaniquet wrote:
> >>
> >>> The lua split function is this
> >>>
> >>>
> >>> ```lua
> >>> function split(str,pat)
> >>>    local tbl = {}
> >>>    str:gsub(pat, function(x) tbl[#tbl+1]=x end)
> >>>    return tbl
> >>> end
> >>> ```
> >>>
> >>> El jueves, 15 de abril de 2021 a las 16:08:23 UTC+2, Angel Joaniquet
> >>> escribió:
> >>>
> >>>>
> >>>> I'm trying to make a filter to transform some features of org-mode to
> >>>> GitLab-markdown (not supported by Pandoc out of the box), in
> particular,
> >>>> the math blocks.
> >>>>
> >>>> The filter should work when transforming to `markdown`, but instead of
> >>>> giving the markdown format for the math blocks (enclosed by
> `$$...$$`), it
> >>>> should write the blocks as
> >>>>
> >>>>     ```  math
> >>>>     a + b = c
> >>>>     ```
> >>>>
> >>>> The preces I have now is
> >>>>
> >>>> In org-mode, the math blocks are simply the latex code:
> >>>>
> >>>> ```
> >>>> \begin{equation}
> >>>> a + b = c
> >>>> \end{equation}
> >>>> ```
> >>>>
> >>>> this is parsed as a pandoc AST `RawBlock` with format `latex`. I then
> >>>> remove the first (`\begin{equation}`) an last line
> (`\end{equation}`), and
> >>>> construct a pandoc `CodeBlock` with atrributes `{"math"}`, so the
> >>>> `CodeBlock` object displays in AST as
> >>>>
> >>>> ```
> >>>> CodeBlock ("",["math"],[]) "a + b = c\n"
> >>>> ```
> >>>>
> >>>> and then I let Pandoc create the markdown document, and the written
> >>>> result is
> >>>>
> >>>>     ``` {.math}
> >>>>     a + b = c
> >>>>     ```
> >>>>
> >>>>
> >>>>
> >>>> **The question:**
> >>>> I want the bare `math`, not `{.math}` written, without the use of CLI
> >>>> options.
> >>>>
> >>>>
> >>>> I am aware that this can be done setting the Writer extension
> >>>> `fenced_code_attributes` to false (eg. `$pandoc -w
> >>>> markdown-fenced_code_attributes ...`), but I would much prefer this
> done
> >>>> inside the filter.
> >>>>
> >>>> Or is it possible to set the extensions inside the filter?
> >>>>
> >>>>
> >>>> Here is my atempted lua-filter:
> >>>>
> >>>> ``` lua
> >>>> function RawBlock(rb)
> >>>>    if rb.format == "latex" then
> >>>>       local text = rb.text
> >>>>       split_text =  split(text, "[^\n]*")
> >>>>       if split_text[1] == '\\begin{equation}'  and
> >>>> split_text[#split_text-1] == '\\end{equation}' then
> >>>>          table.remove(split_text, #split_text-1)
> >>>>          table.remove(split_text, 1)
> >>>>          text = table.concat(split_text, "\n")
> >>>>          local cb = pandoc.CodeBlock()
> >>>>          cb.attr = {"",{"math"}}
> >>>>          cb.text = text
> >>>>          return cb
> >>>>       end
> >>>>    end
> >>>> end
> >>>> ```
> >>>>
> >>>>
> >>>> Kind regards,
> >>>>
> >>>> Angel
> >>>>
> >>>>
> >>>>
> >>>>
> > --
> >
> -----------------------------------------------------------------------------------------------
> >
> > La información contenida en este mensaje es de carácter privado y
> > confidencial, dirigiéndose
> > exclusivamente al destinatario mencionado en el
> > encabezamiento. Si usted ha recibido este mensaje por
> > error, le informamos
> > que no debe revelar, copiar, distribuir o usarlo en ningún sentido ya que
> > está
> > prohibido por la legislación vigente. Rogamos lo comunique al
> > remitente y borre dicho mensaje y
> > cualquier documento adjunto que pudiera
> > contener. Los datos personales que usted facilite por correo
> > electrónico
> > podrán ser tratados por Zitro SARL con el fin de responder a su consulta
> o
> > atender su
> > solicitud, así como gestionar la relación comercial, contractual
> > o precontractual con usted. La base
> > legitimadora de este tratamiento es el
> > interés legítimo de Zitro, así como el mantenimiento de la
> > relación
> > contractual o de medidas precontractuales. No se cederán datos a
> terceros,
> > salvo obligación
> > legal. Sus datos serán conservados durante todo el plazo
> > de duración de la relación entre usted y Zitro y,
> > una vez terminada la
> > misma, durante el plazo que determine la legislación aplicable en cada
> > momento.
> > Usted podrá ejercitar en todo momento los derechos reconocidos en
> > la normativa de protección de
> > datos, así como contactar con Zitro a través
> > de la siguiente dirección: info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org
> > <mailto:info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org>.
> >
> > The information contained in this message is
> > private and confidential, speaking exclusively to the
> > recipient mentioned
> > in the heading. If you have received this message by mistake, we inform
> you
> > that
> > you should not disclose, copy, distribute or use it in any way because
> > it is prohibited by current law.
> > Please notify the sender and delete the
> > message and any attachment that might contain. The personal
> > data you
> > provide by email may be processed by Zitro SARL for the purpose of
> > responding to your query
> > or attending to your request, and to manage the
> > commercial, contractual or pre-contractual
> > relationship with you. The
> > legitimizing basis of this processing is the legitimate interest of
> Zitro,
> > and the
> > maintenance of the contractual relationship or pre-contractual
> > measures. No data will be passed to
> > third parties unless there is a legal
> > obligation to do so. Your data will be retained throughout the term of
> > your
> > relationship with Zitro and, once that is terminated, for the term
> legally
> > required at any specific
> > time. You may exercise your rights, as recognized
> > in data protection legislation, at any time, and you
> > may contact Zitro at
> > the following email address: info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org
> > <mailto:info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org>.
>
>
> --
> Albert Krewinkel
> GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "pandoc-discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/pandoc-discuss/PTbqI_YhiX4/unsubscribe.
> To unsubscribe from this group and all its topics, 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/87sg3qqqn9.fsf%40zeitkraut.de
> .
>


-- 
Angel Joaniquet
Mathemathician


+34 937 456 900
Ronda Maiols 23-27
08192 Sant Quirze del Vallés
Barcelona

angel.joaniquet-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org
zitrogames.com
<https://twitter.com/Zitrogames>   <https://www.facebook.com/zitrogames/>
<https://www.linkedin.com/company/zitro>
<https://www.instagram.com/zitro.games>

-- 
-----------------------------------------------------------------------------------------------

La información contenida en este mensaje es de carácter privado y 
confidencial, dirigiéndose
exclusivamente al destinatario mencionado en el 
encabezamiento. Si usted ha recibido este mensaje por
error, le informamos 
que no debe revelar, copiar, distribuir o usarlo en ningún sentido ya que 
está
prohibido por la legislación vigente. Rogamos lo comunique al 
remitente y borre dicho mensaje y
cualquier documento adjunto que pudiera 
contener. Los datos personales que usted facilite por correo
electrónico 
podrán ser tratados por Zitro SARL con el fin de responder a su consulta o 
atender su
solicitud, así como gestionar la relación comercial, contractual 
o precontractual con usted. La base
legitimadora de este tratamiento es el 
interés legítimo de Zitro, así como el mantenimiento de la
relación 
contractual o de medidas precontractuales. No se cederán datos a terceros, 
salvo obligación
legal. Sus datos serán conservados durante todo el plazo 
de duración de la relación entre usted y Zitro y,
una vez terminada la 
misma, durante el plazo que determine la legislación aplicable en cada 
momento.
Usted podrá ejercitar en todo momento los derechos reconocidos en 
la normativa de protección de
datos, así como contactar con Zitro a través 
de la siguiente dirección: info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org 
<mailto:info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org>.

The information contained in this message is 
private and confidential, speaking exclusively to the
recipient mentioned 
in the heading. If you have received this message by mistake, we inform you 
that
you should not disclose, copy, distribute or use it in any way because 
it is prohibited by current law.
Please notify the sender and delete the 
message and any attachment that might contain. The personal
data you 
provide by email may be processed by Zitro SARL for the purpose of 
responding to your query
or attending to your request, and to manage the 
commercial, contractual or pre-contractual
relationship with you. The 
legitimizing basis of this processing is the legitimate interest of Zitro, 
and the
maintenance of the contractual relationship or pre-contractual 
measures. No data will be passed to
third parties unless there is a legal 
obligation to do so. Your data will be retained throughout the term of
your 
relationship with Zitro and, once that is terminated, for the term legally 
required at any specific
time. You may exercise your rights, as recognized 
in data protection legislation, at any time, and you
may contact Zitro at 
the following email address: info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org 
<mailto:info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org>.

-- 
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/CAA1uXFihjG2S55ePoBB6F6DD-UJDjk48Tui8rYAV%3Dnf8pNzmQA%40mail.gmail.com.

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

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

* Re: Modify writer or extensions inside a filter
       [not found]                 ` <87sg3qqqn9.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
  2021-04-19 11:33                   ` 'Angel Joaniquet' via pandoc-discuss
@ 2021-04-19 14:49                   ` BPJ
  1 sibling, 0 replies; 7+ messages in thread
From: BPJ @ 2021-04-19 14:49 UTC (permalink / raw)
  To: pandoc-discuss

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

> Den fre 16 apr. 2021 15:57Albert Krewinkel <albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
skrev:
>
> You could take full control of the output by creating the desired block
yourself.
>
> E.g., instead of local cb = pandoc.CodeBlock() ff., you could write
>
> return pandoc.RawBlock('markdown',
>   string.format('``` math\n%s\n```\n', text)
> )
>
> So you'd basically be creating the Markdown yourself, which is
> relatively safe in the case of code blocks (assuming that the math
> doesn't contain ```, which would be very unusual).

There is a workaround for that, assuming that three backticks is the
*minimum* length of the fence:

``````lua
local fence_len = 3

-- loop through all substrings with consecutive backticks
for ticks in text:gmatch('%`+') do

  -- How many backticks in this substring?
  local ticks_count = ticks:len()

  -- Are there more ticks in this substring than the current fence length?
  if ticks_count > fence_len then

    -- Update the fence length to be one more than the length of this
substring
    fence_len = ticks_count + 1
  end
end

local fence = string.rep('`', fence_len)

return pandoc.RawBlock('markdown',
  string.format('%s math\n%s\n%s\n', fence, text, fence)
)
``````

> HTH,
> Albert
>
>
> 'Angel Joaniquet' via pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
writes:
>
> > cross-posting of
> >
https://stackoverflow.com/questions/67109880/is-it-posible-to-enable-extensions-on-pandoc-filters#comment118648930_67109880
> >
> > The reason is that I want to have all in one file, to diminish the
> > cognitive load
> >
> >
> > El viernes, 16 de abril de 2021 a las 13:41:58 UTC+2, mb21 escribió:
> >
> >> cross-posting of
> >>
https://stackoverflow.com/questions/67109880/is-it-posible-to-enable-extensions-on-pandoc-filters
> >>
> >> Why do you prefer to set this in the filter instead of on the writer? I
> >> don't think there's a way to do that... because the filter just
outputs an
> >> AST again, and what you're trying to change is happening in the
writer...
> >>
> >> On Thursday, April 15, 2021 at 4:20:32 PM UTC+2 Angel Joaniquet wrote:
> >>
> >>> The lua split function is this
> >>>
> >>>
> >>> ```lua
> >>> function split(str,pat)
> >>>    local tbl = {}
> >>>    str:gsub(pat, function(x) tbl[#tbl+1]=x end)
> >>>    return tbl
> >>> end
> >>> ```
> >>>
> >>> El jueves, 15 de abril de 2021 a las 16:08:23 UTC+2, Angel Joaniquet
> >>> escribió:
> >>>
> >>>>
> >>>> I'm trying to make a filter to transform some features of org-mode to
> >>>> GitLab-markdown (not supported by Pandoc out of the box), in
particular,
> >>>> the math blocks.
> >>>>
> >>>> The filter should work when transforming to `markdown`, but instead
of
> >>>> giving the markdown format for the math blocks (enclosed by
`$$...$$`), it
> >>>> should write the blocks as
> >>>>
> >>>>     ```  math
> >>>>     a + b = c
> >>>>     ```
> >>>>
> >>>> The preces I have now is
> >>>>
> >>>> In org-mode, the math blocks are simply the latex code:
> >>>>
> >>>> ```
> >>>> \begin{equation}
> >>>> a + b = c
> >>>> \end{equation}
> >>>> ```
> >>>>
> >>>> this is parsed as a pandoc AST `RawBlock` with format `latex`. I then
> >>>> remove the first (`\begin{equation}`) an last line
(`\end{equation}`), and
> >>>> construct a pandoc `CodeBlock` with atrributes `{"math"}`, so the
> >>>> `CodeBlock` object displays in AST as
> >>>>
> >>>> ```
> >>>> CodeBlock ("",["math"],[]) "a + b = c\n"
> >>>> ```
> >>>>
> >>>> and then I let Pandoc create the markdown document, and the written
> >>>> result is
> >>>>
> >>>>     ``` {.math}
> >>>>     a + b = c
> >>>>     ```
> >>>>
> >>>>
> >>>>
> >>>> **The question:**
> >>>> I want the bare `math`, not `{.math}` written, without the use of CLI
> >>>> options.
> >>>>
> >>>>
> >>>> I am aware that this can be done setting the Writer extension
> >>>> `fenced_code_attributes` to false (eg. `$pandoc -w
> >>>> markdown-fenced_code_attributes ...`), but I would much prefer this
done
> >>>> inside the filter.
> >>>>
> >>>> Or is it possible to set the extensions inside the filter?
> >>>>
> >>>>
> >>>> Here is my atempted lua-filter:
> >>>>
> >>>> ``` lua
> >>>> function RawBlock(rb)
> >>>>    if rb.format == "latex" then
> >>>>       local text = rb.text
> >>>>       split_text =  split(text, "[^\n]*")
> >>>>       if split_text[1] == '\\begin{equation}'  and
> >>>> split_text[#split_text-1] == '\\end{equation}' then
> >>>>          table.remove(split_text, #split_text-1)
> >>>>          table.remove(split_text, 1)
> >>>>          text = table.concat(split_text, "\n")
> >>>>          local cb = pandoc.CodeBlock()
> >>>>          cb.attr = {"",{"math"}}
> >>>>          cb.text = text
> >>>>          return cb
> >>>>       end
> >>>>    end
> >>>> end
> >>>> ```
> >>>>
> >>>>
> >>>> Kind regards,
> >>>>
> >>>> Angel
> >>>>
> >>>>
> >>>>
> >>>>
> > --
> >
-----------------------------------------------------------------------------------------------
> >
> > La información contenida en este mensaje es de carácter privado y
> > confidencial, dirigiéndose
> > exclusivamente al destinatario mencionado en el
> > encabezamiento. Si usted ha recibido este mensaje por
> > error, le informamos
> > que no debe revelar, copiar, distribuir o usarlo en ningún sentido ya
que
> > está
> > prohibido por la legislación vigente. Rogamos lo comunique al
> > remitente y borre dicho mensaje y
> > cualquier documento adjunto que pudiera
> > contener. Los datos personales que usted facilite por correo
> > electrónico
> > podrán ser tratados por Zitro SARL con el fin de responder a su
consulta o
> > atender su
> > solicitud, así como gestionar la relación comercial, contractual
> > o precontractual con usted. La base
> > legitimadora de este tratamiento es el
> > interés legítimo de Zitro, así como el mantenimiento de la
> > relación
> > contractual o de medidas precontractuales. No se cederán datos a
terceros,
> > salvo obligación
> > legal. Sus datos serán conservados durante todo el plazo
> > de duración de la relación entre usted y Zitro y,
> > una vez terminada la
> > misma, durante el plazo que determine la legislación aplicable en cada
> > momento.
> > Usted podrá ejercitar en todo momento los derechos reconocidos en
> > la normativa de protección de
> > datos, así como contactar con Zitro a través
> > de la siguiente dirección: info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org
> > <mailto:info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org>.
> >
> > The information contained in this message is
> > private and confidential, speaking exclusively to the
> > recipient mentioned
> > in the heading. If you have received this message by mistake, we inform
you
> > that
> > you should not disclose, copy, distribute or use it in any way because
> > it is prohibited by current law.
> > Please notify the sender and delete the
> > message and any attachment that might contain. The personal
> > data you
> > provide by email may be processed by Zitro SARL for the purpose of
> > responding to your query
> > or attending to your request, and to manage the
> > commercial, contractual or pre-contractual
> > relationship with you. The
> > legitimizing basis of this processing is the legitimate interest of
Zitro,
> > and the
> > maintenance of the contractual relationship or pre-contractual
> > measures. No data will be passed to
> > third parties unless there is a legal
> > obligation to do so. Your data will be retained throughout the term of
> > your
> > relationship with Zitro and, once that is terminated, for the term
legally
> > required at any specific
> > time. You may exercise your rights, as recognized
> > in data protection legislation, at any time, and you
> > may contact Zitro at
> > the following email address: info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org
> > <mailto:info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org>.
>
>
> --
> Albert Krewinkel
> GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124
>
> --
> 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/87sg3qqqn9.fsf%40zeitkraut.de
.
>

-- 
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/CADAJKhAcUZ-Sxj1yjbp0ky%2BTdDUq5XGMKb3Kd7NhMCcoyvmBEQ%40mail.gmail.com.

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

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

end of thread, other threads:[~2021-04-19 14:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-15 14:08 Modify writer or extensions inside a filter 'Angel Joaniquet' via pandoc-discuss
     [not found] ` <509d7700-5cb3-4382-9276-c4b2e2a0c3e5n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-04-15 14:20   ` 'Angel Joaniquet' via pandoc-discuss
     [not found]     ` <50d9ae1b-95a0-445f-9ab2-5b1fe2cc992fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-04-16 11:41       ` mb21
     [not found]         ` <c01112ea-3fd0-42c7-86ae-6e1806671b7bn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-04-16 12:00           ` 'Angel Joaniquet' via pandoc-discuss
     [not found]             ` <03f7ab59-6b1a-451e-8528-4b164d439dc4n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-04-16 13:56               ` Albert Krewinkel
     [not found]                 ` <87sg3qqqn9.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2021-04-19 11:33                   ` 'Angel Joaniquet' via pandoc-discuss
2021-04-19 14:49                   ` BPJ

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