From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32806 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Bastien DUMONT Newsgroups: gmane.text.pandoc Subject: Re: Inserting attributes into elements Date: Tue, 13 Jun 2023 21:27:46 +0000 Message-ID: References: <76a72c07-6699-d243-ae20-64808682ec9e@meddatainc.com> <90C7A30F-C0FA-49D8-B0CD-6521B58113F1@meddatainc.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19933"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDCINCES2QJRBVF6UOSAMGQEH5VCN7I-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Jun 13 23:27:54 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-wm1-f60.google.com ([209.85.128.60]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1q9BYP-0004wE-9k for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 13 Jun 2023 23:27:53 +0200 Original-Received: by mail-wm1-f60.google.com with SMTP id 5b1f17b1804b1-3f7f2d9a660sf216055e9.2 for ; Tue, 13 Jun 2023 14:27:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686691673; cv=pass; d=google.com; s=arc-20160816; b=DcOkHny9FVyG3hHjznAc4Md/mttiUN96yu6+z+t7sQxyU/fwhCbjFxmlaFxGJbpRlj iAknG+dag4E4f7qXN3nbslhCzQEpaSmbYUfjXjkD5ig5iYRQ6tcgJ+eiU/JbgDHJnMDb 8DUQGerlGoCi4v8TiRjVqGoJ4+kh5kNxn5qPp4dUFXNxSqf4sgLHs35MVqVsGMjErXCs My3/K9ucGUbyGV91IqDoWU7vJC3WugCutr0xaO7eVn9B0p0ldBccifubTVvC9uGjXKI4 ttOjkhqDRzy/U9n0U+cxOyyWfV2FJkfp/DYeFjuaSQvxWQNp5KnZ+i9rP0A8Rahy8c3T 7PVA== 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:to:from:date:sender:dkim-signature; bh=MPeg5xKyrOoUs8uO9MGCMoBg2OdXswXt1shIhRoS8xY=; b=iQxQ5XFMUCCt7+8VvbaUIrsvsoDbIzCni8pJ9aEFJDui6X7D4UoSA6inQPsSdGJgac houx7Op/DW0Ewai7hTDJzHKbA4OXGT3wGMXFbkTMFMLXj7ZGZtdEKvBvNFyPO6/D4Gke yRaM6fVIEKnJGlOlBYQ5e1iLxRlccTHMoI5Q8bA69IbNZE/yQSHF0tZahEqLuzpbPzKn PAhA/HI86s1FZU2jOjZq45RJ01GoTnbLs5U4B7+kFq0/9o12imcK/oPPcOrauPDPZmW2 N1RFIChS+By2kToJBsU5egIndbb8ZihhCwcAuTFvF1wQEOReykpnhKvvM1Ab1nu0NOW3 TVEA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b="inc57cc/"; spf=pass (google.com: domain of bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org designates 185.67.36.65 as permitted sender) smtp.mailfrom=bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1686691673; x=1689283673; 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:to:from:date:sender:from:to:cc :subject:date:message-id:reply-to; bh=MPeg5xKyrOoUs8uO9MGCMoBg2OdXswXt1shIhRoS8xY=; b=WyX2UoYVXTlvCISJnl9SBkr3XMHsmdlwNhVYdKLDswQT3pfX7BcQjic9X4q6FyA/wY RxfPsz9YMW1q3orp2PKCeFAcDestXHngu0AanlDy1pLqwwA27HIv+oneBaDbnvISyp4o SmC+Cs6ULAPwPbrQQ+BaEuS5QJcp6iak5YVzAbgNPNIUZfz4umH9yMc2hRRivjboGoSl ZnyXooNg+MC7C6899BARKllui84W4Z4VlqOFY9pWAs2AF2bxkVo1WiLqoVLjq/pQf8UQ zmF9idrM7g7HOGwMn X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686691673; x=1689283673; 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:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:to:from:date:x-beenthere :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=MPeg5xKyrOoUs8uO9MGCMoBg2OdXswXt1shIhRoS8xY=; b=g0+Ygd0vFDboL99xnQ6/Y9yl3I+hrNVf3xFd93TTU1XnCg1JRJFfWMW0tz4PPlyC8H Pb0WjXF+cf6/0/QBsAX1RSpVVil1OreA+9B7hsyZLzeKzyZkhsR8yZAM+VT+cjOMI3j9 TlJEcf3bu7nUQOvnHh0GlUuASx+qGS4OYHA7IecqAqea1tmYtUbVTtWBK/mJPW9Cn7Mv caTjyx4zPAYRjO2HY/IdeAGoH2Tt Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AC+VfDxKco6MrZbqQX9xmWKy7FAYXnPqsQt4hADZ+u7LZi51zXiPRMll fyX8W5AHdHbkeStWKS1NTmU= X-Google-Smtp-Source: ACHHUZ6JGlyk3IA0sRZOsTqoOprpHjy8fowTmMG8c+beK7YGYOBLbEz3lNlqfDmJegbPJIr+aQMESg== X-Received: by 2002:a7b:c8d3:0:b0:3f6:7fb:b60e with SMTP id f19-20020a7bc8d3000000b003f607fbb60emr9521602wml.35.1686691672574; Tue, 13 Jun 2023 14:27:52 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:600c:5110:b0:3f3:15ce:e16c with SMTP id o16-20020a05600c511000b003f315cee16cls740771wms.0.-pod-prod-01-eu; Tue, 13 Jun 2023 14:27:47 -0700 (PDT) X-Received: by 2002:a5d:4492:0:b0:30e:3da5:46e5 with SMTP id j18-20020a5d4492000000b0030e3da546e5mr7264450wrq.59.1686691667574; Tue, 13 Jun 2023 14:27:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686691667; cv=none; d=google.com; s=arc-20160816; b=mPh430W6b9yg3P7PViq4GHpTkBUEbjQW3DNFLx3iBBT0BXUiIbrOHGA1fs7yOM80I7 OXwx8cWJjyYwU7juePSvRd910GnJj+MU/v6YM5ioPegb2POV8uPnP1V5nsDSeb6PloAv o3rCbtHZAeCr/4lDFs6Pc17RuseeJYKxgn0E5ICG1C59bVQTvsNFfNjaZcpIf2OYh52u qbPgkVbPD+HDwlCrJgT42TkzJC8EiMqtkYvrhEJdcQzRY4qnCjSU/AuTshLYg4EvZKmQ LYAWI20/7FIxLH57ToYtbeh/6ntndS8tM+duqPWIcgUoDrJbXPDDVyTSp0DUNyYLA5DM 4w9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:to:from:date :dkim-signature; bh=o6H6qsfaJh3Bm1QiBJ28t141Fbglvgf4/Hz4BsRAZ40=; b=YKeZQA1JQ0odH/9F9PbsMIxm+5q2GUCmffQR2nKnJcv/xe44rGf3XMgaOvx92u50TY ORYm4McC8c+9BBBVa5C3bssdBG/T3rMlQ6MRFcrYTpzLKg8UsxcsRiSNs5JOxmqmJ30B IvVeMDVAm5A0GH2ND68rHZgeDfeOKIg5jyNn/+JQn7t2vKlKSPNqISkxiRQVDDZ3QSJt adgSMBMhlJgB1K3R+/1hrBCwJI2P24TnY7STy3fN5grCyKyYURPC1tAC67c9VS336++b mulQbJFr/DD+BaS8mfl+emoAQ9Q5WHKN7+BnSj1tfMS6HsamTr6jOQof60eDPRrZGkqY b9Gw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b="inc57cc/"; spf=pass (google.com: domain of bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org designates 185.67.36.65 as permitted sender) smtp.mailfrom=bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net Original-Received: from mout01.posteo.de (mout01.posteo.de. [185.67.36.65]) by gmr-mx.google.com with ESMTPS id b13-20020adfd1cd000000b003062765f97esi779937wrd.6.2023.06.13.14.27.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 14:27:47 -0700 (PDT) Received-SPF: pass (google.com: domain of bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org designates 185.67.36.65 as permitted sender) client-ip=185.67.36.65; Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 2787C240028 for ; Tue, 13 Jun 2023 23:27:47 +0200 (CEST) Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QghVB5Yxkz6tw5 for ; Tue, 13 Jun 2023 23:27:46 +0200 (CEST) Content-Disposition: inline In-Reply-To: <90C7A30F-C0FA-49D8-B0CD-6521B58113F1-FcZObrvlYduBUy7/sJONFg@public.gmane.org> X-Original-Sender: bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@posteo.net header.s=2017 header.b="inc57cc/"; spf=pass (google.com: domain of bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org designates 185.67.36.65 as permitted sender) smtp.mailfrom=bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.net 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:32806 Archived-At: You call =E2=80=9Cinsert=E2=80=9D as if it were a method of =E2=80=9Cattr= =E2=80=9D, but attr is a key-value table. The correct way to add an attribu= te is: if (el.level =3D=3D 2) then local attr =3D el.attributes attr.style =3D 'color: #112233;' end Le Tuesday 13 June 2023 =C3=A0 05:19:14PM, H a =C3=A9crit : > On June 13, 2023 5:16:32 PM EDT, H wrote: >=20 > On June 13, 2023 5:00:19 PM EDT, 'William Lupton' via pandoc-discuss > wrote: >=20 > As far as I know, you can't add 'style' attributes. But you can e= mbed > CSS via header-includes. You'll find an example of this if you se= arch > 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). >=20 > On Tue, 13 Jun 2023, 21:37 H, <[1]agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote: >=20 > Continuing my quest to write a custom filter, I now ran into = a need > to add attributes to different types of tags as exemplified b= elow: >=20 > - In header tags such as

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

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

