From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32218 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Julien Dutant Newsgroups: gmane.text.pandoc Subject: Re: Can math elements have attributes Date: Wed, 22 Feb 2023 08:33:36 -0800 (PST) Message-ID: <0845b275-aa43-4fc3-86a5-17b20de652een@googlegroups.com> References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_6748_1138358186.1677083616193" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31490"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBC5Y3356IYIODB6ZT4DBUBHNUH5RO-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Feb 22 17:33:41 2023 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 1pUs3o-0007yL-Pe for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 22 Feb 2023 17:33:40 +0100 Original-Received: by mail-qv1-f56.google.com with SMTP id ks21-20020a056214311500b0056bec2871e8sf3883151qvb.1 for ; Wed, 22 Feb 2023 08:33:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=N2UVOMG7LJi0CenTMjxhqCdN48/ky4dJ47RoVQJwGoc=; b=NJlc3vQ3y0lIoeCvHjDDcH9YGFw07vQ+D38pIijHucwJtiSVvGMef0621YQNQh9kEq v5s5dsjvrvriPnHi3/1h5uneucWiP6plaSpQvJhdlfUzLTd0/7eb5kSbiVMOUkGyTFI9 Zb95NZFgC7oicclEfP+6HC5QoxpUKtttYn0Yrvld8xrzDwKLQbZdVhKFgSq8qT3pAydZ l9pCrEyhofKBs0/0bJCexe5mzzH7BL//kOLLIgb5NO1+7UJW6s6UMqxx9wYNMKP/3Azr NT3wFW47z1ddyBr7Lse6OgUcDvu4MhVTh2RI2QBzqMpR0lYc892kqpP+qAVupe+FvFEi sHxw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=N2UVOMG7LJi0CenTMjxhqCdN48/ky4dJ47RoVQJwGoc=; b=EXjxK9xjvmGBZ5Ww0JGz+fouFyO83G7WATvfzAeCkRAZO1LzHBEzWw7GlddOWVRCon YTx/uxI3rfjAzuZFdN0eLW3BVVoegwDrSwDAOuJ8DeVUyKO0V20KDhnKtJhvFjcdS+LQ 7TcIlqqYmzCschHc4/nNJjva/0ETpCRAZpSPWlotXcORIup9jjSZB1LHft58BVqwxBjw j56h74W07jB9mxSEgajyq3ejV/+PWF1ssT6P/QkYDYUoksxpUTjX21F71tkXP6/6xZQA sOgh1knhOxdVN2aOsCwBCl35BH+TPo8ozIs/+Abc5H/GmNq3S4I64X10H9k2l8QFAdvQ XMqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-sender:mime-version:subject:references:in-reply-to :message-id:to:from:date:x-gm-message-state:sender:from:to:cc :subject:date:message-id:reply-to; bh=N2UVOMG7LJi0CenTMjxhqCdN48/ky4dJ47RoVQJwGoc=; b=lSSeyZvBgKTPbiL5+ydiswMLhzOFDEw7agBEIB0iFGiyWUIEi3QOKPybXcIGn/+RBB q+eLmzdTS/PKwInxNcHorWHyxUejXOykFAFjvNPT5EHzxZ2Ik8f4eP7LmYqJt4xFc/3v Miex9ZcMt8ppfLTzm9UKffcH6oKaYbJXyNWUYJwIm/82QYryMA/hcPSuaqNYe9WviL75 0qzUqB/UOSl698ar9DrbmWcWHawvm187MpXO0218+OE3mgyP03GTc9cFU4k/6VtFi2mv EMe3RGrkp5Bsprnhnu1yCuxud3Wj2co/yoK2jsox1Ry5/uGtYjEltf1pEBnHb6xAoOhJ HZ4A== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AO0yUKU2JFTT5Nu4TIPHjZyMr0j8xDuZ4HDLEXTWTQlkYprH7wHiJc6A IQs2aT+np2Dn7sKxQX/jZTY= X-Google-Smtp-Source: AK7set+Nq++ffMt4WU3ZZfimK1Me/Rs3fGHiHr/KYzl83EHAFlq+bx+EAMammAA8sMtu1v3zaashhQ== X-Received: by 2002:a05:620a:1115:b0:71f:b908:7b83 with SMTP id o21-20020a05620a111500b0071fb9087b83mr1074094qkk.15.1677083619764; Wed, 22 Feb 2023 08:33:39 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6214:176d:b0:56f:ee90:e325 with SMTP id et13-20020a056214176d00b0056fee90e325ls7389106qvb.7.-pod-prod-gmail; Wed, 22 Feb 2023 08:33:37 -0800 (PST) X-Received: by 2002:a05:6214:a05:b0:56e:8c9a:2610 with SMTP id dw5-20020a0562140a0500b0056e8c9a2610mr1037773qvb.3.1677083616935; Wed, 22 Feb 2023 08:33:36 -0800 (PST) In-Reply-To: X-Original-Sender: julien.dutant-Re5JQEeQqe8AvxtiuMwx3w@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:32218 Archived-At: ------=_Part_6748_1138358186.1677083616193 Content-Type: multipart/alternative; boundary="----=_Part_6749_1996953081.1677083616193" ------=_Part_6749_1996953081.1677083616193 Content-Type: text/plain; charset="UTF-8" I'd check out if there's an extension flag (https://pandoc.org/MANUAL.html#extensions) you can add to commonmark_x input for it to process multiline attributes. Or one that can be added to markdown to process math attributes. As the Pandoc AST doesn't have attributes on Math elements (https://pandoc.org/lua-filters.html#type-math) the common mark reader turns them into attributes of a container Span element, as your output shows. So an alternative would be to simply write the span in Pandoc's markdown by simply adding a backtick before and after: `$$x = 1+2$$`{ .cs #math:equation caption=test} `$x = 1+2$ `{ .cs #math:equation caption=test} ~~~{ .cs #lst:my-listing caption=test } def f(x): return x ~~~ Writing a Lua filter that picks up either is also an option. Picking up attributes list after equations is probably a bit complicated. But using pattern matching to process the initial {...} in a code block is more feasible. All the best, On Wednesday, February 22, 2023 at 8:15:53 AM UTC A A wrote: > Anyone? I also opened an issue in Github but no response. > > On Fri, 17 Feb 2023 at 12:01, A A wrote: > >> Dear all, >> >> Having not received a response to my query below, I ran a few of my own >> tests to try to understand what is going on. >> >> It seems that commonmark_x *does* recognize attributes for both inline >> and display math. If I have the following in my markdown file: >> >> $$x = 1+2$${ .cs #math:equation caption=test} >> >> $x = 1+2${ .cs #math:equation caption=test} >> >> ~~~{ >> .cs >> #lst:my-listing >> caption=test >> } >> def f(x): >> return x >> ~~~ >> >> And I run pandoc --from commonmark_x --to native test.md I will get the >> following: >> >> [ Para >> [ Span >> ( "math:equation" , [ "cs" ] , [ ( "caption" , "test" ) ] ) >> [ Math DisplayMath "x = 1+2" ] >> ] >> , Para >> [ Span >> ( "math:equation" , [ "cs" ] , [ ( "caption" , "test" ) ] ) >> [ Math InlineMath "x = 1+2" ] >> ] >> , CodeBlock >> ( "" , [ "{" ] , [] ) >> " .cs \n #lst:my-listing \n caption=test\n }\ndef f(x):\n return x" >> ] >> >> Notice that the multiline attributes for the CodeBlock element are not >> picked up. If I instead try pandoc --from markdown --to native test.md: >> >> [ Para >> [ Math DisplayMath "x = 1+2" >> , Str "{" >> , Space >> , Str ".cs" >> , Space >> , Str "#math:equation" >> , Space >> , Str "caption=test}" >> ] >> , Para >> [ Math InlineMath "x = 1+2" >> , Str "{" >> , Space >> , Str ".cs" >> , Space >> , Str "#math:equation" >> , Space >> , Str "caption=test}" >> ] >> , CodeBlock >> ( "lst:my-listing" , [ "cs" ] , [ ( "caption" , "test" ) ] ) >> "def f(x):\n return x" >> ] >> >> >> The attributes in the CodeBlock element *are* picked up, but the >> attributes for display and inline math are not. >> >> Unfortunately, for my use case I would like to be able to assign >> multiline attributes to code block elements *and* assign attributes to >> display and inline math elements. >> >> Is there a way to achieve both in the same markdown file? Thanks for your >> consideration. >> >> Regards, >> >> Amine >> >> ---------- Forwarded message --------- >> From: A A >> Date: Wed, 8 Feb 2023 at 13:52 >> Subject: Can math elements have attributes >> To: >> >> >> Dear all, >> >> I am writing my own pandoc to latex converter using panflute and would >> like to attach attributes to Math elements. I have tried the following >> syntax, but it seems that the attribute is not being picked up by panflute: >> >> ``` >> $$x=y$${ a=b } >> ``` >> >> I did some of my own research to figure out what I was doing wrong. And a >> couple of things became apparent: >> >> - On the one hand, it looks like pandoc might not support this: >> - https://github.com/jgm/pandoc/issues/684 >> - https://github.com/jgm/pandoc/issues/5286 >> - On the other hand, `pandoc-crossref` seems to be able to handle this >> syntax: >> - https://github.com/lierdakil/pandoc-crossref >> - https://lierdakil.github.io/pandoc-crossref/#equation-labels >> >> Is this currently supported by pandoc? If not then how is >> `pandoc-crossref` able to handle it? Thanks for your consideration. >> >> Regards, >> >> Amine >> >> >> -- 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/0845b275-aa43-4fc3-86a5-17b20de652een%40googlegroups.com. ------=_Part_6749_1996953081.1677083616193 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I'd check out if there's an extension flag (https://pandoc.org/MANUAL.= html#extensions) you can add to commonmark_x input for it to process multil= ine attributes. Or one that can be added to markdown to process math attrib= utes.

