From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/28193 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "'Angel Joaniquet' via pandoc-discuss" Newsgroups: gmane.text.pandoc Subject: Re: Modify writer or extensions inside a filter Date: Mon, 19 Apr 2021 13:33:40 +0200 Message-ID: References: <509d7700-5cb3-4382-9276-c4b2e2a0c3e5n@googlegroups.com> <50d9ae1b-95a0-445f-9ab2-5b1fe2cc992fn@googlegroups.com> <03f7ab59-6b1a-451e-8528-4b164d439dc4n@googlegroups.com> <87sg3qqqn9.fsf@zeitkraut.de> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000372e1405c051b40b" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34386"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCUYX56H3IEBBIOV6WBQMGQE5KWFSGI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon Apr 19 13:33:56 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-pg1-f183.google.com ([209.85.215.183]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lYSA8-0008fB-8c for gtp-pandoc-discuss@m.gmane-mx.org; Mon, 19 Apr 2021 13:33:56 +0200 Original-Received: by mail-pg1-f183.google.com with SMTP id m36-20020a634c640000b02901fbb60ec3a6sf5977930pgl.15 for ; Mon, 19 Apr 2021 04:33:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1618832035; cv=pass; d=google.com; s=arc-20160816; b=iS7WKR+cfwEmt3mrpFji+Mss7DNB62vqb/x4GayIS86DFzNFLxpehS0I80ctRdgMyB Vzqu+SDzMbvTh9/XjE0YqEpWnpvc0cl1T447q9FQmpmoaIPKMqMdLaQOrH1SxNKbolzD GTYorc/v8cXxeD54m+G/ko/vx/Vg3aNP7HyX3TcvLuJGqUTRTWuqo9188hPMLmPbHEAh COPDOI2snkz/FnpIAVcrQjQfCUPNkFsIVq9lea0Ajc21RJ+WzX7V6K8QhwLRCJAGbun6 SYHN4LrB0yoxT2dWTW1Ic+rk23kz83NLuS7cQhl6xUg8N4c0wZA8dwD07ZS9JsCEjoMY Gr5g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date :from:in-reply-to:references:mime-version:dkim-signature; bh=aLNdUC1Nac81S6nzlip0y17hxcIJJvOK06SD5PazByw=; b=onNruiqZK6+ozVTNp2tsa+VpjN1XAvFN6JewBU5Azy7yA6lse+JukF2YFGoZzLoNDF jOeXeiL81R5/p4meHpIySSLYqtKYLhzlhsoeGyhPHnAZ1Oc0vO7Yq/NeikXQ4NJxnmMu fiZsD3Kztvmk94MfGurnc29CH1JCX/wu2wt0WD289hYUXe8ki7Ctlmz1l7TEfkeXxc14 LXoDHONXY8Vo8LStaudMaD+qYZgZkrj9+UQkdcPB4AQRtaNNjeO1yQQV/GukXsAuV44S vH/xLymXVNFlBSk5Rp4pIzZW/bdfdPhY/9h+z9jWE/9GNVhwLSLtgbvIaJhB67ydHIeZ uiIw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@zitrogames.com header.s=google header.b=l2QJZ9DQ; spf=pass (google.com: domain of angel.joaniquet-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org designates 2607:f8b0:4864:20::f33 as permitted sender) smtp.mailfrom=angel.joaniquet-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zitrogames.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=aLNdUC1Nac81S6nzlip0y17hxcIJJvOK06SD5PazByw=; b=lfcZqOvEeJLHwR/BDCptA+dyDVQxLFjvq+95WXAziW88ufBeczRrCM33l/4XSecxps OChnjZlxBlw7CHdKnLyr1H3cn6FZ3DzE8ATaIcj0L6ghwxggb6oErAui8rJm2AZKlklo Qoh5ATj2xGZdMpd5ma3jra47Awbgnn609V851I15F+utsZh6UVx6NRc4TcMI/MJnNWzK HdQFAFshGkkfboMTXTCOdSERXJN8VUS5eDwgCXJ7LefPghWVMO7dT+X4BLIWhsYOaKWb RbBspH7QNQPLGtQS0o06KRV+3T5hU4nk2ugNTpJi1GiZoJRwaexX19APEgh7qmA2dUZD QCOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=aLNdUC1Nac81S6nzlip0y17hxcIJJvOK06SD5PazByw=; b=LQQCeBP6Fthq7VKS0rDnIbrIi3NmTtuBsA+gBdUwuLmor4YQSbq+D7EdjT9JWpnkho vpSlTxAGv3gDCEMu+rtPfe3NXgbbrnVtXYAOe204Gj0Rf2IFPcoO0Ch+upx12vKQlbGP Un1veAuom50nh5GkUw5JshbqtcRgze1DYaRGWi7TX7RgTNJXELXbAjusxDjV3WmqiwTN Ap8xkLlm8kKgmZ/7/wQlc+NuJc6l8iwI32Q6Kqef1zzDkOy3pRCNwnvEJxjtkF/+mqFQ uX/TGWbRCSWl0A9TYhWOoD465jv7ADLxQgq6kC6trslu0QMHop3B5ZEK4A0Akcm0+rKQ Im3A== X-Gm-Message-State: AOAM531UAfD9XdJwmD/97SP9pVQEIjAup8YxlWQTTeY+FbpdbuoP2Oit f1BAsL20VKL1s5NIiY9mb58= X-Google-Smtp-Source: ABdhPJzM36tv94DqqQ5d9Yhy9BdPp5yGeLppxIzt4qRiOIjSvzOJJR5OMshK7slnf2zfeSepeQir4g== X-Received: by 2002:a65:5c88:: with SMTP id a8mr11048326pgt.130.1618832035093; Mon, 19 Apr 2021 04:33:55 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a62:7e53:: with SMTP id z80ls5317917pfc.1.gmail; Mon, 19 Apr 2021 04:33:52 -0700 (PDT) X-Received: by 2002:a05:6a00:24c3:b029:253:e598:2c62 with SMTP id d3-20020a056a0024c3b0290253e5982c62mr19824288pfv.30.1618832032817; Mon, 19 Apr 2021 04:33:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618832032; cv=none; d=google.com; s=arc-20160816; b=Jjxxkynqp9S6eEq/Qy4zKnu90HjZ9fsjDQEhOm00WQF8ka5h8F5b6m89NRt8kjyhTx H+y5yHBDBJKVVlCsmz1GojkUIgDSIVWO5huIbdwjLSKXSze4Hc4BL5Ue31DqfnWxRfeF FQecaoYs0MmfCtbzwtlHpv+Kcnvho4XR38bjfsl2gYyylyvz2qGL8JhrWP1a7wlOlXO/ ugVIv64l+lAsg1dhoasbJBNr/QNw9XHbnS0+8+MN6ZorqjWOeq0BtK0kDEAE3JLYz3Jp V3ITyGBGtpM4wSo2cqxHca3X8YZHBLZbfbYDf0Y/vn3lBVkCu77i667F5P5Z8sFZksjG 2Uvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=BlLI/Mroy1xKYapZ3+McgFG2AwE/3b67DeFbMp3hVdM=; b=QB/aVazRdnAJ7ywooN0G2ufL4IvOTaosLEH6dARuvW2fM5RL0n67sHbEU4OuToJldR ERb8bGQOq5UdKT/ZCZnJP6ORFKY9ViBLoi7SGGkVhqqyRJtycvrzyMSf24fOV93SrSpA uXR022JXQ+4CzIRJz4PIFGBKLoL5g9t8iB4cuTLxYFe2uWxyMFVylslWwPG0AOFa6sbG Heyk6OJUmHxkUHtOI94K4h8WEzwNzs9aF7O3vuYngkMWkC1HVOfaLZtYi4Po6ICSxoK3 P037EyrhlrYlQFP3Go0bPYNX16QboKUy41heWDgtPHYAbwRH01XhCmul4LNT6ZhQsMSc EgcQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@zitrogames.com header.s=google header.b=l2QJZ9DQ; spf=pass (google.com: domain of angel.joaniquet-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org designates 2607:f8b0:4864:20::f33 as permitted sender) smtp.mailfrom=angel.joaniquet-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zitrogames.com Original-Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com. [2607:f8b0:4864:20::f33]) by gmr-mx.google.com with ESMTPS id g1si1027690pjj.0.2021.04.19.04.33.52 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Apr 2021 04:33:52 -0700 (PDT) Received-SPF: pass (google.com: domain of angel.joaniquet-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org designates 2607:f8b0:4864:20::f33 as permitted sender) client-ip=2607:f8b0:4864:20::f33; Original-Received: by mail-qv1-xf33.google.com with SMTP id dp18so12036094qvb.5 for ; Mon, 19 Apr 2021 04:33:52 -0700 (PDT) X-Received: by 2002:ad4:4511:: with SMTP id k17mr18465122qvu.44.1618832031942; Mon, 19 Apr 2021 04:33:51 -0700 (PDT) In-Reply-To: <87sg3qqqn9.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> X-Original-Sender: angel.joaniquet-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@zitrogames.com header.s=google header.b=l2QJZ9DQ; spf=pass (google.com: domain of angel.joaniquet-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org designates 2607:f8b0:4864:20::f33 as permitted sender) smtp.mailfrom=angel.joaniquet-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zitrogames.com X-Original-From: Angel Joaniquet Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:28193 Archived-At: --000000000000372e1405c051b40b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=C3=B3: > You could take full control of the output by creating the desired block > yourself. > > E.g., instead of local cb =3D 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 > writes: > > > cross-posting of > > > https://stackoverflow.com/questions/67109880/is-it-posible-to-enable-exte= nsions-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=C3= =B3: > > > >> cross-posting of > >> > https://stackoverflow.com/questions/67109880/is-it-posible-to-enable-exte= nsions-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 output= s > 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 =3D {} > >>> str:gsub(pat, function(x) tbl[#tbl+1]=3Dx end) > >>> return tbl > >>> end > >>> ``` > >>> > >>> El jueves, 15 de abril de 2021 a las 16:08:23 UTC+2, Angel Joaniquet > >>> escribi=C3=B3: > >>> > >>>> > >>>> I'm trying to make a filter to transform some features of org-mode t= o > >>>> 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 =3D c > >>>> ``` > >>>> > >>>> The preces I have now is > >>>> > >>>> In org-mode, the math blocks are simply the latex code: > >>>> > >>>> ``` > >>>> \begin{equation} > >>>> a + b =3D c > >>>> \end{equation} > >>>> ``` > >>>> > >>>> this is parsed as a pandoc AST `RawBlock` with format `latex`. I the= n > >>>> 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 =3D c\n" > >>>> ``` > >>>> > >>>> and then I let Pandoc create the markdown document, and the written > >>>> result is > >>>> > >>>> ``` {.math} > >>>> a + b =3D c > >>>> ``` > >>>> > >>>> > >>>> > >>>> **The question:** > >>>> I want the bare `math`, not `{.math}` written, without the use of CL= I > >>>> 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 =3D=3D "latex" then > >>>> local text =3D rb.text > >>>> split_text =3D split(text, "[^\n]*") > >>>> if split_text[1] =3D=3D '\\begin{equation}' and > >>>> split_text[#split_text-1] =3D=3D '\\end{equation}' then > >>>> table.remove(split_text, #split_text-1) > >>>> table.remove(split_text, 1) > >>>> text =3D table.concat(split_text, "\n") > >>>> local cb =3D pandoc.CodeBlock() > >>>> cb.attr =3D {"",{"math"}} > >>>> cb.text =3D text > >>>> return cb > >>>> end > >>>> end > >>>> end > >>>> ``` > >>>> > >>>> > >>>> Kind regards, > >>>> > >>>> Angel > >>>> > >>>> > >>>> > >>>> > > -- > > > -------------------------------------------------------------------------= ---------------------- > > > > La informaci=C3=B3n contenida en este mensaje es de car=C3=A1cter priva= do y > > confidencial, dirigi=C3=A9ndose > > 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=C3=BAn sentido= ya que > > est=C3=A1 > > prohibido por la legislaci=C3=B3n 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=C3=B3nico > > podr=C3=A1n ser tratados por Zitro SARL con el fin de responder a su co= nsulta > o > > atender su > > solicitud, as=C3=AD como gestionar la relaci=C3=B3n comercial, contract= ual > > o precontractual con usted. La base > > legitimadora de este tratamiento es el > > inter=C3=A9s leg=C3=ADtimo de Zitro, as=C3=AD como el mantenimiento de = la > > relaci=C3=B3n > > contractual o de medidas precontractuales. No se ceder=C3=A1n datos a > terceros, > > salvo obligaci=C3=B3n > > legal. Sus datos ser=C3=A1n conservados durante todo el plazo > > de duraci=C3=B3n de la relaci=C3=B3n entre usted y Zitro y, > > una vez terminada la > > misma, durante el plazo que determine la legislaci=C3=B3n aplicable en = cada > > momento. > > Usted podr=C3=A1 ejercitar en todo momento los derechos reconocidos en > > la normativa de protecci=C3=B3n de > > datos, as=C3=AD como contactar con Zitro a trav=C3=A9s > > de la siguiente direcci=C3=B3n: 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 > > . > > > -- > 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%40zeitkra= ut.de > . > --=20 Angel Joaniquet Mathemathician +34 937 456 900 Ronda Maiols 23-27 08192 Sant Quirze del Vall=C3=A9s Barcelona angel.joaniquet-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org zitrogames.com --=20 ---------------------------------------------------------------------------= -------------------- La informaci=C3=B3n contenida en este mensaje es de car=C3=A1cter privado y= =20 confidencial, dirigi=C3=A9ndose exclusivamente al destinatario mencionado en el=20 encabezamiento. Si usted ha recibido este mensaje por error, le informamos=20 que no debe revelar, copiar, distribuir o usarlo en ning=C3=BAn sentido ya = que=20 est=C3=A1 prohibido por la legislaci=C3=B3n vigente. Rogamos lo comunique al=20 remitente y borre dicho mensaje y cualquier documento adjunto que pudiera=20 contener. Los datos personales que usted facilite por correo electr=C3=B3nico=20 podr=C3=A1n ser tratados por Zitro SARL con el fin de responder a su consul= ta o=20 atender su solicitud, as=C3=AD como gestionar la relaci=C3=B3n comercial, contractual= =20 o precontractual con usted. La base legitimadora de este tratamiento es el=20 inter=C3=A9s leg=C3=ADtimo de Zitro, as=C3=AD como el mantenimiento de la relaci=C3=B3n=20 contractual o de medidas precontractuales. No se ceder=C3=A1n datos a terce= ros,=20 salvo obligaci=C3=B3n legal. Sus datos ser=C3=A1n conservados durante todo el plazo=20 de duraci=C3=B3n de la relaci=C3=B3n entre usted y Zitro y, una vez terminada la=20 misma, durante el plazo que determine la legislaci=C3=B3n aplicable en cada= =20 momento. Usted podr=C3=A1 ejercitar en todo momento los derechos reconocidos en=20 la normativa de protecci=C3=B3n de datos, as=C3=AD como contactar con Zitro a trav=C3=A9s=20 de la siguiente direcci=C3=B3n:=C2=A0info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org=20 . The information contained in this message is=20 private and confidential, speaking exclusively to the recipient mentioned=20 in the heading. If you have received this message by mistake, we inform you= =20 that you should not disclose, copy, distribute or use it in any way because=20 it is prohibited by current law. Please notify the sender and delete the=20 message and any attachment that might contain. The personal data you=20 provide by email may be processed by Zitro SARL for the purpose of=20 responding to your query or attending to your request, and to manage the=20 commercial, contractual or pre-contractual relationship with you. The=20 legitimizing basis of this processing is the legitimate interest of Zitro,= =20 and the maintenance of the contractual relationship or pre-contractual=20 measures. No data will be passed to third parties unless there is a legal=20 obligation to do so. Your data will be retained throughout the term of your=20 relationship with Zitro and, once that is terminated, for the term legally= =20 required at any specific time. You may exercise your rights, as recognized=20 in data protection legislation, at any time, and you may contact Zitro at=20 the following email address:=C2=A0info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org=20 . --=20 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 e= mail 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. --000000000000372e1405c051b40b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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=C3=B3:
You could take full control of the out= put by creating the desired block yourself.

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

