From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/27627 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Bernie Roesler Newsgroups: gmane.text.pandoc Subject: Re: Markdown Fenced Div to LaTeX Environment Date: Thu, 28 Jan 2021 14:24:32 -0500 Message-ID: <0F730DD9-8029-462F-A65E-AD3E618118E4@gmail.com> References: <8ba84992-d792-4333-aae0-560147ef79d4n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.40.0.2.32\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_33885277-93D1-431B-817E-030243649072" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30558"; mail-complaints-to="usenet@ciao.gmane.io" Cc: pandoc-discuss To: John MacFarlane Original-X-From: pandoc-discuss+bncBDDZVXW5TUDRB446ZSAAMGQE4YRKXDY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Jan 28 20:24:39 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-qv1-f56.google.com ([209.85.219.56]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l5CuE-0007qO-Ht for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 28 Jan 2021 20:24:38 +0100 Original-Received: by mail-qv1-f56.google.com with SMTP id q37sf3897754qvf.14 for ; Thu, 28 Jan 2021 11:24:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1611861877; cv=pass; d=google.com; s=arc-20160816; b=gHy1G8UiQ4d8nv1Qy9/L/7gSWDh7zeyoG8NI1DAt1JJ9sr5UxtbHcdImB2i8FJQ15L 1rgmHn94KMaDt86dfrQod34NreyVBRZ5ubIoSw8OUn6qtb+Vz9q086/NgpryeG2KW1yy RhsGh7DA7pRaBNQTGesA8NAg1po0hoc6VbcD/IX6HXvJTCO2+NFofhhe9DFMqjl8IPx9 nbmCltD3JQmyIh8q88IrxCgvNIJmOIeBwCx9fqtEo+LDzpob4NS6+6XO+1MH9yGEcq5F g2HwH8/sdgJK8pXTINVVy/vTCcYC8w+mVZ4EXNTwbKa9Z/gnYX0fZI6aDGzUJmoiRMLW ti6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:references:to:cc :in-reply-to:date:subject:mime-version:message-id:from:sender :dkim-signature:dkim-signature; bh=4id4t1z0jvN9TDlmG5DXGOGyv2fMMwV1CJSX0UqWhls=; b=kJAr+Tz61+d/nPrpCpymdnDHbRcDzmCGy9kOCakuUMwonbGyvds2kqh9RbiijSo/mj yo76hPN4FYJtlySkO5JO5rDU/kR1xQROCCPPeRjRh8tnD9z9bU6LdgnRV5uxUhAVT8TD kwK2Yn29GaMVBAgijapEpD2PZghstyNCkDCOrJkZfwL0flfOSgUtHVlw+u0KjGKUGORf nHMafNj5180UOQGuEMhZOswwTHZvffcRrXMTQB6/0KHfw8PgZ8XX5NU5ifLjUd0cjP6C 1TYH79rqcdRQAfylYNaPpA7+ci17lkdjURRLma8NG5iEJ/uoVu7qF0Zyiwpbiuxu4s9T Zp8w== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a0lS4DUj; spf=pass (google.com: domain of bernard.roesler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::f2f as permitted sender) smtp.mailfrom=bernard.roesler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:message-id:mime-version:subject:date:in-reply-to:cc:to :references:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=4id4t1z0jvN9TDlmG5DXGOGyv2fMMwV1CJSX0UqWhls=; b=pTvKHK73eA9epB/7yd/cn21JOPnl1r8zhK9DD7F7hhb81gBGXsUDIU16jl9rZWFpPi i7qX6FQpHIr05kUP4YAXzfI1ntDTQyqyXRnwqqTLwhFeBoo5YOzJ6O0ZMK0eCBAZHnYC yRkMpvA3dhHzs8M2ovQjQkrnjFvoI7wPtNGg4d4QYXoKVkjcagc8aLBHOHBf1s5d9ROa il+URXNZxU2v3Y+4TVItNfvINKAIJW5HlVNBdLq3kxDtzTB1sbojAaRKjNLdF91nWePC Lj6yopbh9EwY/KJ4JlFiMB/bHf50pke2EAKa2GkQ2ZxkVxj4e20NX9HHGGX8QDGgVOx+ wwow== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=4id4t1z0jvN9TDlmG5DXGOGyv2fMMwV1CJSX0UqWhls=; b=tgvo6HAf7SFFo686pCL1JzQYsKxZiRx7m/AuD8bRgygNkMY8pXsHHs/PrYvTm11pZy I2ltN55ejyjigVeYpYO+VaMtKA0PvDzXwmBAoFKCp1qk5OXSSUIlY2HUXNf220F76qam +lvx+pfmzndJt+2n2h7TkvL5me6FCmn0MYEfWxs68Q/JiIzR/oigGrPPPSbYzadPzZwK UjhOzy4wz5gMuPWdjuPCH1fEgvi6o8ytm6Voceq+yrArwhCcsCfJXY2GJBd6fbwrrWgn st0wYef+9aXaD0mlNBXZs0LqkN450T54aGqpTRnYhVpjDyhlQ8H8myquiO5kur7Xwbb+ Owyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=4id4t1z0jvN9TDlmG5DXGOGyv2fMMwV1CJSX0UqWhls=; b=cO1Ab+FhiBtcoEYy6WgVy1PgLKaMbrQRNajH6g3pUX5XvhYvikOYUyN+KBbn6hdMNC t+7iocHHmS0ekAWOlWkhSHduFxubwEzcybqjkDe0sieTK8lDJ6QFae6e7DKEtnFpzDf9 jabq1oOlocLx/K+EtRU89XSAKXzkGF4H7SwjEGuxZFpiwcZ42ZcOTt6GEgGdJNRIYWBx T8DWbMP2+BSB1eAQs2d07sKcQEJGkni7dhmkpMuOkC5vHy6j6zRXcjnoBJNq/ZT6yi6d /z3pW9IW+5O3HV0XGH0UaLTdr0lhkLZy45vAd0DGjw4bBEkQgywl2SMP4Dw8aRigDaPG Dz/g== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM531SfZCZxXA2G9m7+G40l5KPynRbvEcO6qApnuP4uVYon3NanEIE RFly2rk7tzw2c8fqh4NhG18= X-Google-Smtp-Source: ABdhPJw6jYrvDgB9ikIoG7QntpDaPd+bc7LjuZqb5Jo0NPCIeDQSIS7nKMTrrBjdCHpWbMYyizXphg== X-Received: by 2002:a05:622a:2d6:: with SMTP id a22mr1026415qtx.111.1611861877613; Thu, 28 Jan 2021 11:24:37 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a0c:e60c:: with SMTP id z12ls1673228qvm.0.gmail; Thu, 28 Jan 2021 11:24:35 -0800 (PST) X-Received: by 2002:ad4:40c6:: with SMTP id x6mr836504qvp.10.1611861875552; Thu, 28 Jan 2021 11:24:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611861875; cv=none; d=google.com; s=arc-20160816; b=frZQWSGprpTy6AbPKopC1XspBE5yOYhssa6P6uezUGNxw9KMkRIGFtcZ75MR8Pi9ir Wm2rmFEs33/e2UV+h5yJNjN9XIYbST44lcp3O+w8aWHmtGp596isYBqEw625K1gn/m6F hrduNGMcDqc/w9BKX2sWJd4iKgH9+NDHxYCoSCjnaMogLfOck68HWzHQkAHCbRMgGCYd OP82/qccfQi6rWJhf3BD5N4utH/J6V6KYRulZKUHlTmWyFKiNYGJATK0aDcUhFYdeKUg pkMYlhfYr6Sx26dX7MHuxuQwdJj4ZgKEY9G67PFW8/s0Q3HlUWy7dDXmvBqvopGjc76B udoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:dkim-signature; bh=0uqrtfNEqZiIGBhRnNKna3WHMosEL7OkDVrQzXSFxEg=; b=RXP0N4/mfu4MDBo5LqMhbhdCHsERRIJZW2uPDQw+nAiiAetj9JIh3Ezzw9NafuSkPb tpBKVmTS+qrw40jR0M1MnhD9KifOdo4EmdNlegg77PW/jWB5PQ0hwuMGoikiX84O9EuY ++xadLCpY43Wk1xCuOaq4vmzycfVppVNyN0JfyG86vQWQuqzTDGmYZddNSl29lyLgbrL EDWhWlHOop/SoBrdEHG4fuU2beDNMeDktJCGrEvqpRg2Gm5+lT8rPbruZa6qutX9UwpU oy9jSWFKCinzwYcaaEirGe8IE2bEXjSEA19PK/nIICvja/UHpKIsSVsvyjWdbRenahua agMQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a0lS4DUj; spf=pass (google.com: domain of bernard.roesler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::f2f as permitted sender) smtp.mailfrom=bernard.roesler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com. [2607:f8b0:4864:20::f2f]) by gmr-mx.google.com with ESMTPS id c3si365666qkc.2.2021.01.28.11.24.35 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Jan 2021 11:24:35 -0800 (PST) Received-SPF: pass (google.com: domain of bernard.roesler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::f2f as permitted sender) client-ip=2607:f8b0:4864:20::f2f; Original-Received: by mail-qv1-xf2f.google.com with SMTP id j4so3342035qvk.6 for ; Thu, 28 Jan 2021 11:24:35 -0800 (PST) X-Received: by 2002:a0c:c583:: with SMTP id a3mr866434qvj.15.1611861875130; Thu, 28 Jan 2021 11:24:35 -0800 (PST) Original-Received: from [192.168.7.141] ([71.233.204.254]) by smtp.gmail.com with ESMTPSA id k14sm3882119qtj.40.2021.01.28.11.24.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jan 2021 11:24:34 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3654.40.0.2.32) X-Original-Sender: bernard.roesler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a0lS4DUj; spf=pass (google.com: domain of bernard.roesler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::f2f as permitted sender) smtp.mailfrom=bernard.roesler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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:27627 Archived-At: --Apple-Mail=_33885277-93D1-431B-817E-030243649072 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Ah, excellent. The additional div makes a big difference in processing. I realized I over-simplified my example. It's actually: \begin{algorithm} \caption{...} \label{alg:my_alg} \begin{algorithmic} ...statements... \end{algorithmic} \end{algorithm} "algorithm" is just a float like "figure" or "table", and "algorithmic" act= ually defines the commands "\Require", etc. pandoc now makes divs for both = algorithm and algorithmic, but still loses the commands, as you've mentione= d. I've just been using a bash/sed script to pre-process the latex document be= fore processing with pandoc which seems to work well for now. Thanks for the update! -Bernie ------------------ for reference, I'm now using: ------------------ $ pandoc --version pandoc 2.11.4 Compiled with pandoc-types 1.22, texmath 0.12.1, skylighting 0.10.2, citeproc 0.3.0.5, ipynb 0.1.0.1 User data directory: /Users/bernardroesler/.local/share/pandoc or /Users/be= rnardroesler/.pandoc Copyright (C) 2006-2021 John MacFarlane. Web: https://pandoc.org This is free software; see the source for copying conditions. There is no warranty, not even for merchantability or fitness for a particular purpose. > On Jan 28, 2021, at 12:10, John MacFarlane wrote: >=20 >=20 > Pandoc's latex reader doesn't know about the algorithm > environment. What package defines it? >=20 > With the latest pandoc release, we get this output with > pandoc -f latex -t html --mathjax on your input: >=20 >
>

