From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/27623 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: John MacFarlane Newsgroups: gmane.text.pandoc Subject: Re: Markdown Fenced Div to LaTeX Environment Date: Thu, 28 Jan 2021 09:10:56 -0800 Message-ID: References: <8ba84992-d792-4333-aae0-560147ef79d4n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10914"; mail-complaints-to="usenet@ciao.gmane.io" To: Bernie Roesler , pandoc-discuss Original-X-From: pandoc-discuss+bncBCJZJHG45QDBBLXAZOAAMGQEHUO4PUY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Jan 28 18:11:13 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-pj1-f64.google.com ([209.85.216.64]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l5Ap6-0002gX-Up for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 28 Jan 2021 18:11:12 +0100 Original-Received: by mail-pj1-f64.google.com with SMTP id ep24sf3828432pjb.5 for ; Thu, 28 Jan 2021 09:11:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1611853871; cv=pass; d=google.com; s=arc-20160816; b=aEZcvJg3qCCXyR4zBsOKmFAdlYnlPgg5afsKrqz1znBRIidIoJ15qW1TjjNk3T3wvj 6kqR/VWkMxzk8v8y4/FZaponjvII+saJWTp48qRPnSt8N5aFlOyYY9vbRxPk15ajBXcx 41dZA10A5s577SxloMAzTsfZyHMH3fJ/7cukCM6GESL5cXcuZ9qMMTSc2oybvB5oCOhI cVYO4vIc94Gy6/TJNXF3rVUvgB/OyM5jYgmQVoVJOaEmZUqjWBdJlOfwp+l4bs6V6fh3 QV+YuV5N9Ua+U7FNgz7+JDXIw/mZ3iUfTqSd7RVPVHmf5POUgquobpulA7ElRI/fVT99 5xnw== 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:mime-version:message-id :date:references:in-reply-to:subject:to:from:sender:dkim-signature; bh=1H2WyVuEJAJHgSYDlZC5eh/H/McQrLyFriDOwNf5XuU=; b=OtJk38EmqsjgSY/kiw7amoZ1NQ8O4bA/dlwY8MB1sZrlg4zf2OCwSiNOjiTCVc+ldC KfBgqtIfP71rE9SrO1nHCTL94JHKlv5IsqH9aWtRPppQ7W73WtqR6xq3br9prDpdZkr8 uFyaMyNvbkyADCKsxGYnkXv5LwyN5RImG6qbUxUgxRbZPvCHGAIouMaHfhlXHd/rOORp XGzuR/XsrG5w9axW72l+MYlA0wuCSSc+1NTVMMVWNdDVu90IDDSFtLrfB7ANWi4tutqB pUNcR2xGe1jL8kyZ+tiLAPcVN+qSt8SJ4Y149vv3V8thBOT9NdhQvGzggUnU3h2XOxNJ 4KAQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=voSZWkx3; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::62b as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:subject:in-reply-to:references:date:message-id :mime-version: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=1H2WyVuEJAJHgSYDlZC5eh/H/McQrLyFriDOwNf5XuU=; b=KjqImWbN46fwIWrS8oNjmwAHehYAxBh+3UYs4AwGEn1xEHJgLxdBjDgP+J/0fZ14Z9 eV8EU/waH2iJ7VtWGzuydU2k2kJNf0+kdmhywIarS+tXu38Fim3faK2c97bU3W9CGyro gF+vm51aja9N8ccZdr5y5QxIn0aQ0J7M8t+sp9sD7jVLgmIfabS/LjoFns79WJdjBagy Z5NlUTT1S8wS9D82E5maPxrlLdZsBsXilTKfUAVA8OB0EzpInwMsdyKfMLxaCwj38F0t nyoT2YTVE5QUKhKy4fLnUkzUO8zh5gn+wC0Kmg4Z65Ewvbnnze6I9XvXM3jujWdvAZ// DOxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:subject:in-reply-to:references :date:message-id:mime-version: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=1H2WyVuEJAJHgSYDlZC5eh/H/McQrLyFriDOwNf5XuU=; b=m0KKGriLp/NjOaazVsNPoKTPDMM83WyfUiFmVuV+MCi+tquyPUOmTwSowu8Xwp/PoG AdX/WBC6TJkGE0p3hvffQkb4Qlg/eJDrxWi91I5Tq65UNUG3ZbM4tloN8ibr5YJKKxeB pqw6AAyILuIknAd2XPF+7DcSZbO0nsoHKkpUBq6KrHoJnQd1uOUFBCN8OoyTKEJ7nxv+ viOcWkzDLspcNGuhZsKEEux4InXeBLs/M5pG90bmfK19kYX0sKujlcTNkWzGdrb3fvtL c4SgFPCfDkR5+4n3CKlM7vIAgbv+2nIk+BlRnFFeSLAiiAZNM/Y8lMJxRGO0E0R5pZrY 8q6g== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM531hGdsgemCm3VDcCUSD2vR4pIT9zDvPpRJ/GgW6r9t4fnfqPf2+ 75XbISikL9l0brzHGOcSqdk= X-Google-Smtp-Source: ABdhPJzANwWJ/GhpYDsJtrh3+8vwXC/DQGGX1PjA7SDzkbzYwGFoAsCdB3PWfqcCIQoOJBr3LRr2Xg== X-Received: by 2002:a17:90b:1997:: with SMTP id mv23mr333068pjb.177.1611853871751; Thu, 28 Jan 2021 09:11:11 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a17:902:a416:: with SMTP id p22ls2987099plq.3.gmail; Thu, 28 Jan 2021 09:11:09 -0800 (PST) X-Received: by 2002:a17:902:6843:b029:e0:52c:ad88 with SMTP id f3-20020a1709026843b02900e0052cad88mr328413pln.72.1611853869630; Thu, 28 Jan 2021 09:11:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611853869; cv=none; d=google.com; s=arc-20160816; b=aAl7qafWMOZtKNA5VgR7525O96+Aoouw8w2h6zsYKZtWKdImytg2QvIFedkN07Xp/M Q9NRMKk3FcsLX6OWtBFw0S8NC+P6qLt+YRgOuXth2ALu/zZ+G7cqthYdOJisgpNBO3T9 AC2nlNpPE5c3UtlQZ7sD2w+fMR8zzuUN9DnVn8mMCH2Ca4jAGtkvnspunPwXKWXtNaSL Ys9gpdNgXDIkMsvJQOU5QhUDvkKX6N4gfhZF7E1VClyoHxVnIPpXT6jffxJR8xFTQ5Uo BQT+MjHdm7nFr8Q7YLhvf0BmWBCQfv7zpmqxrLFWKdN2Ho/2By7JIA28e7aBNt0YlaA5 JgoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :dkim-signature; bh=7aaoPQXWqZIdCTBhXxRc5rMJ/2J8VTeUAZ3K6tt0fWY=; b=N6y0KNJ9Eua7Y112r9pi98ohpnOmeuUVJe5p1s0tqJrOYDWZNhPt1VnjP7pCaQQhZ6 JtxPTEPcbpQV1y3Ie2gK5fQ7GWt+1F39ZXOIOWN82+t7dXRl5oBGUxXqlZztNFPl7E03 d4m28JNBKDAGNXbQH4oKadSCzwAMVZRIH8yvgUXo2Al5gymCXWlfEJjYgLCRTKhqjDqa 9RBM/a0N3cUmp2zxKhoe7raJpp7UEKDH24jaXU5rHHTho+J+Poc94K1iSPR5klT0oqpD 65x80KPHfi/fW4chdz8Jl7Suo877+dDuR7WUpG4S02+4dZSA6KS0fnES+AIhhZF26k8E dOkw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=voSZWkx3; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::62b as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org Original-Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com. [2607:f8b0:4864:20::62b]) by gmr-mx.google.com with ESMTPS id f20si233032plj.3.2021.01.28.09.11.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Jan 2021 09:11:09 -0800 (PST) Received-SPF: pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::62b as permitted sender) client-ip=2607:f8b0:4864:20::62b; Original-Received: by mail-pl1-x62b.google.com with SMTP id 31so3679691plb.10 for ; Thu, 28 Jan 2021 09:11:09 -0800 (PST) X-Received: by 2002:a17:902:6b01:b029:da:d295:2582 with SMTP id o1-20020a1709026b01b02900dad2952582mr321376plk.14.1611853869068; Thu, 28 Jan 2021 09:11:09 -0800 (PST) Original-Received: from johnmacfarlane.net (li55-134.members.linode.com. [74.82.3.134]) by smtp.gmail.com with ESMTPSA id 145sm6212814pfu.8.2021.01.28.09.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 09:11:08 -0800 (PST) Original-Received: by johnmacfarlane.net (Postfix, from userid 1000) id 41E05A268; Thu, 28 Jan 2021 12:10:57 -0500 (EST) In-Reply-To: X-Original-Sender: jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=voSZWkx3; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::62b as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@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:27623 Archived-At: Pandoc's latex 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:

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

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 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 blocks with algorithm environments and convert them to some form that works in your Jekyll blog. You might also try 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 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. For the newlines, you could add a filter that intercepts SoftBreak. Bernie Roesler 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 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$} > \State $x \gets x^2$ > \State \Return $x$ > \EndProcedure > \end{algorithm} > > Currently the output is: > > $x > 0$. $x \gets x^2$ $x$ > > I'd like to have to something like: > >
> $x > 0$ > SquareX($x$) > $x \gets x^2$ > $x$ > >
> > or something to that effect to allow formatting of the individual elements. > > See also my StackOverflow question > > and Jekyll Talk discussion > > . > > I can do my own wrangling and add a verbatim environment before running it > through pandoc and then parse that chunk of the markdown file afterwards, > but I was curious if there was a more elegant solution to dealing with > unknown environments. > > Thanks, > Bernie > > On Sunday, January 24, 2021 at 2:51:02 PM UTC-5 chris....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > >> Thanks! Exactly what i needed to know. >> >> -Chris >> >> On Sun, Jan 24, 2021, 11:58 AM John MacFarlane wrote: >> >>> >>> You 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] == 'solution' then >>> return { latex('\begin{solution}'), el.content, >>> latex('\end{solution}') } >>> end >>> end >>> >>> Chris Diaz writes: >>> >>> > Hello, >>> > >>> > I'm looking for advice on how to produce HTML and LaTeX from Markdown >>> using >>> > 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 order to produce this when HTML is the output (already works): >>> > >>> >
>>> > Solution text here. >>> >
>>> > >>> > and this when LaTeX/PDF is the output: >>> > >>> > \begin{solution} >>> > Solution text here. >>> > \end{solution} >>> > >>> > This idea comes from Bookdown's >>> > Custom Blocks >>> > feature, but I'm wondering 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...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> > To view this discussion on the web visit >>> https://groups.google.com/d/msgid/pandoc-discuss/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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/e6363602-852a-45a1-a199-81553da1966bn%40googlegroups.com.