From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/23100 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Sven Lauer Newsgroups: gmane.text.pandoc Subject: Inheritance / fallback for lua writers? Date: Tue, 9 Jul 2019 08:22:52 -0700 (PDT) Message-ID: <0520a2cf-0235-4dd0-81d4-5109daedbb4c@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_2623_1570970931.1562685772700" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="7092"; mail-complaints-to="usenet@blaine.gmane.org" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCH4VVVM4ECBBTXCSLUQKGQEOEWEQUQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Jul 09 17:22:57 2019 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-oi1-f189.google.com ([209.85.167.189]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1hkrxH-0001hF-UV for gtp-pandoc-discuss@m.gmane.org; Tue, 09 Jul 2019 17:22:56 +0200 Original-Received: by mail-oi1-f189.google.com with SMTP id l15sf3310615oic.13 for ; Tue, 09 Jul 2019 08:22:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:message-id:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=jC6wYAvlDaMQVhL7PxWr/Q2EVPJJ/Lf4oVDDnhhzVzU=; b=XoJvtXDpVBRgcRgt8B9dDlVL8/CYW7FCGgxBSYGqpwo6KiKIPr3es2BxgRwcznrBRT yDu9op0Cc5TRGUjBo3CXZyvpJx727APtgNgJIuKuuv99W7ngdGBC/MqYZ2mnOveFbYhO NolJ6jDO3kfqSvK3PqcNIkbl7RvmEDMmIHJBwxKDQbkhTDQ0AAKID7bX3XN93Hu127MY vRRPhEimfZfXFCZuqeJ5kQW+pGsw4zw1+LjTnn8mPbG+xYT8ed2mszZqY3oba0NnyJEO zA2HYPKQHhvplOFphU92TVhPCYkowwCYoMBbNd0UPkw3YW9AVo1pNPrckyTjlCM83pra 3DOA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:subject:mime-version:x-original-sender :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=jC6wYAvlDaMQVhL7PxWr/Q2EVPJJ/Lf4oVDDnhhzVzU=; b=BqngogS2zK9zHKlqOB+bzJEQiRjaijIKyjEdU/7dE+uPuIxp5l6OvZQ24HYqHDTaf6 4t0CBqcWMwAElwpFDL5+CofWK6QMzfT7INGUiE0Nd+vjzqe65d+QTKv8aBJbUy+qIWPy kWMKTlfZCiF6YhZy0lSYM1/XOP85nhPoo0C8QN6FwJb5EPbnFy0SKu0zBVAHdT6B3LGx vNA+O2+1qQt1tmFk+YoDqqPUjBqDAgg6UJriR406XEkVTBS560G+VQZMOG2uhI8xdVwW /oNE1DPHrIjEbVNYXLp6CIb0SHVYERUW47/+SRkUhz+QKcvxgpqCAVXSvuGElvBqTboR eCOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:date:from:to:message-id:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=jC6wYAvlDaMQVhL7PxWr/Q2EVPJJ/Lf4oVDDnhhzVzU=; b=p3V2Sgf2gxmgF1gZt/8v8fSkwanh0w6boXYgG9FE0nxV2r9k2GG5gf8mV3IeLel8N/ UjPi+bIhLzzhKGcKxcxEpwjYDjIBYylbYrg6F668v7CmD5lE/5wAeq3C3jOdtLwefyJk UsuVq9TS5QiYjFRZeWe8ghuCdSa4pffhJzWlBFQD3Yz9szqBmEf6WM8egXPk9pF6n/aB w5jz2l+8tAXnlPU+UIEacdcmfqobtuj/LxBsyTKyUWcjxaebIOnGyuAMeHnOjpDDOB1E +SLfc3Bq0ZWSbY/tuY+vYfjGJtFLzhWjrIh6SVE/bnQrg0FMhjjgxq857OZ01SiM/9Gh yRzg== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: APjAAAVt26XctSxmRc2TDLYrQWcM1TSYvnP+MDBqJ5gvPiL830UZWhep Ri08N3cm/sBZN2qjECaqxpU= X-Google-Smtp-Source: APXvYqzHff4YoMUJdJf7vhYjNbjOi8oH9HDuUnx0odmSBvqK4VegAF+YRwAw+LaKmvvHnwaJikSqFw== X-Received: by 2002:a54:441a:: with SMTP id k26mr330097oiw.78.1562685774587; Tue, 09 Jul 2019 08:22:54 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a9d:4804:: with SMTP id c4ls658901otf.10.gmail; Tue, 09 Jul 2019 08:22:53 -0700 (PDT) X-Received: by 2002:a9d:4103:: with SMTP id o3mr6213487ote.134.1562685773496; Tue, 09 Jul 2019 08:22:53 -0700 (PDT) X-Original-Sender: tired.philanthropist-Re5JQEeQqe8AvxtiuMwx3w@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.org gmane.text.pandoc:23100 Archived-At: ------=_Part_2623_1570970931.1562685772700 Content-Type: multipart/alternative; boundary="----=_Part_2624_855589695.1562685772700" ------=_Part_2624_855589695.1562685772700 Content-Type: text/plain; charset="UTF-8" Hello, is there a way to "inherit" from another writer when coding a lua writer? To clarify, my use case: When the output format is latex/pdf, I want to render spans with a certain class in a special way. I could write a custom lua writer, but unless there is an inheritance/fallback mechanism, I would have to reproduce all of the functionality of the (excellent) standard latex writer, and in the future, I would have to update it whenever the standard writer is changed. So: Is there a way (either on the command line or in the lua writer file) to say: "If an element is not defined here, use the element from writer X"? (For then, I could simply re-define the rendering function for Span, and let all other elements "fall back" to the standard implementation.) If this is not possible, is there any chance this could be included in the future? I would volunteer to help making this happen, but unfortunately my Haskell skills are not really existent. In the most awesome version of this, one would even have an option to invoke the "fall back" version of a rendering function (maybe just by returning nil?), so that one can say something like: function Span(s, attr) if [has class "foo"] then ... do special handling ... else ... use implementation from fallback ... end end This would make it really easy to develop writers that "add on" to existing ones, without reinventing the wheel / rewriting the existing writer while doing so. (Right now, I am using a lua filter that transforms the spans in question to RawInlines (a la https://ulyngs.github.io/blog/posts/2019-02-19-how-to-use-pandoc-filters-for-advanced-customisation-of-your-r-markdown-document/ ) - but this seems hacky, since all I want is to specify how to output those spans in a particular output format ... which should be done in a writer, shouldn't it? Best, Sven -- 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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/0520a2cf-0235-4dd0-81d4-5109daedbb4c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. ------=_Part_2624_855589695.1562685772700 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,