\(x > 0\). \(x \gets x^2\) \(x\)

>
>=20 > Better, though we lose the line breaks and we lose \Require, etc. >=20 > If you want to handle this properly, one option would be to use > pandoc -f latex+raw_tex --lua-filter handle_algorithm.lua >=20 > You'd have to write handle_algorithm.lua, but what it would do > is find raw latex blocks with algorithm environments and convert > them to some form that works in your Jekyll blog. >=20 > You might also try this approach: >=20 > Add macro definitions to your latex: >=20 > \renewcommand{\Require}{1]{Require #1} >=20 > and so on for \State and \Procedure. >=20 > Then pandoc will parse them and you'll get better output. That > gets you almost all the way there, except for the newlines and > whitespace, if they're significant in this environment. >=20 > For the newlines, you could add a filter that intercepts > SoftBreak. >=20 >=20 >=20 > Bernie Roesler > writes: >=20 >> Hi all, >>=20 >> Is there a *reverse* of this solution? I'm trying to go from LaTeX to=20 >> markdown/html for posting to a Jekyll blog, but pandoc parses out much o= f=20 >> the algorithm/algorithmic environments, and does not put the contents in= a=20 >> div like it does for theorems/proofs. >>=20 >> With the input: >>=20 >> \begin{algorithm} >> \Require $x > 0$. >> \Procedure{SquareX}{$x$} >> \State $x \gets x^2$ >> \State \Return $x$ >> \EndProcedure >> \end{algorithm} >>=20 >> Currently the output is: >>=20 >> $x > 0$. $x \gets x^2$ $x$ >>=20 >> I'd like to have to something like: >>=20 >>
>> $x > 0$ >> SquareX($x$) >> $x \gets x^2$ >> $x$ >> >>
>>=20 >> or something to that effect to allow formatting of the individual elemen= ts. >>=20 >> See also my StackOverflow question=20 >> > >> and Jekyll Talk discussion=20 >> > >> . >>=20 >> I can do my own wrangling and add a verbatim environment before running = it=20 >> through pandoc and then parse that chunk of the markdown file afterwards= ,=20 >> but I was curious if there was a more elegant solution to dealing with= =20 >> unknown environments. >>=20 >> Thanks, >> Bernie >>=20 >> On Sunday, January 24, 2021 at 2:51:02 PM UTC-5 chris....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: >>=20 >>> Thanks! Exactly what i needed to know.=20 >>>=20 >>> -Chris >>>=20 >>> On Sun, Jan 24, 2021, 11:58 AM John MacFarlane > wrote: >>>=20 >>>>=20 >>>> You need a filter, but it would be a simple one. >>>>=20 >>>> Something like >>>>=20 >>>> function latex(s) >>>> return pandoc.RawBlock('latex', s)=20 >>>> end >>>>=20 >>>> function Div(el) >>>> if el.classes[1] =3D=3D 'solution' then >>>> return { latex('\begin{solution}'), el.content,=20 >>>> latex('\end{solution}') } >>>> end >>>> end >>>>=20 >>>> Chris Diaz > writes: >>>>=20 >>>>> Hello, >>>>>=20 >>>>> I'm looking for advice on how to produce HTML and LaTeX from Markdown= =20 >>>> using=20 >>>>> fenced divs (or something else) to apply custom styles to specific=20 >>>> portions=20 >>>>> of the document.=20 >>>>>=20 >>>>> For example, I'm hoping to write something like this: >>>>>=20 >>>>> ::: solution >>>>> Solution text here. >>>>> ::: >>>>>=20 >>>>> in order to produce this when HTML is the output (already works): >>>>>=20 >>>>>
>>>>> Solution text here. >>>>>
>>>>>=20 >>>>> and this when LaTeX/PDF is the output: >>>>>=20 >>>>> \begin{solution} >>>>> Solution text here. >>>>> \end{solution} >>>>>=20 >>>>> This idea comes from Bookdown's=20 >>>>> > Custom Blocks=20 >>>>> feature, but I'm wondering if there's a way to do this with Pandoc, o= r=20 >>>> if=20 >>>>> this would require a Lua filter.=20 >>>>>=20 >>>>> Thanks, >>>>> Chris >>>>>=20 >>>>> --=20 >>>>> You received this message because you are subscribed to the Google=20 >>>> Groups "pandoc-discuss" group. >>>>> To unsubscribe from this group and stop receiving emails from it, sen= d=20 >>>> an email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org . >>>>> To view this discussion on the web visit=20 >>>> https://groups.google.com/d/msgid/pandoc-discuss/8ba84992-d792-4333-aa= e0-560147ef79d4n%40googlegroups.com >>>> . >>>>=20 >>>=20 >>=20 >> --=20 >> You received this message because you are subscribed to the Google Group= s "pandoc-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send a= n email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org . >> To view this discussion on the web visit https://groups.google.com/d/msg= id/pandoc-discuss/e6363602-852a-45a1-a199-81553da1966bn%40googlegroups.com = . --=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 e= mail 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/0F730DD9-8029-462F-A65E-AD3E618118E4%40gmail.com. --Apple-Mail=_33885277-93D1-431B-817E-030243649072 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="UTF-8" Ah, excellent. The addi= tional div makes a big difference in processing.

