From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/28179 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Albert Krewinkel Newsgroups: gmane.text.pandoc Subject: Re: Modify writer or extensions inside a filter Date: Fri, 16 Apr 2021 15:56:42 +0200 Message-ID: <87sg3qqqn9.fsf@zeitkraut.de> References: <509d7700-5cb3-4382-9276-c4b2e2a0c3e5n@googlegroups.com> <50d9ae1b-95a0-445f-9ab2-5b1fe2cc992fn@googlegroups.com> <03f7ab59-6b1a-451e-8528-4b164d439dc4n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35643"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCZJF7XJTILRBIFP42BQMGQEUS46WMI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Apr 16 15:56:53 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-lf1-f57.google.com ([209.85.167.57]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lXOxn-00092e-9s for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 16 Apr 2021 15:56:51 +0200 Original-Received: by mail-lf1-f57.google.com with SMTP id v23-20020a05651203b7b02901abd47176ffsf3943115lfp.9 for ; Fri, 16 Apr 2021 06:56:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1618581411; cv=pass; d=google.com; s=arc-20160816; b=QBO+gUqw4PkN2yIt8Ty03SXKU0IW18GGZw08sWsueMBDyfN8Tssf/4QFmMiU+qLTNE mnyB9s0g96yzTA/UEudd9P8p+xAaqj8pMFItiyD32DKgngtZVMyfyqEyZG7VlKH3CNnD 39jvXid330go07vmfTIUtFsQ6imZJRig/HzPRuhcl6os/oIQDhbwTe0fpHW1iRaiUxNU pPxkpIT5D/VSo6wyg8Rxmdp96Pq7iv61eazNTvzFwAlKdxP0xG+cBinZ1ceC5D//BkQA /G++ZI97yx9BVwk38ld+HRUFo7mMJ5WFxjVW24fJXhXNkyqIuIhL6JfxGKOIhHzT4ovl 8Z5w== 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:content-transfer-encoding :mime-version:message-id:date:in-reply-to:subject:to:from:references :sender:dkim-signature; bh=8GstyzymEsXT5JKmkra/HTEFrBfTB0a4AOZjesO49vw=; b=YsvZQl7tXtvAWYlwHQftauDaSfzC6PGA/gQFpiC3i/PKQy5skcotj4yjLyvW1o4uBD zVzXlgIbKWw1eN783GnIi4Q7c4ik+NI4HlonnLTgBe7jMu6smO7iTcrsZTeenWa+8C3G zpXafs63JmkKn5PqKUfS8lhZQeijiTCToB6TuDusuFiD96GD3VxejrxKP6pKhBgFovnU d7hz3KtTLGgrYhjDIBBsyIpQ1I1dOZb2sIFi6m9jKDhaUWp027b8keoxM5cMtYGFy3wd ZBieB/xUkgXo75+DLmeMyGlmhCq1F29AdxnSrx69VGqpkH1lNU3NwmAqDD7eUjcJt6wy 9pgw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.152 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:references:from:to:subject:in-reply-to:date:message-id :mime-version:content-transfer-encoding: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=8GstyzymEsXT5JKmkra/HTEFrBfTB0a4AOZjesO49vw=; b=teR6EHwvZNTdyXXGQ5i1OeXeYqCdG9iajgwQfnlYBGYIWnrG8lZmk+h36UN9B/SBiw OdscuvST7+Vjrc+u1ASGNVYeUpzqNyJMYzlGVzRiuvRn5Ae5CMPvXBnXT9ADBcqoBVPu gB2uvsbx/tadujIUSxHrWcp5ycB1jXtyCrHfBtl69Kqg6bOhQjBhWiQDP4g+EDEg1MmR ujPGR/Tt3vFbID/E9XR2pKhOmn1hI6nOjvG+LH5V9vi1wo1S40B8uxjhAOY+JIOh4ogQ /6o0Y7lmvG2Qar8g0W8eMIthLmBe2XDGAvrj+TeUdwXdAeh/iloP0YiETyQsHNnNWLHf eXvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:references:from:to:subject:in-reply-to :date:message-id:mime-version:content-transfer-encoding :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=8GstyzymEsXT5JKmkra/HTEFrBfTB0a4AOZjesO49vw=; b=JTSb3yLFknSvJyMcmF+Xhei70wIsms/jPQecLiuhNXgnknVxyOGzQjASkScvCFJNzK +0fVL39n28VbsEceH0Ofg31smW055KebWSFuQIiAHhS8uOKG5AJif4nC8hxClRZSwVcz KFcIcfKknxbHCFKnasAjnOHmydpQ6G5LpbtSREXOG28cHG0ltvaK4P7E0tCk1KUUPzl7 t7F0JY64KCA0dIo92m9uMt1HQwKnw4YH7xSDmviBc/i6TidljPyJ5GejbjMScFVTSUaf OKVrFn8IobOCm8qR7lUa5Pu12ZlbvMDg5z295vCml7hS56e6d0pTDJ7Viv6zMUPzcTve Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM532Qo5TKUz2zwjlRBi9OM6QJg1bGk0qkNLZKc2HJOR0XRvEYA2u+ i8d0reDq5H4+5r7SVps0L+M= X-Google-Smtp-Source: ABdhPJz7hKnidycZ2phZA+u6fjA4KuoFUmOHge9lR4R3tC25pxy3b3U9O/ZfdOhAlIzdK9GHMlp/Nw== X-Received: by 2002:a05:6512:2254:: with SMTP id i20mr3160604lfu.56.1618581410833; Fri, 16 Apr 2021 06:56:50 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6512:39cc:: with SMTP id k12ls903636lfu.0.gmail; Fri, 16 Apr 2021 06:56:48 -0700 (PDT) X-Received: by 2002:a05:6512:3f2a:: with SMTP id y42mr3017299lfa.234.1618581408009; Fri, 16 Apr 2021 06:56:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618581408; cv=none; d=google.com; s=arc-20160816; b=fcbjz1mTSpFsCeQli7API0Y5yhAid+InBcoNgG/tqZc6WoBT25kpkV8YdszK9oEmrR gTO9fFKhB9MggeApJ7IAIehtWPnhMQE/lweoAAkviCI+I7DScf0CGZokSz9odFe9JLIF rupKsC7GEwvO/Js3oojXyyWniSoDBZ1DAn8O6Yl65Xz+t3IfsACFOcE89KmBlngpMcOp 9VsnXq3UOdBzegweMlmNZURokxlHdBaQ3L56IYg+PLtopEHYaPwTAf3iHXaqKh/+ol/a 1yOjItyMx4YjfO6WiEXZkeicly7v1wHNZC5z+oRX5VsiUKzRLPPQV2LEcQGJy3XpjkFN WyyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:in-reply-to :subject:to:from:references; bh=vnpW07T5oB66te+8vqHVC1Ck9nzpEEo1hWAwBZhSKxI=; b=uGlB/7VW8HNPT5F8u9D5XYTJDLzZNujb/I5nyxVXhPv7CKT0qAhFOuoyW6xfc/I2ch dZkjVeJlh5uaIlVhO8AqQ2HU6SVDmqXu2msFyf/p4jQut6bz19XELsdTr06w6p4FHVYO yWOb9bAlczhlvEtfd3bo9JGZSHaSiGfyOiGo2J42lqYDR5CDLcRG8YpqefSGRwB7XSEz KHUutpB99bB1y++e34i+9wn0lh56ACZGZZ6IDIpK7hrqKTVypfwtWCLARbD/84YrUF3Q 4Ud0ogNnutYnh3+MuOdYAGgVn1TpfMsOR0xmCAprqQ1EJW5AmQqr2i38Rnw7tTzjVjuB 3l/g== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.152 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org Original-Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org. [80.241.56.152]) by gmr-mx.google.com with ESMTPS id n13si329821lfi.5.2021.04.16.06.56.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Apr 2021 06:56:47 -0700 (PDT) Received-SPF: pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.152 as permitted sender) client-ip=80.241.56.152; Original-Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4FMHnW1wr6zQk0w for ; Fri, 16 Apr 2021 15:56:47 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Original-Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id UCuCizl6cKvF for ; Fri, 16 Apr 2021 15:56:42 +0200 (CEST) In-reply-to: <03f7ab59-6b1a-451e-8528-4b164d439dc4n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Rspamd-Score: -6.60 / 15.00 / 15.00 X-Rspamd-Queue-Id: E46CD1111 X-Rspamd-UID: d2b599 X-Original-Sender: albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.152 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org 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:28179 Archived-At: You could take full control of the output by creating the desired block you= rself. 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 writ= es: > 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-ext= ensions-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 =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 to >>>> GitLab-markdown (not supported by Pandoc out of the box), in particula= r, >>>> 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 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 =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 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 do= ne >>>> 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 privado= 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 y= a 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 cons= ulta o > atender su > solicitud, as=C3=AD como gestionar la relaci=C3=B3n comercial, contractua= l > 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 ter= ceros, > 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 ca= da > 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 y= ou > 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 legall= y > 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 --=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/87sg3qqqn9.fsf%40zeitkraut.de.