From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/27628 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:52:43 -0500 Message-ID: References: <8ba84992-d792-4333-aae0-560147ef79d4n@googlegroups.com> <0F730DD9-8029-462F-A65E-AD3E618118E4@gmail.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=_76F5C349-5A92-43FE-ABBA-504CE5CB8E0F" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37447"; mail-complaints-to="usenet@ciao.gmane.io" Cc: pandoc-discuss To: John MacFarlane Original-X-From: pandoc-discuss+bncBDDZVXW5TUDRBD5MZSAAMGQE7HOQ7LA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Jan 28 20:52:50 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-ua1-f59.google.com ([209.85.222.59]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l5DLV-0009aU-DG for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 28 Jan 2021 20:52:49 +0100 Original-Received: by mail-ua1-f59.google.com with SMTP id u32sf1763734uau.21 for ; Thu, 28 Jan 2021 11:52:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1611863568; cv=pass; d=google.com; s=arc-20160816; b=SwdSb/5DnxhfCI1f0LtuQQJNDCZcyV9gO8audBrCK48e8d63aqYCJSenShsi4jkWnn nRhS7X3hbuDI1nSxNdgAeQ7hKTNhZtsOTQ8TUWknz3a0aksvZjTminmdM7kT1umg89Ui MUi3Vj6uE+UcZJAs4Q41A0hMZX72Yiz8cqy7VsCX/U3W0Q5eF9NWkOy9udH74Gw4Tb1j U5MLiGsB5Ems4EkAX8Ok70OZrKNTnjL00A1qqmmnBY0bsZPpfWypTn9BAFrjD3ed2hXQ n/FVQoFj/Cj6bvrv/EiZCT0xE0eFP3zG3OwYsZ72QiyyhLazkqVcOvFNJe1x1UOhe2zj phwQ== 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=RmbN26xVdkFO6ogvmzXX9cH6wn3fmbGP0yz9T/YCMbI=; b=iI/wXbVB3Sc4vdkZ8h9pCbEZC9flS1cHkX8EBCu2YL7Ja594v1/iMnaEKL9+6d6ysv G3JPESMEKqjQFv3NIwc9udMjADB5b5iwAqAwHQ6EPeiZN0ffeaPUsPFoPv+QdAx+Zb/6 xK0I+EVSWqjZY1fBR8LjAVuyEDtgnHN+k9PIQC21CGb6S6SymXTcfVKCeOBSb8TY6BX2 H7TaTxIDCkAOZAsjGk8v+vNGKnuq0YNIxVIi9eJ4bz4jLTOrh3viAXYJHWnJixQKz5/C eXDwgfNDJgPwMK44UfkqvMJfV/h55E6lk4K5uzZx4Hr7cLVMbjunV0MuEvCussNtQ+XS IlzQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=omEmyHpc; spf=pass (google.com: domain of bernard.roesler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::82b 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=RmbN26xVdkFO6ogvmzXX9cH6wn3fmbGP0yz9T/YCMbI=; b=f07Pcp6O/YMx4SuKNKUQsOh38xLYoHsahTFjbA2p/eFM3P5KC9z6yLMVoGYpDQlm8g Ezh5KyvAko+t56HdXc1O0tpZYvExdihEqjLG4kc1oYGdq2B/qfHA30b3XTC48/iI3RaA RU0rGibIbS2qbjM2gH0AiIuoIrgS7idRudMx9Cmcw2xxTUDhsM5U2X8IrRr6j+zcu2Fl zTVOPARv8/MPI91rUJXPamMh7NuP4roVTGZJQP8sI+lfB4QzJqOgixCCghhM93PtUhOW loc8i5zc7WhezO2+hNZlUe05IfUMEou0hq32KN48nDy9Ejd469O8bg7YQ0o39V41Irpi VXRA== 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=RmbN26xVdkFO6ogvmzXX9cH6wn3fmbGP0yz9T/YCMbI=; b=XDyTdC7d+RMFhFc0LgdilFuizF5r0mV40N02KNRo0H50LR/+sAOpVXTtmqpmsFgP8V kzQBImmCNEvP7odSgpnvwvLl4tdYqEeYmqAHKURKup+26219ZRMjY7yQXCiu5C9WffUr UGH2LY9dY26h0iE4kNmLrYWyrXoOYrp6za/Hgdcqj7B8hcv7hWQ4hw82E8fPuyOYXBq6 f/TTDIw+7k0oYSOfdFFeLL9HxJNxiduH1sLxYgSl2aB3/5SwWzFoPXVpjxwMwCjOSpDx fohSzP5fP+KA/1nSiXJEvlgCh9QoSC96g2foT+hNvVWKtriBbAQwsjGCNCXGeGqR/Ww9 eIGQ== 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=RmbN26xVdkFO6ogvmzXX9cH6wn3fmbGP0yz9T/YCMbI=; b=g5SHzBjfZ1RHnLgroWbgMri3+WLdxrLerELnZenRJKVZerPl0Duo3ftuyMtTX/rI/g KA6mrhIEBnK0cG+3ePfs88fuhN4oOzbM5xlre3T6Vh7fGK6IRrcwhBclOq/hTyNUL92t 7ahBDhRcksXRMS+i9Yc6fG2mo9T+kDhOq+vruE9qldCj8ZK8t/KMk0X5oFF4zitqiv/A subXabavrEN99c8jCSwzO2cGc5y0ygpbaB+ODhq04IEESGIOoT4sGJjZ019rXUqJFC9U FdO/DrZYAbMC7iUw3unolFY2Ah+5KyF0NDz81P52OczATNsnoODgt+d5KSOG70B5fF6O jw7w== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM530Sq7+i+Zsd3MYoJRT03Nlhxh/TSiBycRpTVQ/4ciPRMGo1/p2R LOYqFh3yRjS1c30KYfBIkGA= X-Google-Smtp-Source: ABdhPJyzsFaaeobsjflRyJZ/Cg0A2g0Yh8ZvC9JYdqAo8k+5wTriw/AznbklL/LJzyg2oTsZuPtWmg== X-Received: by 2002:ab0:2451:: with SMTP id g17mr792134uan.104.1611863568409; Thu, 28 Jan 2021 11:52:48 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a67:fb19:: with SMTP id d25ls856700vsr.11.gmail; Thu, 28 Jan 2021 11:52:46 -0800 (PST) X-Received: by 2002:a67:d087:: with SMTP id s7mr820475vsi.27.1611863566686; Thu, 28 Jan 2021 11:52:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611863566; cv=none; d=google.com; s=arc-20160816; b=FxcSmSLCWanbKKFWIoZYYz/lJEc2RH/tdttwX2NcxX7LKY2l8KDCqkbtou4mQ2eb96 08WPjgP4XmXaHElKmvPrO71hql5qyO7jQ6+7MTGqFw6Oj+qo0elHKlEs79dRgsy9ecgw 3MYCm5VvqkKtUem9rDEYCin3P37gVtu7CaFg8bDr0fcRVbfWUpr3gxGoLaCToI1vpgXQ Fn94cQHvk4CJf99HAzyOnFV1nE6fYeXOjPvoBfUWmA89NHTjxf1DcOH9dqm+4R2LJ2kf /G8bmjxPXticQ8jGeLraOXARQPPXAR65AduSnXvqgv2wbjLF0yLlS2epLNh8jyI1Uhps exYA== 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=abkCORkWXsJxuJvgDFbcasXQef/6gpTDlnEPI8sCEgI=; b=eX4mKZEaAlms5Q/q5pyPU+JvkNoCU2E6p34VNFeT19WnfJnIDwFIo35BYkeyMXQZ// PtL13VZWv6kCE5yzxcjwJayJypVCM+XBtY0I07ev1E8FlmWEWSlGBDJNHS7cUCwTe1QK O+My3LQ0FZb22we0teLDSVNuRDRVxG+8ZepSA1GNEMyC3RA0bKFgybpxDAzeuIJBIGv0 k249GWlC5JCE2G+8OBbgej9GjcF5kuJfGHJ7B2u4xIn5B/yEvj2oUzhLJ7B0L2+cgsol vLCUJZnNdzNkEchLEeqiOig3OLaX+bIfIbHV61bxbXap69CumlM3/BZ+XlyRKbRxkp/J wfdQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=omEmyHpc; spf=pass (google.com: domain of bernard.roesler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::82b 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-qt1-x82b.google.com (mail-qt1-x82b.google.com. [2607:f8b0:4864:20::82b]) by gmr-mx.google.com with ESMTPS id l11si412886vkr.5.2021.01.28.11.52.46 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Jan 2021 11:52:46 -0800 (PST) Received-SPF: pass (google.com: domain of bernard.roesler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::82b as permitted sender) client-ip=2607:f8b0:4864:20::82b; Original-Received: by mail-qt1-x82b.google.com with SMTP id t14so5001246qto.8 for ; Thu, 28 Jan 2021 11:52:46 -0800 (PST) X-Received: by 2002:ac8:383a:: with SMTP id q55mr1083114qtb.273.1611863566240; Thu, 28 Jan 2021 11:52:46 -0800 (PST) Original-Received: from [192.168.7.141] ([71.233.204.254]) by smtp.gmail.com with ESMTPSA id c20sm3942511qtj.29.2021.01.28.11.52.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jan 2021 11:52:45 -0800 (PST) In-Reply-To: <0F730DD9-8029-462F-A65E-AD3E618118E4-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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=omEmyHpc; spf=pass (google.com: domain of bernard.roesler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::82b 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:27628 Archived-At: --Apple-Mail=_76F5C349-5A92-43FE-ABBA-504CE5CB8E0F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Edit: Reference for algorithm environments . > On Jan 28, 2021, at 14:24, Bernie Roesler wro= te: >=20 > Ah, excellent. The additional div makes a big difference in processing. >=20 > I realized I over-simplified my example. It's actually: >=20 > \begin{algorithm} > \caption{...} > \label{alg:my_alg} > \begin{algorithmic} > ...statements... > \end{algorithmic} > \end{algorithm} >=20 > "algorithm" is just a float like "figure" or "table", and "algorithmic" a= ctually defines the commands "\Require", etc. pandoc now makes divs for bot= h algorithm and algorithmic, but still loses the commands, as you've mentio= ned. >=20 > I've just been using a bash/sed script to pre-process the latex document = before processing with pandoc which seems to work well for now. >=20 > Thanks for the update! >=20 > -Bernie >=20 >=20 > ------------------ > 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 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 purpos= e. >=20 >=20 >> 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 = of=20 >>> the algorithm/algorithmic environments, and does not put the contents i= n 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 eleme= nts. >>>=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 afterward= s,=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 Markdow= n=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, = or=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, se= nd=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-a= ae0-560147ef79d4n%40googlegroups.com >>>>> . >>>>>=20 >>>>=20 >>>=20 >>> --=20 >>> 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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org . >>> To view this discussion on the web visit https://groups.google.com/d/ms= gid/pandoc-discuss/e6363602-852a-45a1-a199-81553da1966bn%40googlegroups.com= . >=20 --=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/B9CE6F77-90D4-4B5A-8EA7-953A11DAFD36%40gmail.com. --Apple-Mail=_76F5C349-5A92-43FE-ABBA-504CE5CB8E0F Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="UTF-8" Edit: Reference for&nbs= p;algorithm e= nvironments.


On Jan 28, 2021, at 14:24, Ber= nie Roesler <ber= nard.roesler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

Ah, exce= llent. 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 "fig= ure" or "table", and "algorithmic" actually defines the commands "\Require"= , etc. pandoc now makes divs for both algorithm and algorithmic, but still = loses the commands, as you've mentioned.

I've just been using a bash/sed script to pre-proce= ss the latex document before processing with pandoc which seems to work wel= l for now.

Thanks= for the update!

= -Bernie


------------------
for ref= erence, I'm now using:
------------------
$ pandoc --version
pandoc 2.1= 1.4
Compiled with pandoc-types 1.22, texmath 0.12.1, s= kylighting 0.10.2,
citeproc 0.3.0.5, ipynb 0.1.0.1
User data directory: /Users/bernardroesler/.local/share/p= andoc or /Users/bernardroesler/.pandoc
Copyright (C) 2= 006-2021 John MacFarlane. Web:  https://pandoc.org
This is free software; se= e the source for copying conditions. There is no
warra= nty, not even for merchantability or fitness for a particular purpose.


On Jan 28, 2021, at 12:10, J= ohn MacFarlane <jgm@berke= ley.edu> wrote:


Pandoc's latex reader doesn't know about the algorithm
environment. What package de= fines it?

With the latest pandoc release, we get this outpu= t 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 brea= ks and we lose \Require, etc.
=
If you want to handle this pr= operly, one option would be to use
pandoc -f latex+raw_tex --lua-filter handle_algorithm.lua

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

You might also try this approach:

Add macro de= finitions to your latex:

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

and so on for \State and \Procedure.

Then pandoc will parse them and you'll get better output. That
gets you almost all the way there,= except for the newlines and
<= span style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size:= 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; = letter-spacing: normal; text-align: start; text-indent: 0px; text-transform= : none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: = 0px; text-decoration: none; float: none; display: inline !important;" class= =3D"">whitespace, if they're significant in this environment.


For the newlines, you could add a filter that intercepts

SoftBreak.



Bernie R= oesler <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 f= or posting to a Jekyll blog, but pandoc parses out much of 
the algorithm/algorithmic = environments, and does not put the contents in a 
div like it does for theorems/proofs= .

With the input:

\begin{algorithm}
   \Require $x > 0$.
   \Procedure{SquareX}{$x$}
 &= nbsp;   \State $x \gets x^2$
   = ;  \State \Return $x$
   \EndProcedu= re
\end{algorithm}

Currently the= output is:

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

I'd like to have to something like:
=
<div class=3D"algorithm">
  &n= bsp;<span class=3D"Require">$x > 0$</span>
&nb= sp;  <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 something to that effect to allow formatting of the indi= vidual elements.

See also my StackOverflow que= stion 
<= https://stackoverflow.com/questi= ons/65930404/pandoc-latex-to-markdown-do-not-parse-environment>
and Jekyll Talk discussion&= nbsp;
<h= ttps://talk.jekyllrb.com/t/kramdown-latex-usepackage-algorithm-pseudocode/2= 861/7?u=3Dbroesler>
.

I c= an do my own wrangling and add a verbatim environment before running it 
through pando= c and then parse that chunk of the markdown file afterwards, 
but I was curious if the= re was a more elegant solution to dealing with 
unknown environments.
Thanks,
Bernie

On S= unday, January 24, 2021 at 2:51:02 PM UTC-5 chris....@gmail.com&nbs= p;wrote:

Thanks! Exactly what i needed to know. 

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


Yo= u need a filter, but it would be a simple one.

Something like

function latex(s)
 return pandoc.RawBlock('latex', s) 
end

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

Chris Diaz <chris....@gmail.com> writes:

Hello,

I'm looking for advic= e on how to produce HTML and LaTeX from Markdown 
using 
fenced divs (or something else) to apply custom styles to specifi= c 
portions 
of the document. 

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

::= : solution
Solution text here.
:::

in order to produce this when HTML is the output (already = works):

<div class=3D"solution">
Solution text here.
</div>

and this when LaTeX/PDF is the output:

\begin{solution}
Solution text here.
\end{solu= tion}

This idea comes from Bookdown's 
<https://boo= kdown.org/yihui/bookdown/custom-blocks.html> Custom Blocks 
feature, but I'm wo= ndering if there's a way to do this with Pandoc, or 
if 
this would require a Lua filter. 

Thanks,
Chris=

-- = ;
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/8ba84992-d792-4333-aae0-560147ef79d4n%40googlegroups.= com
.



--&= nbsp;
You received this message because you are subscr= ibed to the Google Groups "pandoc-discuss" group.
To unsubscr= ibe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe@go= oglegroups.com.
To view this discussion on the web visit<= span class=3D"Apple-converted-space"> https://groups.google.com/d/msgid/pandoc-discu= ss/e6363602-852a-45a1-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/B9CE6F77-90D4-4B5A-8EA7-953A11DAFD36%40gmail.com.
--Apple-Mail=_76F5C349-5A92-43FE-ABBA-504CE5CB8E0F--