public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Ian Barnes <ianbarnes1963-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: No indent after horizontal rule
Date: Mon, 16 Aug 2021 07:03:55 -0700 (PDT)	[thread overview]
Message-ID: <9953168b-aa53-4c75-b18b-612ddd8a3ddfn@googlegroups.com> (raw)


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

It's not quite the same situation as the various discussions about not 
wanting indents after blockquotes, but similar enough that perhaps my 
solution is interesting for others.

I'm converting Markdown to PDF via LaTeX, with indent:true, and I'm using 
horizontal rules as scene or section breaks. I found the indent on the 
first paragraph after such a break ugly and wanted to do an automatic 
\noindent after every horizontal rule. This turned out to be pretty easy 
with a Haskell filter.

As it's the first time I've written anything in Haskell, I thought I'd post 
it here for feedback. Seems to me like maybe there's a more concise way to 
do the same thing.

Also this could obviously be adapted to actually remove the horizontal 
rules and replace them with the Pandoc internal representation of a 
vertical skip or blank line (whatever that is).

import Data.Text
import Text.Pandoc.JSON

main :: IO ()
main = toJSONFilter noIndentAfterHorizontalRule

noIndentAfterHorizontalRule :: Pandoc -> Pandoc
noIndentAfterHorizontalRule doc =
  let Pandoc meta blocks = doc
   in Pandoc meta (mapAfterHorizontalRule noIndentifyPara blocks)

mapAfterHorizontalRule :: (Block -> Block) -> [Block] -> [Block]
mapAfterHorizontalRule f (HorizontalRule : block : blocks) =
  HorizontalRule : f block : mapAfterHorizontalRule f blocks
mapAfterHorizontalRule f (block : blocks) = block : mapAfterHorizontalRule 
f blocks
mapAfterHorizontalRule f [] = []

noIndentifyPara :: Block -> Block
noIndentifyPara (Para xs) =
  Para (RawInline (Format (Data.Text.pack "tex")) (Data.Text.pack 
"\\noindent ") : xs)
noIndentifyPara x = 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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/9953168b-aa53-4c75-b18b-612ddd8a3ddfn%40googlegroups.com.

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

             reply	other threads:[~2021-08-16 14:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AQHXkr8WZu2wiXXT3kiqv6VEeWbF9qt4MMqAgACqNhA=>
2021-08-16 14:03 ` Ian Barnes [this message]
     [not found]   ` <9953168b-aa53-4c75-b18b-612ddd8a3ddfn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-08-16 16:52     ` John MacFarlane
     [not found]       ` <m2im05s56x.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
2021-08-17 23:02         ` Ian Barnes
     [not found]           ` <945bf0d5-b826-4446-a086-0b1120824e80n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-08-18  7:12             ` AW: " denis.maier-NSENcxR/0n0
     [not found]               ` <23250a1cbd394d0487439d89bf180814-NSENcxR/0n0@public.gmane.org>
2021-08-18  7:29                 ` Ian Barnes
     [not found]                   ` <a2305a76-f1a6-420a-a589-f0a95a7fecb3n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-08-22  8:39                     ` Ian Barnes
     [not found]                       ` <acf9a5d3-ff84-404b-8b3b-9d152b5f4621n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-08-23  9:14                         ` AW: " denis.maier-NSENcxR/0n0
2021-08-18  8:13                 ` BPJ
2021-08-22  8:36                 ` Ian Barnes

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=9953168b-aa53-4c75-b18b-612ddd8a3ddfn@googlegroups.com \
    --to=ianbarnes1963-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).