is there a way to "inherit&= quot; from another writer when coding a lua writer?

To clarify, my use case: When the output format is latex/pdf, I want to r= ender spans with a certain class in a special way.

I could write a custom lua writer, but unless there is an inheritance/fall= back mechanism, I would have to reproduce all of the functionality of the (= excellent) standard latex writer, and in the future, I would have to update= it whenever the standard writer is changed.

So: I= s there a way (either on the command line or in the lua writer file) to say= : "If an element is not defined here, use the element from writer X&qu= ot;? (For then, I could simply re-define the rendering function for Span, a= nd let all other elements "fall back" to the standard implementat= ion.)

If this is not possible, is there any chance= this could be included in the future? I would volunteer to help making thi= s happen, but unfortunately my Haskell skills are not really existent.

In the most awesome version of this, one would even ha= ve an option to invoke the "fall back" version of a rendering fun= ction (maybe just by returning nil?), so that one can say something like:
function Span(s, attr<= /span>)
=C2=A0 =C2=A0if
[has class "foo"] then=
=C2=A0 =C2=A0 =C2=A0
... d= o special = handling .= ..
=C2= =A0 =C2=A0
= else
= =C2=A0 =C2=A0 =C2=A0
... use implementat= ion from fallback ...
=C2=A0 =C2=A0end
end


This would make it really = easy to develop writers that "add on" to existing ones, without r= einventing the wheel / rewriting the existing writer while doing so.
<= div>
(Right now, I am using a lua filter that transforms the = spans in question to RawInlines (a la=C2=A0https://ulyngs.github.io/blog/posts/2019-= 02-19-how-to-use-pandoc-filters-for-advanced-customisation-of-your-r-markdo= wn-document/=C2=A0) - but this seems hacky, since all I want is to spec= ify how to output those spans in a particular output format ... which shoul= d be done in a writer, shouldn't it?

Best,
Sven

--
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/= msgid/pandoc-discuss/0520a2cf-0235-4dd0-81d4-5109daedbb4c%40googlegroups.co= m.
For more options, visit http= s://groups.google.com/d/optout.
------=_Part_2624_855589695.1562685772700-- ------=_Part_2623_1570970931.1562685772700--