I realized I over-simplified my example. It's a= ctually:

\begin{a= lgorithm}
\caption{...}
\label{alg:my_alg}
\begin{algorithmic}
...statements...
\end{algorithmi= c}
\end{algorithm}

"algorithm" is just a float like "figure" or "table"= , and "algorithmic" actually defines the commands "\Require", etc. pandoc n= ow makes divs for both algorithm and algorithmic, but still loses the comma= nds, as you've mentioned.

I've just been using a bash/sed script to pre-process the latex do= cument before processing with pandoc which seems to work well for now.

Thanks for the update= !

-Bernie


------------------
for reference, I'm now= using:
------------------
$ pandoc --version
pandoc 2.11.4
Compiled with pandoc-types 1.22, texmath 0.12.1, skylighting 0.10= .2,
citeproc 0.3.0.5, ipynb 0.1.0.1
User data directory: /Users/bernardroesler/.local/share/pandoc or /Users= /bernardroesler/.pandoc
Copyright (C) 2006-2021 John M= acFarlane. Web:  https://pan= doc.org
This is free software; see the source for = copying conditions. There is no
warranty, not even for= merchantability or fitness for a particular purpose.
=

On Jan 28, 2021, at 12:10, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:

Pandoc's la= tex reader doesn't know about the algorithm
environment. What package defines it?

