From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/30654 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.text.pandoc Subject: AW: How to make my latex environment accessible from markdown via short-code? Date: Thu, 2 Jun 2022 08:28:46 +0000 Message-ID: References: <4de0a599-a196-438a-928c-b0895b35afb6n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_cc1c350768424985bb0f5c9380386904unibech_" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12837"; mail-complaints-to="usenet@ciao.gmane.io" To: Original-X-From: pandoc-discuss+bncBCZ27W53TUFBBQPJ4GKAMGQED57F2HI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Jun 02 10:28:54 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-lf1-f55.google.com ([209.85.167.55]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nwgCM-0003Cx-9A for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 02 Jun 2022 10:28:54 +0200 Original-Received: by mail-lf1-f55.google.com with SMTP id w38-20020a0565120b2600b00477b08c1730sf2204055lfu.13 for ; Thu, 02 Jun 2022 01:28:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654158533; cv=pass; d=google.com; s=arc-20160816; b=iLbGcREnPF5YciaLfNkQ3Uh542byHHqsZBWV+l4//xKKMJDLuLDo4asC/U74cXKSIZ pBZv+LcDQYA4AEP8XReo9RwBmDZThvxk5kbTVVLTJGeLQECiwQqrMRK7hqiBbsvBACiW 0LTmF9dDGsuz9EWJpw/dY0koAWGl1jsDh52pd5uZnEPAd0Umb8jqlDLExDlPHHEgKy7C xQ6M7r+78I5sfjA4m1weyrDjChxOcLcBva59zt0yqzAlZ4Em6Tj8Lypr8er0aXR+StsQ PZFjLr+GPi7sX4uQRgPIhVbJW2QaCw3zphV5BBt3ZBraLh90QotbNxLI6JdI648Kldc6 Fm1g== 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 :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:from:sender :dkim-signature; bh=DUoUoI9zJTjQV73dt3v0uGz3ZCpnc+KCpEbO8HnaRNA=; b=PLSV5ECHZsJl7p0FP2WpUFoiC0A/JLVTsXRQHlRXe1+R4X9wVnDA7osTfwATMNQSGK o1YjFYdCZkTUz/YwmWVYV+pt3idiN3XvEz9hwYb+//7a0KUJSTJUv+wnQDTlXK6CJobQ k739huODjypIS6QLEqf0tHy13vuQU3wJcS+J0CVWMabfXqC/IUuo1czf8AO/g6sELtwd o7ELxSaVRhw6N/6kuE6AK5FMBzFQVaiFuEMEO5KhsKo7Txj9yBBf6Cajvzg2HiAKe7yg irMHul3zVKZbR2Kv2824ci8ViizXdZWUV0cMWNj/rrfDAvteuSsDhk2xVajyhs54xgJn k1Vg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.83 as permitted sender) smtp.mailfrom=denis.maier-NSENcxR/0n0@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=unibe.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:subject:thread-topic:thread-index:date:message-id :references:in-reply-to:accept-language:content-language :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=DUoUoI9zJTjQV73dt3v0uGz3ZCpnc+KCpEbO8HnaRNA=; b=HTgf1j9j1s7AJszWVqWhyy1K+s3o5OTIJofTV3mJvwOItGeMx+EPa+mCHrsM4L9wxS rRsismAjab5Jb5rL9mzRwt/llI3XxUxZYhfwxxrNinrRHZ1qiIuJPqiumgCVToXQ/SDv StQ51+SmXlSHaCTIJ0kRIXdfMWeVMXcMDce+H0c2UrSdi9jI6oUl56a9onBd7lcFkTgH o6wjfl5FvvsM6ijN1BJL9HtnexMuI/9wZeR7GESvhtZXILvMxuTNILW90Ft6RDDyQyUh +XJnkR070q38sAXkf2SAjeR0azF52Z6kYk6Dh9ERNfGNWHRgBnrwuYyWJ31HVZaur0oK rbhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:subject:thread-topic:thread-index :date:message-id:references:in-reply-to:accept-language :content-language: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=DUoUoI9zJTjQV73dt3v0uGz3ZCpnc+KCpEbO8HnaRNA=; b=V1bbvs6dE+TfZDeP6+1Fp6B4wUjYllWhbhOgEUzjCtBD/LOwZ5Q4p1wBzKTmBuggpb 6b4RimF2sLkdlEIJrL/761ZBTKPp0OGIqMPMz0Hh6BGwZ1lb+UTKrTDE4VTcRkNph5Jx 3yqqIZyvQkeN4T7YfSPaM0NmCNXWcItyWKVoQmGNTOnJClys995LuNm3ErqFV8j9AmYI hMF4cdMMVywWMDT4DRgzEfvRb/MxYXo+bfz/SWGkDw2/YL+ITf40xgI5D0T/zHg5xrsX /S9HcevlivhEWAXjY5zCw2c6Zg3mbRa Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM531AUC43dPsoa1sAeDIhnTo8TFyL/CodBqEd8rvKzCAMy/ii45iT 1qFD0pPf+PNbCUeUgtG5GQU= X-Google-Smtp-Source: ABdhPJzQOl3LXTiP+qYlq0kzrIGbCkI170swcLyOqIyLAQLIHUa7MrMn93RYp5OZGqspmF3Vgxcn5Q== X-Received: by 2002:a2e:bc05:0:b0:24b:212d:7521 with SMTP id b5-20020a2ebc05000000b0024b212d7521mr39830144ljf.243.1654158533690; Thu, 02 Jun 2022 01:28:53 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6512:10cb:b0:478:7256:822a with SMTP id k11-20020a05651210cb00b004787256822als306395lfg.3.gmail; Thu, 02 Jun 2022 01:28:49 -0700 (PDT) X-Received: by 2002:a05:6512:70b:b0:477:a832:7d07 with SMTP id b11-20020a056512070b00b00477a8327d07mr2707920lfs.71.1654158528931; Thu, 02 Jun 2022 01:28:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654158528; cv=none; d=google.com; s=arc-20160816; b=gCHzdOZTQZDmTKYgjfyyuzha9VH+Bz+OPoJbqCdWaoU27wxNfXVtGbEGbi2XPFnfKa m+Ijbri3JuscsQF2j+npJPlWULITGLtLq9bJDEngB9YPy17qLiEXtbWN06L8itCsFap9 vjOP4irsXcpe9+ed7DqEqap+AacO0pFlHVaICcHA4KkJrED7yC7NBQEphIC9dU1XObkA dIddxFpajVMA+yirlOYu3P7DqRWVReEjQ3FHABZXa/QDHf++Vq18PNZMmJ9TqEyvLpDP tp5lpsz5og2v+d0efsfLrf4WzHCcMixLsMzSO0zEG8sZmE6D899CC/CEQ9W5hnhKZimK 2/4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-language:accept-language:in-reply-to :references:message-id:date:thread-index:thread-topic:subject:to :from; bh=yoMtYuE8VCdVnArp52a9nK16yLR1R/w0ARCRlYpL+X0=; b=YFwkNlnwUlmfKEplKpCwaD8EJ/wCLm2I6ZcPUL7gttEFHSibrg+H8g3LUhSWDeHO/j wJJ90RpylC6JWZ0HVrHRQ2z7Jc0Lv2X4sZs+6XzrJxXAz1Q7UbTxuwsmqrdRWd1ypA3N mkqNj3Zm6SvxdgN79eSkxsTi+uMpmkwdmTmGx6Yeoa1ifXboOZbZp7pQouy/E2MM09A7 YgNZLSiuR+kvtIfINkJjnbsfGeqciwwGRrxY4U/cUjyeDJ1V/5lSPWzfE8eEmv5zDDk7 vr8wqwrVvFBLxKixbN50Eupezg5wKC4mk8Gu+3BoTtSe8JS6vaAZpk5ToOi9Ad5ENpD+ ZyzQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.83 as permitted sender) smtp.mailfrom=denis.maier-NSENcxR/0n0@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=unibe.ch Original-Received: from mailhub-lb2.unibe.ch (mailhub-lb2.unibe.ch. [130.92.0.83]) by gmr-mx.google.com with ESMTPS id o18-20020ac24c52000000b00478f1faa988si198674lfk.13.2022.06.02.01.28.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 01:28:48 -0700 (PDT) Received-SPF: pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.83 as permitted sender) client-ip=130.92.0.83; X-Virus-Scanned: By University of Bern - MGW Original-Received: from mail.campus.unibe.ch (aai-edge-03.campus.unibe.ch [130.92.13.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailhub-lb2.unibe.ch (Postfix) with ESMTPS id 54D87500087 for ; Thu, 2 Jun 2022 10:28:47 +0200 (CEST) Thread-Topic: How to make my latex environment accessible from markdown via short-code? Thread-Index: AQHYdlk/OWfYV7I3oUynfv4PgxHqAa07x2og In-Reply-To: <4de0a599-a196-438a-928c-b0895b35afb6n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Accept-Language: de-CH, en-US Content-Language: de-DE x-originating-ip: [130.92.13.161] X-Original-Sender: denis.maier-NSENcxR/0n0@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.83 as permitted sender) smtp.mailfrom=denis.maier-NSENcxR/0n0@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=unibe.ch 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:30654 Archived-At: --_000_cc1c350768424985bb0f5c9380386904unibech_ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Just use divs for that: ::: hint Whatever ::: Now, you can use a filter like the one below (posted by BPJ at some point). This will check each div whether it has one of the classes defined in ENV_C= LASSES. If yes, it will insert an appropriate raw block. ```lua ENV_CLASSES =3D { 'intro', 'question', 'solution', 'hint', 'definition', 'w= hatever'} local function latex(s) return pandoc.RawBlock('latex', s) end local function get_env_class(elem) if elem.classes then for i =3D 1, #elem.classes do for j =3D 1, #ENV_CLASSES do if elem.classes[i] =3D=3D ENV_CLASSES[j] then return ENV_CLASSES[j] e= nd end end else error('function has_class used on an element of type ' .. elem.t .. ' that cannot have classes.') end end function Div(el) local env_class =3D get_env_class(el) -- nil if there is none if env_class then -- false if env_class is nil return { latex('\\begin{'.. env_class..'}'), el, latex('\\end{'.. env_c= lass..'}') } end end function Span(el) if el.classes[1] =3D=3D 'speaker' then return pandoc.RawInline('latex', '\\speaker{= '..el.content..'}') end end ``` Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Im A= uftrag von Stefan Schroeder Gesendet: Donnerstag, 2. Juni 2022 10:18 An: pandoc-discuss Betreff: How to make my latex environment accessible from markdown via shor= t-code? I am converting markdown to pdf via latex using my own template. In the template I have defined a new environment called 'hint' that is like= a call-out. This works: --- ```{=3Dlatex} \begin{hint} ``` Lorem ipsum dolor sit amet, ```{=3Dlatex} \end{hint} ``` --- The Lorem text appears in the callout-environment. I want to make the environment accessible more conveniently via a short-cod= e. I have created a new lua-filter, 'hint.lua' that I successfully include: return { { Str =3D function (elem) if elem.text =3D=3D "{{hint_end}}" then return pandoc.Str("```{=3Dlatex}\n\\end{guidehint}\n```\n") elseif elem.text =3D=3D "{{hint_begin}}" then return pandoc.Str "```{=3Dlatex}\\begin{guidehint}```" else return elem end end, } } But when I use it, the macro-text will be included literally: {{hint_begin}} Neque porro quisquam est, {{hint_end}} The code is not interpreted to end up being proper Latex, but it's escaped = somehow to become a string literal. Thus my output looks like this: =E2=80=9C=E2=80=98{=3Dlatex}\begin{hint}=E2=80=9C=E2=80=98 Neque porro quis= quam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit =E2=80=9C=E2=80=98{=3Dlatex} \end{hint} =E2=80=9C=E2=80=98 How do I make the short-code to get access to my own environments? PS. If there are different apporaches, that'll be nice as well. Thanks Stefan -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/4de0a599-a196-438a-928c-b0895b35afb6n%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/cc1c350768424985bb0f5c9380386904%40unibe.ch. --_000_cc1c350768424985bb0f5c9380386904unibech_ Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Just use = divs for that:

&nbs= p;

::: hint<= o:p>

Whatever<= o:p>

:::<= /o:p>

&nbs= p;

Now, you can use a filter like the one below (posted by BPJ at some p= oint).

 

This will= check each div whether it has one of the classes defined in ENV_CLASSES. I= f yes, it will insert an appropriate raw block.

&nbs= p;

```lua

ENV_CLASSES =3D { 'intro', 'question', 'solution', 'hint', 'definitio= n', 'whatever'}

 

local function latex(s)

  return pandoc.RawBlock('latex', s)

end

 

local function get_env_class(elem)

if elem.c= lasses then

  fo= r i =3D 1, #elem.classes do

 &nb= sp;  = for j =3D 1, #ENV_CLASSES do

      if elem.classes[i] =3D=3D ENV_CLASSES[= j] then return ENV_CLASSES[j] end

  end

end

else

  error('function has_class used on an element of type ' ..=

        elem.t .. ' that cannot ha= ve classes.') end end

 

function Div(el)

  local env_class =3D get_env_class(el) -- nil if there is none<= o:p>

  if env_class then -- false if env_class is nil

    return { latex('\\begin{'.. env_class..'}'), el, l= atex('\\end{'.. env_class..'}') }

  end

end

 

function Span(el)

           &nb= sp;    if el.classes[1] =3D=3D 'speaker' then

           &nb= sp;            =        return pandoc.RawInline('latex', '\\sp= eaker{'..el.content..'}')

           &nb= sp;    end

end

```

 

 

Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Stefan Schroeder
Gesendet: Donnerstag, 2. Juni 2022 10:18
An: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Betreff: How to make my latex environment accessible from markdown v= ia short-code?

 

I am converting markdown to pdf via latex using my o= wn template.

In the template I have defined a new environment cal= led 'hint' that is like a call-out.

 

This works:

---

```{=3Dlatex}
\begin{hint}
```
Lorem ipsum dolor sit amet,
```{=3Dlatex}
\end{hint}
```

---

The Lorem text appears in the callout-environment.

 

I want to make the environment accessible more conve= niently via a short-code.

 

I have created a new lua-filter, 'hint.lua' that I s= uccessfully include:

return {
  {
    Str =3D function (elem)
      if elem.text =3D=3D "{{hint_end}}" then
        return pandoc.Str("```{=3Dlatex}\n\\end{gu= idehint}\n```\n")
      elseif elem.text =3D=3D "{{hint_begin}}" the= n
        return pandoc.Str "```{=3Dlatex}\\begin{gu= idehint}```"
      else
        return elem
      end
    end,
  }
}

 

But when I use it, the macro-text will be included l= iterally:

 

{{hint_begin}}
Neque porro quisquam est,
{{hint_end}}

 

The code is not interpreted to end up being proper L= atex, but it's escaped somehow to become a string literal.

Thus my output looks like this:

 

=E2=80=9C=E2=80=98{=3Dlatex}\begin{hint}=E2=80=9C=E2= =80=98 Neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, c= onsectetur,
adipisci velit =E2=80=9C=E2=80=98{=3Dlatex} \end{hint} =E2=80=9C=E2=80=98

 

How do I make the short-code to get access to my own= environments?

 

PS. If there are different apporaches, that'll be ni= ce as well.

 

Thanks

Stefan

 

--
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 pandoc-d= iscuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/4de0a599-a196-438a-928c-b0= 895b35afb6n%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/pandoc= -discuss/cc1c350768424985bb0f5c9380386904%40unibe.ch.
--_000_cc1c350768424985bb0f5c9380386904unibech_--