From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/13498 Path: news.gmane.org!not-for-mail From: Tahir B Newsgroups: gmane.text.pandoc Subject: Re: Issues with using include-before/include-after when output is pdf Date: Mon, 24 Aug 2015 09:27:25 -0700 (PDT) Message-ID: <7cc8e08e-14fd-4d56-b258-036540acba31@googlegroups.com> References: <12a3b4c1-e64e-4f0d-ba1b-545311045f86@googlegroups.com> <20150723162035.GF31766@protagoras.berkeley.edu> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_2395_335166341.1440433645281" X-Trace: ger.gmane.org 1440433648 23732 80.91.229.3 (24 Aug 2015 16:27:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 24 Aug 2015 16:27:28 +0000 (UTC) To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCD6NWM3TMBRB3ML5WXAKGQESN7UWNQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon Aug 24 18:27:28 2015 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-io0-f188.google.com ([209.85.223.188]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZTual-00071a-4M for gtp-pandoc-discuss@m.gmane.org; Mon, 24 Aug 2015 18:27:27 +0200 Original-Received: by iods203 with SMTP id s203sf35822870iod.1 for ; Mon, 24 Aug 2015 09:27:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :content-type:x-original-sender:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :sender:list-subscribe:list-unsubscribe; bh=ZYcGiVTq6pS4S2yLbNWHdODsUiQe08RKvRWkIRz9pF8=; b=VqZYcmwmFSbP1Zy9Vdh77IBr+hr1hCApP6h862sp76bWzOoNeSSvbHn30ZdqybkYlN d58lIL81bT/Qqpt/kVJjsUJqGqsOh+XFZ/YHsrjr3jmtmsgcv1p832BYdw0qlrD5wtq2 9EqOH+5ryVEpYXwntYKYVEUpH93167uleu7ttpEDjSDIcEvctsMJaKLkzkZY9/u+Qcl/ 1h52bUbephnMGHImRB3cer625A6GtujRi4pGHL3bAuq80cIPvSBsjC8SlnXQNNEj+fWh WqgdJRYPPdbz+vQ/VXWbvm0A1MnsVnYPMlfPSgJWlehdThMjD7eQ65zui1CgPr/N4JaP GPGg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :content-type:x-original-sender:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :sender:list-subscribe:list-unsubscribe; bh=ZYcGiVTq6pS4S2yLbNWHdODsUiQe08RKvRWkIRz9pF8=; b=rBOF8TEXb0B1j+db1Zg0o4jl2un24mUfo34A4AcMvYiX2H6UvHwOEnz7UZ3rhUyjNb 0nZrkMyx49iSI4hGMM5HycJ5pizrinkptzs72MidkyD9ordikun2jXwm12uHxRdFx0Qm nXmXBUTsnepjyBbZYhQkBwu5B2/mwYsbjHuz7j8nHyAYLIYtn8RjBilP+jB49wACCMkV R/Q7frGt/fmeEv7bNMNOP0h2tdwzUkP4rMUAYHlmanAaeU+uWR6JJv9J6mtfyyrizYcM 0q74UyAUvpKBEYNsCVcA6DWqEieHionu1kgIfl0XfRondVJTGpiQsSvIXm41N3rt2jKK /pNg== X-Received: by 10.182.120.106 with SMTP id lb10mr324064obb.19.1440433646405; Mon, 24 Aug 2015 09:27:26 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 10.182.105.165 with SMTP id gn5ls3308435obb.20.gmail; Mon, 24 Aug 2015 09:27:25 -0700 (PDT) X-Received: by 10.182.197.203 with SMTP id iw11mr57211obc.14.1440433645712; Mon, 24 Aug 2015 09:27:25 -0700 (PDT) In-Reply-To: <20150723162035.GF31766-nFAEphtLEs/fysO+viCLMa55KtNWUUjk@public.gmane.org> X-Original-Sender: tahir.butt-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-Spam-Checked-In-Group: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.org gmane.text.pandoc:13498 Archived-At: ------=_Part_2395_335166341.1440433645281 Content-Type: multipart/alternative; boundary="----=_Part_2396_355301313.1440433645281" ------=_Part_2396_355301313.1440433645281 Content-Type: text/plain; charset=UTF-8 Hi John -- I am finally getting back to try writing such a filter. I am opting to use the python pandocfilters package to intercept this with toJSONFilter. But I don't seem to be getting it. I think I have it close but don't know how to handle the lines in the metadata include-after before the start of the reference header. But when I run pandoc with the filter, I get pandoc: The key "MetaList" was not found How should I be handling the metadata lines in the jsonfilter? How do I prepend this before the reference Header object? Thanks! from pandocfilters import toJSONFilter, RawBlock, Header import sys def latex(x): return RawBlock('latex', x) def references_includeafter(key, value, format, meta): if key == 'Header': [level, [ident, _, _], content] = value if ident == "references": if format == "latex": # insert include-after lines before start of reference header includeafter = meta.get('include-after', {}) print >> sys.stderr, str(includeafter) return includeafter if __name__ == "__main__": toJSONFilter(references_includeafter) -- 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/7cc8e08e-14fd-4d56-b258-036540acba31%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. ------=_Part_2396_355301313.1440433645281 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi John --

I am finally getting back to= try writing such a filter. I am opting to use the python pandocfilters pac= kage to intercept this with toJSONFilter. But I don't seem to be gettin= g it.

I think I have it close but don't know h= ow to handle the lines in the metadata=C2=A0include-after before the start = of the reference header.

But when I run pandoc wit= h the filter, I get=C2=A0pandoc: The = key "MetaList" was not found

H= ow should I be handling the metadata lines in the jsonfilter? How do I prep= end this before the reference Header object?

= Thanks!

from pandocfilters import toJSONFilter, RawBlock, Header
import sys


def latex(x):
= =C2=A0 =C2=A0 return RawBlock('latex', x)


= def references_includeafter(key, value, format, meta):
=C2=A0 =C2=A0 if key =3D=3D 'Header&= #39;:
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 [level, [ident, _, _], content] =3D value
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if ident = =3D=3D "references":
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if format =3D=3D "= ;latex":
=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # insert include-after li= nes before start of reference header
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 in= cludeafter =3D meta.get('include-after', {})
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 print >> sys.stderr, str(includeafter)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 return includeafter

if __name__ =3D=3D "__main__":
=C2=A0 =C2=A0 toJSONFilter(references_includeaf= ter)



--
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/7cc8e08e-14fd-4d56-b258-036540acba31%40googlegroups.co= m.
For more options, visit http= s://groups.google.com/d/optout.
------=_Part_2396_355301313.1440433645281-- ------=_Part_2395_335166341.1440433645281--