public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: nickbart1980-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: How to enclose reference list entries in a latex environment?
Date: Sat, 28 Mar 2015 10:02:33 -0700 (PDT)	[thread overview]
Message-ID: <135f56b1-9ca7-4f33-9216-a09c01e88518@googlegroups.com> (raw)
In-Reply-To: <20150328152704.GC49524-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>


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

Great, thank you – this filter:

#!/usr/bin/env runhaskell

-- addRefEnvItem.hs

import Text.Pandoc.JSON
import Text.Pandoc.Walk

main :: IO ()
main = toJSONFilter addRefEnvItem

addRefEnvItem :: Maybe Format -> Block -> Block
addRefEnvItem (Just (Format "latex")) (Div ("",["references"],[]) (h@(Header 
_ _ _) : blocks)) =
  Div ("",["references"],[]) ( [h, latex "\\begin{references}"] ++ 
concatMap addItem blocks ++ [latex "\\end{references}"] )
  where latex = RawBlock (Format "latex")
addRefEnvItem _ x = x

addItem :: Block -> [Block]
addItem x = [RawBlock (Format "latex") "\\item", x]

together with this definition:

\newenvironment{references} {\list{}{%
    \leftmargin1.5em%
    \itemindent-\leftmargin%
    %\itemsep0pt%
    %\parsep0pt%
    }}
    {\endlist}

give very nice results now. I'll try this out a bit more and report back.

Anyway, my feeling is that using lists for bibliographies (at least in 
latex, not sure about html etc.) is probably the way to go for pandoc in 
general. Using lists, it wouldn't seem too difficult to make numbered 
styles (e.g.., nature.csl) work properly, too. pandoc would just have to 
move the first field in a CSL style file bibliography definition into an 
item label (`\item[firstfield]`), and adjust the list definition to the 
width of the widest label, of course. I'll try and figure out some of the 
details.

Thanks again for all suggestions so far!

On Saturday, 28 March 2015 15:27:19 UTC, John MacFarlane wrote:
>
> As far as I can see, there's no problem having a blank line after 
> `\item` in latex.  So, something like this? 
>
> import Text.Pandoc.JSON 
> import Text.Pandoc.Walk 
>
> main :: IO () 
> main = toJSONFilter addHangPara 
>
> addHangPara :: Maybe Format -> Block -> Block 
> addHangPara (Just (Format "latex")) (Div ("",["references"],[]) (h@(Header 
> _ _ _) : blocks)) = 
>   Div ("",["references"],[]) ( [h, latex "\\begin{references}"] ++ 
>   concatMap addItem blocks ++ [latex "\\end{references}"] ) 
>   where latex = RawBlock (Format "latex") 
> addHangPara _ x = x 
>
> addItem :: Block -> [Block] 
> addItem x = [RawBlock (Format "latex") "\\item", x] 
>
>

-- 
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/135f56b1-9ca7-4f33-9216-a09c01e88518%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

      parent reply	other threads:[~2015-03-28 17:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-26 19:57 nickbart1980-Re5JQEeQqe8AvxtiuMwx3w
     [not found] ` <ce053b54-950b-497b-ba33-f0a43c0dd559-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-27  4:05   ` John MacFarlane
     [not found]     ` <20150327040534.GC35873-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2015-03-27  8:19       ` nickbart1980-Re5JQEeQqe8AvxtiuMwx3w
     [not found]         ` <4cd4b00d-3b34-4c19-8b2c-59b6e66eee7d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-27 11:17           ` Nick Yakimov
     [not found]             ` <e881c6dc-b3ad-425d-a1d5-7e030adb9d68-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-27 14:46               ` nickbart1980-Re5JQEeQqe8AvxtiuMwx3w
     [not found]                 ` <d6015803-4bdd-4cab-bb75-3d502ef8cb08-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-27 18:26                   ` John MacFarlane
2015-03-27 18:20           ` John MacFarlane
     [not found]             ` <20150327182009.GB37676-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2015-03-27 18:27               ` John MacFarlane
     [not found]                 ` <20150327182752.GD37676-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2015-03-27 22:22                   ` nickbart1980-Re5JQEeQqe8AvxtiuMwx3w
     [not found]                     ` <584f68ea-db87-4c21-9c13-10d8f6a9118f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-28  1:15                       ` Nikolay Yakimov
2015-03-28  3:17                       ` John MacFarlane
     [not found]                         ` <20150328031718.GD37821-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2015-03-28  9:52                           ` nickbart1980-Re5JQEeQqe8AvxtiuMwx3w
     [not found]                             ` <08aa7ab5-40b2-45f2-8a86-635c75018bb9-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-28 10:05                               ` Nikolay Yakimov
     [not found]                                 ` <CA+hqrpVmrGj7a4G2Ss1FdXkgn=QQXNiK9Smg7aGYxyH2naYdiw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-28 12:22                                   ` nickbart1980-Re5JQEeQqe8AvxtiuMwx3w
     [not found]                                     ` <472e1709-92d6-4c1d-961d-edad2b55bfd0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-28 13:10                                       ` Nick Yakimov
     [not found]                                         ` <9f84082a-3ad0-40f2-b0f5-ad564cbe5d24-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-28 14:28                                           ` nickbart1980-Re5JQEeQqe8AvxtiuMwx3w
     [not found]                                             ` <46a6f65e-a2fe-4207-bbf2-0c96524ebe7d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-28 14:40                                               ` Nick Yakimov
     [not found]                                                 ` <8efa389a-8880-491d-8f18-7e8ae1b38669-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-03-28 15:19                                                   ` nickbart1980-Re5JQEeQqe8AvxtiuMwx3w
2015-03-28 15:27                                                   ` John MacFarlane
     [not found]                                                     ` <20150328152704.GC49524-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2015-03-28 17:02                                                       ` nickbart1980-Re5JQEeQqe8AvxtiuMwx3w [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=135f56b1-9ca7-4f33-9216-a09c01e88518@googlegroups.com \
    --to=nickbart1980-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).