data-insert=3D" style=3D"text-transform: uppercase; colo= r: # > cc002b;""> >=20 > Clearly not the correct way. Can I add the style information = as > above in a filter, in the pandoc function as I am going throu= gh 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. >=20 > I guess I could do it similarly to below but then it applies = to all > eg H2: >=20 > function Header(el) > -- remove header identifier for all levels > el.identifier =3D '' >=20 > -- convert level 1 and 2 to upper case > if (el.level =3D=3D 1) or (el.level =3D=3D 2) then > return el:walk { > Str =3D function(el) > return pandoc.Str(text.upper(el.text)) > end > } > else > return el > end > end >=20 > How to do it on individual H2 in a filter? >=20 > Thanks. >=20 > -- > You received this message because you are subscribed to the G= oogle > Groups "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from= it, > send an email to [2]pandoc-discuss+unsubscribe@googlegroups.c= om. > To view this discussion on the web visit [3]https:// > groups.google.com/d/msgid/pandoc-discuss/ > 76a72c07-6699-d243-ae20-64808682ec9e%40meddatainc.com. >=20 >=20 > I need to stay away from css since the software the output is used in= does > not allow css info to be added. >=20 >=20 > Can I "rewrite" a tag in the filter? >=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= email > to [4]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit [5]https://groups.google.com/d/m= sgid/ > pandoc-discuss/90C7A30F-C0FA-49D8-B0CD-6521B58113F1%40meddatainc.com. >=20 > References: >=20 > [1] mailto:agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org > [2] mailto:pandoc-discuss%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > [3] https://groups.google.com/d/msgid/pandoc-discuss/76a72c07-6699-d243-a= e20-64808682ec9e%40meddatainc.com > [4] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > [5] https://groups.google.com/d/msgid/pandoc-discuss/90C7A30F-C0FA-49D8-B= 0CD-6521B58113F1%40meddatainc.com?utm_medium=3Demail&utm_source=3Dfooter --=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/ZIjfUqabWGUWcZz2%40localhost.