From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/29049 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ian Barnes Newsgroups: gmane.text.pandoc Subject: Re: No indent after horizontal rule Date: Tue, 17 Aug 2021 16:02:09 -0700 (PDT) Message-ID: <945bf0d5-b826-4446-a086-0b1120824e80n@googlegroups.com> References: <9953168b-aa53-4c75-b18b-612ddd8a3ddfn@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_730_1274541083.1629241329680" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39766"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDS35M7NVUMRB4X76CEAMGQEE555OHQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Aug 18 01:02:13 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oo1-f55.google.com ([209.85.161.55]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mG861-000A5k-7i for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 18 Aug 2021 01:02:13 +0200 Original-Received: by mail-oo1-f55.google.com with SMTP id 187-20020a4a01c40000b029028b01802752sf161507oor.6 for ; Tue, 17 Aug 2021 16:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=2uCpSQIH14ymQuWhGUUf0AZpgAkE2mEofmYSyI2OxCw=; b=Iqzl/Q2eGsGBblmyII922kEWG/i1D/OiVV6UAqIejVpDarRzQPfoIV7HUTRNLS/A09 F/ybC7k+/GkgPpoEtD5wJ3wTW+60HkJZwlHkEvX44aO9sHiFFprG2a3Srt0WMByKTqLF mm0jcdgsIDEsrnSWEgMi0xajh768fWuJYSOKLBfnAONFgnmQvy2wTLqfDYvBdnZ44kYr EJG9dqQu3NV/pKJ8a9yqr5O2xUZxzBRg4CDjEnFNrbUCvqfXmSRezGRbDZzh4po4WSaA gLejaY1GIO73k33JimHJqhE53ARnTBi0GFDKNMLhkTO0vB+/qyVJzK++AE+PAI5jS8+j CtMA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=2uCpSQIH14ymQuWhGUUf0AZpgAkE2mEofmYSyI2OxCw=; b=pPMlriPJEmsoxh91p9xhYUiqf8KuAEvClAODyVVYhOlRXS179GfasjL97oy9uDm/KO kr2sROUKvyBQjFuQOjNByy9PPYRe/RPe6i9GzAY8kLyA7/ByJYCzKJPhEaH85/u1+p7w YJkutEWbvpTGthodhZ78ONtmlRc0ou+VtiDQgNOHuS5pViblji7elPidzwTK9RVSmFM7 v6YEKyOj4JtHD7H/AMqjws38Rqbdf/brTzqYBGjZaSjrW7Nj5P52Eyy3KIGKngVTU9+m a9rZvG+JE8g1D0otIAT1M8BRiMbJOELciIXkA7ExREr+AZ0qfjtZTLAJPkTwja6a7EPS UE2A== 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:in-reply-to :references: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=2uCpSQIH14ymQuWhGUUf0AZpgAkE2mEofmYSyI2OxCw=; b=m0IzuOJz3MEdJOeLeBgPcykO3GoEJ9RQlCOHNLuEu5RV8HwmP4k7smNVVrw/Hiw43f +rZzrKaAt05OIkUl5iAL11Gq+u33fZno6Iv1HrdyfV6aXe+PQrd5zJm6cDiQPCBUdAeP r7b6u6pJkH+T3DYDaZP5lPfRkSuQ7BInIICd+zVnlRKOjjj7PyluBQ3Ag3cdJsItkk/b vNrxfnsOqsFJIOGImisWdmVB3NUo/nwHoocWfJQVeVOhjZLjCP4wd/BfikLO1DIbkENR jChYCbb1q8S8KdqmweebIyTE2UbX/kAHVZwFJlKZ4QpoEi9VZkJeWCDbOL0luOgqxV73 Rglg== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM530vXQf6l114hciShA0oXnKWRXxnQmt81GZNkzEfsMvVtWKCZJbO df/Td8LANbEy5WCztVq9Z4s= X-Google-Smtp-Source: ABdhPJxRpE07vozQ0wTT476PKK79mWd/vGA5VqYxrk2U51IH4ZSvFrfahZH9OSipUrSiQG4t8wVnEg== X-Received: by 2002:a05:6830:2146:: with SMTP id r6mr4387698otd.1.1629241331679; Tue, 17 Aug 2021 16:02:11 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6808:2210:: with SMTP id bd16ls120460oib.2.gmail; Tue, 17 Aug 2021 16:02:10 -0700 (PDT) X-Received: by 2002:aca:e0d7:: with SMTP id x206mr4395895oig.64.1629241330185; Tue, 17 Aug 2021 16:02:10 -0700 (PDT) In-Reply-To: X-Original-Sender: ianbarnes1963-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.io gmane.text.pandoc:29049 Archived-At: ------=_Part_730_1274541083.1629241329680 Content-Type: multipart/alternative; boundary="----=_Part_731_1330300701.1629241329680" ------=_Part_731_1330300701.1629241329680 Content-Type: text/plain; charset="UTF-8" Thanks for the response. Yes, I agree that's simpler and I tried something like that first too, but it failed on my first attempt. TeX just ignores the \noindent, because there's a blank line between it and the following paragraph in the generated TeX file. But I went back to it just now and it works if you add something like this \makeatletter \def\gobblepar{\@ifnextchar\par\@gobble\relax} \makeatother to your template or header-includes and then stick a \gobblepar after the \noindent. I'm a little concerned about what this does if the block after the hrule isn't a paragraph. Seems to result in extra vertical space. But that seems kind-of a perverse thing for a document author to do. Interesting, thanks, that was fun... On Monday, 16 August 2021 at 6:52:21 pm UTC+2 John MacFarlane wrote: > > The most straightforward approach would probably just be > > fixhrule :: Block -> Block > fixhrule HorizontalRule = > RawBlock (Format "latex") > "\\begin{center}\\rule{0.5\\linewidth}{0.5pt}\\end{center}\\noindent" > fixhrule x = x > > > Ian Barnes writes: > > > 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-discus...-/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 > . > -- 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/945bf0d5-b826-4446-a086-0b1120824e80n%40googlegroups.com. ------=_Part_731_1330300701.1629241329680 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks for the response. Yes, I agree that's simpler and I tried something = like that first too, but it failed on my first attempt. TeX just ignores th= e \noindent, because there's a blank line= between it and the following paragraph in the generated TeX file. But I we= nt back to it just now and it works if you add something like this

\makeatletter
<= div>\def\gobblepar{\@ifnextchar\par\@gobble\rela= x}
\makeatother

to your template or header-includes and then stick a= \gobblepar after the \noindent. I'm a little concerned about what this does if th= e block after the hrule isn't a paragraph. Seems to result in extra vertica= l space.  But that seems kind-of a perverse thing for a document autho= r to do.

Interesting, thanks, that was fun...
On= Monday, 16 August 2021 at 6:52:21 pm UTC+2 John MacFarlane wrote:

The most straightforward approach would probably just be

fixhrule :: Block -> Block
fixhrule HorizontalRule =3D
RawBlock (Format "latex") "\\begin{center}\\rule{0.5\\= linewidth}{0.5pt}\\end{center}\\noindent"
fixhrule x =3D x


Ian Barnes <ianbar...@gma= il.com> writes:

> It's not quite the same situation as the various discussions a= bout not=20
> wanting indents after blockquotes, but similar enough that perhaps= my=20
> solution is interesting for others.
>
> I'm converting Markdown to PDF via LaTeX, with indent:true, an= d I'm using=20
> horizontal rules as scene or section breaks. I found the indent on= the=20
> first paragraph after such a break ugly and wanted to do an automa= tic=20
> \noindent after every horizontal rule. This turned out to be prett= y easy=20
> with a Haskell filter.
>
> As it's the first time I've written anything in Haskell, I= thought I'd post=20
> it here for feedback. Seems to me like maybe there's a more co= ncise way to=20
> do the same thing.
>
> Also this could obviously be adapted to actually remove the horizo= ntal=20
> rules and replace them with the Pandoc internal representation of = a=20
> vertical skip or blank line (whatever that is).
>
> import Data.Text
> import Text.Pandoc.JSON
>
> main :: IO ()
> main =3D toJSONFilter noIndentAfterHorizontalRule
>
> noIndentAfterHorizontalRule :: Pandoc -> Pandoc
> noIndentAfterHorizontalRule doc =3D
> let Pandoc meta blocks =3D doc
> in Pandoc meta (mapAfterHorizontalRule noIndentifyPara blocks)
>
> mapAfterHorizontalRule :: (Block -> Block) -> [Block] -> = [Block]
> mapAfterHorizontalRule f (HorizontalRule : block : blocks) =3D
> HorizontalRule : f block : mapAfterHorizontalRule f blocks
> mapAfterHorizontalRule f (block : blocks) =3D block : mapAfterHori= zontalRule=20
> f blocks
> mapAfterHorizontalRule f [] =3D []
>
> noIndentifyPara :: Block -> Block
> noIndentifyPara (Para xs) =3D
> Para (RawInline (Format (Data.Text.pack "tex")) (Data.= Text.pack=20
> "\\noindent ") : xs)
> noIndentifyPara x =3D x
>
> --=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 email to pandoc-discus..= .@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/9= 953168b-aa53-4c75-b18b-612ddd8a3ddfn%40googlegroups.com.

--
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 view this discussion on the web visit https://groups.google.com/d= /msgid/pandoc-discuss/945bf0d5-b826-4446-a086-0b1120824e80n%40googlegroups.= com.
------=_Part_731_1330300701.1629241329680-- ------=_Part_730_1274541083.1629241329680--