public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: BPJ <melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: Invisible Markdown code that becomes functioning LaTeX code?
Date: Tue, 6 Oct 2020 17:14:42 +0200	[thread overview]
Message-ID: <CADAJKhB74ZCD4+fWke31rL+BHxTos5=M9yaiQaFBDibHKR03Lw@mail.gmail.com> (raw)
In-Reply-To: <0911d10b-4e31-4d6b-b8e7-67e5ac567ac6n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 8615 bytes --]

What I suggest, although I didn't spell it out clearly, is that you have
one master version of your document written in Pandoc's dialect of
Markdown, complete with inline LaTeX, from which you can

*   convert Markdown → LaTeX, or directly Markdown → PDF, letting Pandoc
use temporary LaTeX files under the hood. You might need to use a custom
template and/or some header inclusions, but generally this is the easier
part, for Pandoc.

*   convert Markdown → Markdown to get a version of Markdown which the
server/whatever which does the Markdown → HTML conversion can handle
correctly. If I understand correctly this would at least involve removing
inline LaTeX, which that other tool can't handle. For that a Pandoc filter
like the one in my previous mail might be needed.

However it might also work to use markdown_strict as Pandoc's output
format, although then you would lose extensions which Python Markdown *can*
handle, like footnotes and definition lists. That's why one or more Pandoc
filters (which work on the Pandoc AST as a data structure) to remove LaTeX
or to remove or "translate" Pandoc Markdown extensions into syntax which
Python Markdown understands may be a better option. I am not familiar with
python-markdown, but to judge from <
https://python-markdown.github.io/extensions/> and <
https://github.com/Python-Markdown/markdown/wiki/Third-Party-Extensions>
linked from there some of the more "basic" extensions like footnotes,
definition lists, fenced code blocks, super-/subscripts either use the same
syntax already or can easily be modified with a filter (with outright raw
HTML injection as a last resort, made easier by the fact that both dialects
support Markdown-in-HTML.)

Producing more than one output format from the same Markdown source (LaTeX
and another variety of Markdown, or at least a somewhat stripped Markdown
in this case) presents its own considerations. You might for example use a
native Pandoc divs and spans for some things and use filters to
inject/replace them with the needed raw LaTeX/HTML/python-markdown markup
around the contents of the div or span, or somewhat differently replace
snippets of inline LaTeX with inline HTML, depending on which output format
you are producing

-- 
Better --help|less than helpless

Den tis 6 okt. 2020 14:51Joseph Zitt <joseph.zitt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:

> Thanks. I may not have been clear about the workflow, though. The
> interpreter that turns the Python-Markdown into HTML isn't Pandoc and isn't
> under my control. It's done by the newsletter site as part of sending it
> out. (BTW, I'm using buttondown.email, which I like, and which is just
> right for my purposes.) I then take the markdown from there, save it onto
> my Mac, and run Pandoc to convert it to LaTeX. I realized earlier today
> that I could probably just pipe the generated LaTeX through a smaill,
> simple Perl script before converting it with pdflatex. But doing it within
> Pandoc would be somewhat cleaner (I've already put together a simple
> Template that helps a lot in getting it to look like I want), and something
> I'd like to learn. I looked at the Lua documentation for the first time
> today and still have to wrap my mind around some of the concepts.
>
> On Tuesday, October 6, 2020 at 3:32:06 PM UTC+3 BP wrote:
>
>> If you are rendering your markdown with python-markdown then you must of
>> course escape inline LaTeX as python-markdown does, if it offers a way, and
>> what Pandoc does becomes irrelevant. If your intention is, as I suspect, to
>> render your markdown as HTML with python-markdown and as LaTeX with Pandoc
>> you can use a Pandoc filter to strip inline LaTeX from your markdown before
>> passing the markdown to python-markdown. Such a filter would be very simple:
>>
>> function RawInline (raw)
>>   if raw.format:match('tex$') then
>>     return {} -- delete it!
>>   else
>>     return nil -- keep it!
>>   end
>> end
>> RawBlock = RawInline
>>
>> Save the above in a file 'strip-tex.lua' and run this on the command line
>> with
>>
>> pandoc -L strip-tex.lua -w markdown -o text-py.md text.md
>>
>> and then pass the resulting file 'text-py.md' to python-markdown.
>>
>> If there are further differences between Python Markdown and Pandoc
>> Markdown just describe them. They can probably be solved with some filter
>> etc. The worst thing that may happen is that you will have to write some
>> things duplicated and marked as Pandoc/Python markup respectively and a
>> filter/extra run of Pandoc to sort them out.
>>
>>
>> --
>> Better --help|less than helpless
>> Den tis 6 okt. 2020 09:48Joseph Zitt <josep...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>>
>>> I understand from the newsletter developer that it uses python-markdown,
>>> which doesn't ignore LaTeX in it. There are ways to put comments in it, in
>>> a line something like
>>>
>>> [comment] <> This is a comment
>>>
>>> preceded by a blank line, but Pandoc (as appropriately designed) strips
>>> them out entirely without interpreting anything,
>>>
>>> On Monday, October 5, 2020 at 8:53:05 PM UTC+3 BPJ wrote:
>>>
>>>> You can just put \columnbreak wherever you like. Pandoc's Markdown
>>>> recognises both raw HTML and raw LaTeX and will ignore raw LaTeX when
>>>> generating HTML and vice versa.
>>>>
>>>> /bpj
>>>>
>>>>
>>>> --
>>>> Better --help|less than helpless
>>>>
>>>> Den mån 5 okt. 2020 19:44Joseph Zitt <josep...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>>>>
>>>>> Hi. I'm pretty new to Pandoc, so just figuring things out. (It's weird
>>>>> to realize that I made my living in much of the 90s hacking together
>>>>> scripts to convert markup languages, and now this one tool appears to do it
>>>>> all.)
>>>>>
>>>>> I'm writing a newsletter in Markdown and would also like to generate a
>>>>> more-printable PDF version. I have most of it working, but have hit one
>>>>> problem:
>>>>>
>>>>> There are specific places where I know that I would like to have a
>>>>> \columnbreak (within a multicol environment) in the LaTeX-generated PDF. Is
>>>>> there a straightforward way to put something in the Markdown that, while
>>>>> not visible in the Markdown-generated HTML, becomes the \columnbreak in the
>>>>> LaTeX?
>>>>>
>>>>> --
>>>>> 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/bd8af183-da78-4596-8a75-56d25828b757n%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/pandoc-discuss/bd8af183-da78-4596-8a75-56d25828b757n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> --
>>> 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/bbb6ad3c-0858-44d0-aff9-98c63f1c58f8n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/pandoc-discuss/bbb6ad3c-0858-44d0-aff9-98c63f1c58f8n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> 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/0911d10b-4e31-4d6b-b8e7-67e5ac567ac6n%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/0911d10b-4e31-4d6b-b8e7-67e5ac567ac6n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CADAJKhB74ZCD4%2BfWke31rL%2BBHxTos5%3DM9yaiQaFBDibHKR03Lw%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 11722 bytes --]

      parent reply	other threads:[~2020-10-06 15:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-05 17:43 Joseph Zitt
     [not found] ` <bd8af183-da78-4596-8a75-56d25828b757n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-10-05 17:52   ` BPJ
     [not found]     ` <CADAJKhCTjP-_qJHpQzxOxACP2zCp7tbMF-pRa5SaL=exsmp5Pw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-10-06  7:48       ` Joseph Zitt
     [not found]         ` <bbb6ad3c-0858-44d0-aff9-98c63f1c58f8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-10-06 12:31           ` BPJ
     [not found]             ` <CADAJKhB+KEgLgLxEAYYbi3RhCDQZK5RzQY=YC=Whp9h3_tDCAg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-10-06 12:50               ` Joseph Zitt
     [not found]                 ` <0911d10b-4e31-4d6b-b8e7-67e5ac567ac6n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-10-06 15:14                   ` BPJ [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='CADAJKhB74ZCD4+fWke31rL+BHxTos5=M9yaiQaFBDibHKR03Lw@mail.gmail.com' \
    --to=melroch-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).