As the Pandoc AST doesn't have attri= butes on Math elements (https://pandoc.org/lua-filters.html#type-math) the = common mark reader turns them into attributes of a container Span element, = as your output shows. So an alternative would be to simply write the span i= n Pandoc's markdown by simply adding a backtick before and after:

`$$x =3D 1+2$$`{ .cs #math:equation caption= =3Dtest}

`$x =3D 1+2$ `{ .cs #math:equation caption=3Dtest}

~~~{
=C2=A0 .cs
=C2=A0 #lst:my-listing
=C2=A0 caption=3Dtest=C2=A0}
def f(x):
=C2=A0= =C2=A0 return x
~~~
=

Writing a Lua filter that picks up either is also an = option. Picking up attributes list after equations is probably a bit compli= cated. But using pattern matching to process the initial {...} in a code bl= ock is more feasible.

All the best,
=

On Wednesday, February 22, 2023 at 8:15:53 AM UTC A A wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin: 0 0 0 0.8ex; border-left:= 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Anyone?= I also opened an issue in Github but no response.

On Fri, 17 Feb 2023 at 12= :01, A A <amine.ab...@gmail.c= om> wrote:
Dear all,

Having not received a response to my query below, I ran a= few of my own tests to try to understand what is going on.

It seems that commonmark= _x does recognize attributes for both inline and display ma= th. If I have the following in my markdown file:

$$x =3D 1+2$${ .cs #math:equation caption=3Dtest}

$x =3D 1+2${ .cs #math:equation caption=3Dtest}

~~~{
  .cs=20
  #lst:my-listing=20
  caption=3Dtest
  }
def f(x):
    return x
~~~

And I run pandoc --from commonmark_= x --to native test.md I will get the following:

[ P=
ara
    [ Span
        ( "math:equation" , [ "cs" ] , [ ( "captio=
n" , "test" ) ] )
        [ Math DisplayMath "x =3D 1+2" ]
    ]
, Para
    [ Span
        ( "math:equation" , [ "cs" ] , [ ( "captio=
n" , "test" ) ] )
        [ Math InlineMath "x =3D 1+2" ]
    ]
, CodeBlock
    ( "" , [ "{" ] , [] )
    "  .cs \n  #lst:my-listing \n  caption=3Dtest\n  }\ndef f(x):\n   =
 return x"
]

Notice that t= he multiline attributes for the CodeBlock element are not picked up. If I i= nstead try pandoc --from markdown --to native test.md:

[ Para
    [ Math DisplayMath "x =3D 1+2"
    , Str "{"
    , Space
    , Str ".cs"
    , Space
    , Str "#math:equation"
    , Space
    , Str "caption=3Dtest}"
    ]
, Para
    [ Math InlineMath "x =3D 1+2"
    , Str "{"
    , Space
    , Str ".cs"
    , Space
    , Str "#math:equation"
    , Space
    , Str "caption=3Dtest}"
    ]
, CodeBlock
    ( "lst:my-listing" , [ "cs" ] , [ ( "caption&q=
uot; , "test" ) ] )
    "def f(x):\n    return x"
]
<= /div>

The attributes in the CodeBlock element are picked up, but t= he attributes for display and inline math are not.

Unfortunately, for my use case I would li= ke to be able to assign multiline attributes to code block elements and= assign attributes to display and inline math elements.

Is there a way to achieve both in the sam= e markdown file? Thanks for your consideration.

Regards,

Amine


---------- Forw= arded message ---------
From: A A <amine.ab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Wed, 8 Feb 2023 at = 13:52
Subject: Can math elements have attributes
To: <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>


Dear all,

I am writing my own= pandoc to latex converter using panflute and would like to attach attribut= es to Math elements. I have tried the following syntax, but it seems that t= he attribute is not being picked up by panflute:

`= ``
$$x=3Dy$${ a=3Db }
```

I di= d some of my own research to figure out what I was doing wrong. And a coupl= e of things became apparent:

- On the one hand, it= looks like pandoc might not support this:

Is this currently supported by pandoc? If not then how is `pandoc-cro= ssref` able to handle it? Thanks for your consideration.

Regards,

Amine

--
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/0845b275-aa43-4fc3-86a5-17b20de652een%40googlegroups.= com.
------=_Part_6749_1996953081.1677083616193-- ------=_Part_6748_1138358186.1677083616193--