return pandoc.RawBlock('markdown',
=C2=A0 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<= /a>> writes:

> cross-posting of
>
https://stackoverflow.com/questions/67109880/is= -it-posible-to-enable-extensions-on-pandoc-filters#comment118648930_6710988= 0
>
> 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=C3= =B3:
>
>> 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 writ= er? 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 th= e writer...
>>
>> On Thursday, April 15, 2021 at 4:20:32 PM UTC+2 Angel Joaniquet wr= ote:
>>
>>> The lua split function is this
>>>
>>>
>>> ```lua
>>> function split(str,pat)
>>>=C2=A0 =C2=A0 local tbl =3D {}
>>>=C2=A0 =C2=A0 str:gsub(pat, function(x) tbl[#tbl+1]=3Dx end) >>>=C2=A0 =C2=A0 return tbl
>>> end
>>> ```
>>>
>>> El jueves, 15 de abril de 2021 a las 16:08:23 UTC+2, Angel Joa= niquet
>>> escribi=C3=B3:
>>>
>>>>
>>>> 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`, bu= t instead of
>>>> giving the markdown format for the math blocks (enclosed b= y `$$...$$`), it
>>>> should write the blocks as
>>>>
>>>>=C2=A0 =C2=A0 =C2=A0```=C2=A0 math
>>>>=C2=A0 =C2=A0 =C2=A0a + b =3D c
>>>>=C2=A0 =C2=A0 =C2=A0```
>>>>
>>>> The preces I have now is
>>>>
>>>> In org-mode, the math blocks are simply the latex code: >>>>
>>>> ```
>>>> \begin{equation}
>>>> a + b =3D c
>>>> \end{equation}
>>>> ```
>>>>
>>>> this is parsed as a pandoc AST `RawBlock` with format `lat= ex`. I then
>>>> remove the first (`\begin{equation}`) an last line (`\end{= equation}`), and
>>>> construct a pandoc `CodeBlock` with atrributes `{"mat= h"}`, so the
>>>> `CodeBlock` object displays in AST as
>>>>
>>>> ```
>>>> CodeBlock ("",["math"],[]) "a + b= =3D c\n"
>>>> ```
>>>>
>>>> and then I let Pandoc create the markdown document, and th= e written
>>>> result is
>>>>
>>>>=C2=A0 =C2=A0 =C2=A0``` {.math}
>>>>=C2=A0 =C2=A0 =C2=A0a + b =3D c
>>>>=C2=A0 =C2=A0 =C2=A0```
>>>>
>>>>
>>>>
>>>> **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 extens= ion
>>>> `fenced_code_attributes` to false (eg. `$pandoc -w
>>>> markdown-fenced_code_attributes ...`), but I would much pr= efer 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)
>>>>=C2=A0 =C2=A0 if rb.format =3D=3D "latex" then >>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0local text =3D rb.text
>>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0split_text =3D=C2=A0 split(text,= "[^\n]*")
>>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0if split_text[1] =3D=3D '\\b= egin{equation}'=C2=A0 and
>>>> split_text[#split_text-1] =3D=3D '\\end{equation}'= then
>>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 table.remove(split_text,= #split_text-1)
>>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 table.remove(split_text,= 1)
>>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 text =3D table.concat(sp= lit_text, "\n")
>>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 local cb =3D pandoc.Code= Block()
>>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cb.attr =3D {""= ;,{"math"}}
>>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cb.text =3D text
>>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return cb
>>>>=C2=A0 =C2=A0 =C2=A0 =C2=A0end
>>>>=C2=A0 =C2=A0 end
>>>> end
>>>> ```
>>>>
>>>>
>>>> Kind regards,
>>>>
>>>> Angel
>>>>
>>>>
>>>>
>>>>
> --
> ----------------------------------------------------------------------= -------------------------
>
> La informaci=C3=B3n contenida en este mensaje es de car=C3=A1cter priv= ado y
> confidencial, dirigi=C3=A9ndose
> 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=C3=BAn sentid= o ya que
> est=C3=A1
> prohibido por la legislaci=C3=B3n 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=C3=B3nico
> podr=C3=A1n ser tratados por Zitro SARL con el fin de responder a su c= onsulta o
> atender su
> solicitud, as=C3=AD como gestionar la relaci=C3=B3n comercial, contrac= tual
> o precontractual con usted. La base
> legitimadora de este tratamiento es el
> inter=C3=A9s leg=C3=ADtimo de Zitro, as=C3=AD como el mantenimiento de= la
> relaci=C3=B3n
> contractual o de medidas precontractuales. No se ceder=C3=A1n datos a = terceros,
> salvo obligaci=C3=B3n
> legal. Sus datos ser=C3=A1n conservados durante todo el plazo
> de duraci=C3=B3n de la relaci=C3=B3n entre usted y Zitro y,
> una vez terminada la
> misma, durante el plazo que determine la legislaci=C3=B3n aplicable en= cada
> momento.
> Usted podr=C3=A1 ejercitar en todo momento los derechos reconocidos en=
> la normativa de protecci=C3=B3n de
> datos, as=C3=AD como contactar con Zitro a trav=C3=A9s
> de la siguiente direcci=C3=B3n: info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org
> <mailto:in= fo-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 infor= m 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 Zi= tro,
> 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 leg= ally
> 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:in= fo-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org>.


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

--
You received this message because you are subscribed to a topic in the Goog= le Groups "pandoc-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pandoc-discuss/PTbqI_YhiX4/un= subscribe.
To unsubscribe from this group and all its topics, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/87sg3qq= qn9.fsf%40zeitkraut.de.


--
= 3D""
Angel Joaniquet
Mathemathician


+34 937 456 900
Ronda Maiols 23-27
08192 Sant = Quirze del Vall=C3=A9s
Barcelona


angel.joaniquet@zit= rogames.com
zitr= ogames.com
=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0

--------------------------------------------------------------= ---------------------------------

La informaci=C3=B3n contenida en este mensaje es de car=C3= =A1cter privado y confidencial, dirigi=C3=A9ndose
exclusivamente al dest= inatario mencionado en el encabezamiento. Si usted ha recibido este mensaje= por
error, le informamos que no debe revelar, copiar, distribuir o usar= lo en ning=C3=BAn sentido ya que est=C3=A1
prohibido por la legislaci=C3= =B3n 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=C3=B3nico podr=C3=A1n ser tratados por = Zitro SARL con el fin de responder a su consulta o atender su
solicitud,= as=C3=AD como gestionar la relaci=C3=B3n comercial, contractual o precontr= actual con usted. La base
legitimadora de este tratamiento es el inter= =C3=A9s leg=C3=ADtimo de Zitro, as=C3=AD como el mantenimiento de la
rel= aci=C3=B3n contractual o de medidas precontractuales. No se ceder=C3=A1n da= tos a terceros, salvo obligaci=C3=B3n
legal. Sus datos ser=C3=A1n conser= vados durante todo el plazo de duraci=C3=B3n de la relaci=C3=B3n entre uste= d y Zitro y,
una vez terminada la misma, durante el plazo que determine = la legislaci=C3=B3n aplicable en cada momento.
Usted podr=C3=A1 ejercita= r en todo momento los derechos reconocidos en la normativa de protecci=C3= =B3n de
datos, as=C3=AD como contactar con Zitro a trav=C3=A9s de la sig= uiente direcci=C3=B3n:=C2=A0info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org.

The information contained = in this message is private and confidential, speaking exclusively to therecipient mentioned in the heading. If you have received this message by m= istake, 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. T= he 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, a= nd to manage the commercial, contractual or pre-contractual
relationship= with you. The legitimizing basis of this processing is the legitimate inte= rest of Zitro, and the
maintenance of the contractual relationship or pr= e-contractual measures. No data will be passed to
third parties unless t= here 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, f= or 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:=C2=A0info-1NcKPjY1c5x0ubjbjo6WXg@public.gmane.org.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://group= s.google.com/d/msgid/pandoc-discuss/CAA1uXFihjG2S55ePoBB6F6DD-UJDjk48Tui8rY= AV%3Dnf8pNzmQA%40mail.gmail.com.
--000000000000372e1405c051b40b--