With the latest pandoc release, we get this output with
pandoc -f latex -t html --mathjax on your= input:

<div class=3D"algorithm">
<p><span class=3D"math inline">= ;\(x &gt; 0\)</span>. <span class=3D"math inline">\(x \gets= x^2\)</span> <span class=3D"math inline">\(x\)</span><= ;/p>
</div>

Better, though we lose the line breaks and we lose \Require, = etc.

If you want to handle this properly, one option would = be to use
pandoc -f lat= ex+raw_tex --lua-filter handle_algorithm.lua

You'd have to = write handle_algorithm.lua, but what it would do
is find raw latex blocks with algorithm environme= nts and convert
them to= some form that works in your Jekyll blog.

You might also t= ry this approach:

Add macro definitions to your latex:

\renewcommand{\Require}{1]{Require #1}

and so = on for \State and \Procedure.
=
Then pandoc will parse them a= nd you'll get better output. That
gets you almost all the way there, except for the newlines and=
whitespace, if they're= significant in this environment.

For the newlines, you c= ould add a filter that intercepts
SoftBreak.


Bernie Roesler <bernard.roesler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

Hi all,

Is there a *reverse* of = this solution? I'm trying to go from LaTeX to 
markdown/html for posting to a Jekyll b= log, but pandoc parses out much of&nb= sp;
the algorithm/algorithmic environments, and does n= ot put the contents in a =
div like it does for theorems/proofs.

With the input:

\begin{algorithm}
   \Require $x > 0$.
  &= nbsp;\Procedure{SquareX}{$x$}
     \= State $x \gets x^2$
     \State \Ret= urn $x$
   \EndProcedure
\end{al= gorithm}

Currently the output is:

$x > 0$. $x \gets x^2$ $x$

I'd like to have to something like:

<div c= lass=3D"algorithm">
   <span class=3D"Re= quire">$x > 0$</span>
   <span = class=3D"Procedure">SquareX</span>($x$)
  =  <span class=3D"State">$x \gets x^2$</span>
=    <span class=3D"State" class=3D"Return">$x$</span= >
   <span class=3D"EndProcedure"><= ;/span>
</div>

or somet= hing to that effect to allow formatting of the individual elements.

See also my StackOverflow question 
<https://stackoverflow.com/questions/65930404/pandoc-late= x-to-markdown-do-not-parse-environment>
and Jekyll Tal= k discussion 
<https://talk.jekyllrb.com= /t/kramdown-latex-usepackage-algorithm-pseudocode/2861/7?u=3Dbroesler&g= t;
.

I can do my own wrangling a= nd add a verbatim environment before running it 
through pandoc and then parse that ch= unk of the markdown file afterwards,&= nbsp;
but I was curious if there was a more elegant so= lution to dealing with unknown environments.

Thanks,
Bernie

On Sunday, January 24, 2021 = at 2:51:02 PM UTC-5 chris....@gmai= l.com wrote:

Thanks! Exactly w= hat i needed to know. 
-Chris

On Sun, Jan = 24, 2021, 11:58 AM John MacFarlane <j...@berkeley.edu> wrote:


You need a filter, but it wo= uld be a simple one.

Something like

function latex(s)
 return pandoc.Ra= wBlock('latex', s) 
end

function Div(el)
&n= bsp;if el.classes[1] =3D=3D 'solution' then
   = ;return { latex('\begin{solution}'), el.content, 
latex('\end{solution}') }
 end
end

Chris Diaz &= lt;chris....@gmail.com> wri= tes:

Hell= o,

I'm looking for advice on how to produce HT= ML and LaTeX from Markdown 
using&n= bsp;
fenced divs = (or something else) to apply custom styles to specific 
portions 
of the document.=  

For example, I'm hoping to write= something like this:

::: solution
Solution text here.
:::

in or= der to produce this when HTML is the output (already works):
=
<div class=3D"solution">
Solution text h= ere.
</div>

and this when = LaTeX/PDF is the output:

\begin{solution}
Solution text here.
\end{solution}
This idea comes from Bookdown's 
<https://bookdown.org/yihui/bookdo= wn/custom-blocks.html> Custom Blocks 
feature, but I'm wondering if there's a w= ay to do this with Pandoc, or 
if&n= bsp;
this would r= equire a Lua filter. 

Thanks,
Chris

-- 
You received this message because you are subscribed to the Google 
Grou= ps "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-discu= ss/8ba84992-d792-4333-aae0-560147ef79d4n%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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.=
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/e6363602-852a-45= a1-a199-81553da1966bn%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/p= andoc-discuss/0F730DD9-8029-462F-A65E-AD3E618118E4%40gmail.com.
--Apple-Mail=_33885277-93D1-431B-817E-030243649072--