From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32803 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "'William Lupton' via pandoc-discuss" Newsgroups: gmane.text.pandoc Subject: Re: Inserting attributes into elements Date: Tue, 13 Jun 2023 22:00:19 +0100 Message-ID: References: <76a72c07-6699-d243-ae20-64808682ec9e@meddatainc.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000003be6da05fe0920cd" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39835"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCS4HJ6WSAHBB4VRUOSAMGQEKOUIXYQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Jun 13 23:00:40 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-lj1-f187.google.com ([209.85.208.187]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1q9B83-000AF2-Q0 for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 13 Jun 2023 23:00:39 +0200 Original-Received: by mail-lj1-f187.google.com with SMTP id 38308e7fff4ca-2b1e6258204sf43317411fa.3 for ; Tue, 13 Jun 2023 14:00:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686690039; cv=pass; d=google.com; s=arc-20160816; b=lvGpQxZkSnKJbleoxL/w4xeV+veHmOhEUjGYOU+Q+wTbDcwfdLSuuxt5gKmdqEj7kV kaVJuA6TPckB9xntLbLN9p3aGLxHH+tBX7M5kiv9XowDAB378jcCLv/twq8GdBn2y8rT ly2J/Wxe8HbhZPPYrrHB53+ANeowBZhV+282qudluf4K+lRvUnchty6+83wMSxlm5Glu wXYIhF9VN/EvMl+Ttdc/DZ3GxFTLNOTANEobS6uWBe8IaF/XFh9Ny3+KEjoKhlDSOGyV BsZStmKRI1ekepr/ZrQYC0GSDUu2W4GBuBUbEZauZil4ZDEzMi+5XCuDgHBuZWv3v+Az dq8A== 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:to:subject:message-id:date :from:in-reply-to:references:mime-version:dkim-signature; bh=J6P5brL6UWumeegs94FgvzE4uzDF9ucoffXMaglrWtI=; b=brLzVm9cIeaj+MFgC9ur7Rl/0pWcYnAnuXXFJNq2Zc1jz0HIEv8N5/nfDmqkIqviil LLUMGBcX7pimijDega5h8s8S3aIM3yFLteN9/gkBnfT27AeT1qfDyE4sGK8ed7RvQeBa xNIIRXURv1usbSthPq2DWK6Xy6ns3D70nfM50VQSQ3bfto3zYMMpt2cl7F0fqXOQoFt4 myTUqXBHhO3a9StzODGj9Ktk2yfS7UQ9ltsIeHV8Lpql//int1cmmdULNZh2HhwgwS7o R3SKV+v7iaHoyRkNO4kizt5a+qc3mexcRpXsGhOHEDE2bKdX9jd4oVlk6UqOnWzUtPUg V1bQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@broadband-forum.org header.s=google header.b=EBzK0ejN; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::62e as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadband-forum.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1686690039; x=1689282039; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:to:subject :message-id:date:from:in-reply-to:references:mime-version:from:to:cc :subject:date:message-id:reply-to; bh=J6P5brL6UWumeegs94FgvzE4uzDF9ucoffXMaglrWtI=; b=Txkbpo3wYM6waKg/NncsmgLDhqxRApGf2UaKqU6G9ah9wVCN02ZTiJFNfZeO7uCbi/ 8KrsmVXw5s+u0fpQlqf/09+0z/AbebNNDVbLhCzp91Z0pkpgSAqec9odVfGuLdMYYPeT QIMHu3az2sjMnvB39Q7HGirGlICc4t8M/vfqcZzIIFl9FN+Pkc5MOadYgXo4zVG8Ugq6 /83cFKPEAVbdCwaz2BTrAqzRQGmYQ0r2xsgx/Kxm9cBHZ1bAMIbTBI/G30cQnpmRQd4C 99J7kxJLwI7vVCl/PEmuWBc8XTDX652GExcDE5d6zC5mQ1qgcjq7PL8JsMpfVKCoIZVS +x X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686690039; x=1689282039; 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-authentication-results:x-original-sender:to:subject :message-id:date:from:in-reply-to:references:mime-version :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=J6P5brL6UWumeegs94FgvzE4uzDF9ucoffXMaglrWtI=; b=U+E2PEiNHIWQUZXpa7M1ayBZUTA1Ho1GSMfKu6N+O0SBJnqyAp6MOJACusIeCWksMy P68qTr0AeHR/aZlJvq4tpaT0aMe8NGuNDnc44WnIr7SPycrThz+e8f7MojkhRi07mrrW Vx+lMoFgwzKtCdfHcwmBe7F06bOV+guyKSzctwZiEBcjDuXE1t+kdemPw0/005ymnnv6 yTLgzMoefJgFe8WHaGKeo+8Ve12QfPEcqy8kJ7yR2LMj4gVhvBVn6bQJiEaMDmXeIJgT tT+RCxRmevzti X-Gm-Message-State: AC+VfDxbfPwK/+lX0ulmD9ZTjC4awIhBmWLVQYdMISqZBRbWnVF2LA8P 5qRslFlla17oAmiRAKTNvQk= X-Google-Smtp-Source: ACHHUZ6PJdTS67MPYm7gpG/odvojd1MACxiEE9JigbHnQjRC/+vn/Zoz2W1GIDg3CEU7XXS6z8WS2A== X-Received: by 2002:a2e:b60c:0:b0:2b3:3a2c:90a0 with SMTP id r12-20020a2eb60c000000b002b33a2c90a0mr1618687ljn.26.1686690038950; Tue, 13 Jun 2023 14:00:38 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:651c:1cc:b0:2b1:ce5e:308d with SMTP id d12-20020a05651c01cc00b002b1ce5e308dls114027ljn.1.-pod-prod-09-eu; Tue, 13 Jun 2023 14:00:33 -0700 (PDT) X-Received: by 2002:a2e:b053:0:b0:2ad:9acb:4849 with SMTP id d19-20020a2eb053000000b002ad9acb4849mr5682630ljl.47.1686690033541; Tue, 13 Jun 2023 14:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686690033; cv=none; d=google.com; s=arc-20160816; b=V9eQgIckKW5jiegWJbep+q0G336SPG3k/a8TfWsJegOnfOnxn8/uOzRiwGIg5JCLGT lUmratWZMJBS86/OEgKitUiawJN/NwkUg8Br6B33EThTAVn5v8jQ/GwjnJd7vcOlLuPH QWe+d2Zkg6NXgRGemmM1bNNNyhP/AEtL4GB/gawzjF+It6POmPe3fVC+9f01ZBfk5LQW rrenCSdTUaqR94xIWUDvdEWp9RCzJeXIh0leedBT86FL1aGV8UI6FYEZWXKMfrKe/TIZ /NoS80Ta285tpTG4Rz5cSrKY2f78k9qssgSM6yTi6YSjl/9pudL8sAm7GGFp5RPA7TDX fpvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=qAhmm6CFvmicL6PPdytXMfVitKHS70eD75KI0kS0GEc=; b=c5IQ9Xq5iIL2Qytmj/SzpnhUa9qZRBJLe0u9q/Txqjlma8HSeUel1TyKwsno7FYl1Z bbq5TAzLQrXcYZcqKXIxtjzZVqlAPu85RIhkdghYnVY8rwFncyKvjXIEcROz2AX3YJxS U/bEHraw+HLU/peQyb686psbedg/8L/6ZHmJgHFaUX08AfGOxoCyMMqUoyDyGQAqFove i3Uv0tTNjxmFeZu/3FniF9Wzh4YL8IRgk1WqwDWp53qHrWbQZgPuxWb6iSaGtBvAh1GY rm0u4gElQD+ZcRM8Ae1Sv8FviD/4heRODtdPbwwO0cdMrsk3ZTffbI7tUvkBBG9qVguf 8JGg== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@broadband-forum.org header.s=google header.b=EBzK0ejN; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::62e as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadband-forum.org Original-Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com. [2a00:1450:4864:20::62e]) by gmr-mx.google.com with ESMTPS id e15-20020a05651c150f00b002b1fffb6355si771772ljf.3.2023.06.13.14.00.33 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Jun 2023 14:00:33 -0700 (PDT) Received-SPF: pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::62e as permitted sender) client-ip=2a00:1450:4864:20::62e; Original-Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-9741caaf9d4so3008666b.0 for ; Tue, 13 Jun 2023 14:00:33 -0700 (PDT) X-Received: by 2002:a17:907:934b:b0:966:b4b:eb0 with SMTP id bv11-20020a170907934b00b009660b4b0eb0mr14687298ejc.30.1686690032503; Tue, 13 Jun 2023 14:00:32 -0700 (PDT) In-Reply-To: <76a72c07-6699-d243-ae20-64808682ec9e-FcZObrvlYduBUy7/sJONFg@public.gmane.org> X-Original-Sender: wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@broadband-forum.org header.s=google header.b=EBzK0ejN; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::62e as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadband-forum.org X-Original-From: William Lupton 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:32803 Archived-At: --0000000000003be6da05fe0920cd Content-Type: text/plain; charset="UTF-8" As far as I know, you can't add 'style' attributes. But you can embed CSS via header-includes. You'll find an example of this if you search the manual for 'header-includes' (and you can use a filter to set the variable; I think Albert gave an example of how to do this a few weeks ago). On Tue, 13 Jun 2023, 21:37 H, wrote: > Continuing my quest to write a custom filter, I now ran into a need to add > attributes to different types of tags as exemplified below: > > - In header tags such as

, I need to add "style=color: #112233;" so it > becomes

. > > - I analogously also need to add style information to tags. > > In my filter I tried: > > style_h2 = > > if (el.level == 2) then > local attr = el.attributes > attr.insert = style_h2 > end > > but ended up with the below in my html output: > >

data-insert=" style="text-transform: uppercase; color: > #cc002b;""> > > Clearly not the correct way. Can I add the style information as above in a > filter, in the pandoc function as I am going through my document > block-by-block and modifying the document structure as needed? I already > adding
with various style information as I iterate over the blocks > and that works fine but now I need to modify existing tags. > > I guess I could do it similarly to below but then it applies to all eg H2: > > function Header(el) > -- remove header identifier for all levels > el.identifier = '' > > -- convert level 1 and 2 to upper case > if (el.level == 1) or (el.level == 2) then > return el:walk { > Str = function(el) > return pandoc.Str(text.upper(el.text)) > end > } > else > return el > end > end > > How to do it on individual H2 in a filter? > > Thanks. > > -- > 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/76a72c07-6699-d243-ae20-64808682ec9e%40meddatainc.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/CAEe_xxgeoT3UjKy0vK2b_w87d-ovNgpL_gRdyDeyb6%2B4SztxQA%40mail.gmail.com. --0000000000003be6da05fe0920cd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
As far as I know, you can't add 'style' attri= butes. But you can embed CSS via=C2=A0header-includes. You'll find an e= xample of this if you search the manual for 'header-includes' (and = you can use a filter to set the variable; I think Albert gave an example of= how to do this a few weeks ago).

On Tue, 13 Jun 2023, 21:37 H, <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:
<= /div>
Continuing my quest to write a custom f= ilter, I now ran into a need to add attributes to different types of tags a= s exemplified below:

- In header tags such as <h2>, I need to add "style=3Dcolor: #11= 2233;" so it becomes <h2 style=3D"color: #112233;">.
- I analogously also need to add style information to <image> tags.
In my filter I tried:

style_h2 =3D

if (el.level =3D=3D 2) then
=C2=A0=C2=A0=C2=A0 local attr =3D el.attributes
=C2=A0=C2=A0=C2=A0 attr.insert =3D style_h2
end

but ended up with the below in my html output:

<h2
data-insert=3D" style=3D&quot;text-transform: uppercase; color: #c= c002b;&quot;">

Clearly not the correct way. Can I add the style information as above in a = filter, in the pandoc function as I am going through my document block-by-b= lock and modifying the document structure as needed? I already adding <d= iv> with various style information as I iterate over the blocks and that= works fine but now I need to modify existing tags.

I guess I could do it similarly to below but then it applies to all eg H2:<= br>
function Header(el)
=C2=A0=C2=A0=C2=A0 --=C2=A0=C2=A0=C2=A0 remove header identifier for all le= vels
=C2=A0=C2=A0=C2=A0 el.identifier =3D ''

=C2=A0=C2=A0=C2=A0 --=C2=A0=C2=A0=C2=A0 convert level 1 and 2 to upper case=
=C2=A0=C2=A0=C2=A0 if (el.level =3D=3D 1) or (el.level =3D=3D 2) then
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return el:walk {
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 Str =3D function(e= l)
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= return pandoc.Str(text.upper(el.text))
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 end
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 }
=C2=A0=C2=A0=C2=A0 else
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return el
=C2=A0=C2=A0=C2=A0 end
end

How to do it on individual H2 in a filter?

Thanks.

--
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-discuss+unsubscribe@googlegroups.= com.
To view this discussion on the web visit https://groups.google= .com/d/msgid/pandoc-discuss/76a72c07-6699-d243-ae20-64808682ec9e%40meddatai= nc.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://group= s.google.com/d/msgid/pandoc-discuss/CAEe_xxgeoT3UjKy0vK2b_w87d-ovNgpL_gRdyD= eyb6%2B4SztxQA%40mail.gmail.com.
--0000000000003be6da05fe0920cd--