public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Gwern Branwen <gwern-v26ZT+9V8bxeoWH0uzbU5w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: Removing parts of the document with [walk] in Haskell
Date: Sun, 5 Sep 2021 11:42:23 -0400	[thread overview]
Message-ID: <CAMwO0gwipJYRLBdt=MOcn_=c_xWu5q-9Y54BZ+vr0SH7anAHaw@mail.gmail.com> (raw)
In-Reply-To: <1473b62b-4b33-49b5-ac6d-52a5571d8068n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>

On Sun, Sep 5, 2021 at 11:09 AM Ilia Zaihcuk <zoickx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> The trick with using Span is neat, although it does seem more like a workaround than a true solution - it is making additional changes to the AST after all. Can I be sure that they won't influence my output in unexpected ways? (e.g. some obscure issue like auto-hyphenation in LaTeX, page breaks, etc.)

I only use HTML output, so I have no idea what other targets like
LaTeX do, or if they even output spans at all. Using the span trick
necessarily introduces spans around the rewritten text, but I think
this is generally desirable. (The whole point of the smallcaps pass is
to add marked-up spans for the CSS to apply a smallcaps variant to,
and the spans allow me to suppress redundant definitions of terms when
doing link rewrites.) The spans might change the necessary CSS for
something or other, but I haven't run into any edge-cases there.

If the span wrappers worry you, you can do an additional pass to
change them, but you are going to run into the basic 'expression
problem' https://en.wikipedia.org/wiki/Expression_problem regardless:
a strong static FP language like Haskell makes it extremely easy and
downright trivial to write a function like 'Inline -> Inline' to plug
into 'Pandoc -> Pandoc', but the cost of this is that the datatype
'Inline' or 'Pandoc' cannot be changed easily.

(But at least doing a cleanup pass scales well in terms of effort:
define all the rewrites you need with the Span trick easily, and then
write a single painful cleanup pass.)

> This is scary! Correctness is certainly more important than speed. Do you have a concrete example where this issue occurs? If @jgm (the original author of pandoc!) is using this method and there are cases in which it behaves unexpectedly, this sounds worthy of an issue and/or a pull request on GitHub.

I think the recursion patterns tend to work worst when you are adding
in new nodes so that it adds a new node, then descends into it,
applies the same rewrite adding new nodes, descends into them... Stuff
like that. Not necessarily wrong, but subtle and requiring a lot of
understanding to know which one to use.

-- 
gwern
https://www.gwern.net

-- 
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/CAMwO0gwipJYRLBdt%3DMOcn_%3Dc_xWu5q-9Y54BZ%2Bvr0SH7anAHaw%40mail.gmail.com.


      parent reply	other threads:[~2021-09-05 15:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-04 19:09 Ilia Zaihcuk
     [not found] ` <915213fc-e4c4-480b-a6a2-fd3420777ddan-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-09-04 19:26   ` Gwern Branwen
2021-09-05  5:23   ` John MacFarlane
     [not found]     ` <m2mtorlhoo.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
2021-09-05 15:09       ` Ilia Zaihcuk
     [not found]         ` <1473b62b-4b33-49b5-ac6d-52a5571d8068n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-09-05 15:42           ` Gwern Branwen [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='CAMwO0gwipJYRLBdt=MOcn_=c_xWu5q-9Y54BZ+vr0SH7anAHaw@mail.gmail.com' \
    --to=gwern-v26zt+9v8bxeowh0uzbu5w@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).