From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32797 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephan Boltzmann Newsgroups: gmane.text.pandoc Subject: Bold figure caption prefix in docx output with filter Date: Tue, 13 Jun 2023 06:16:39 -0700 (PDT) Message-ID: <534b2214-42e6-4be9-8b0e-537509f5be3an@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_17770_1192632962.1686662199490" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15706"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCZ25UWY24ERBOGYUGSAMGQE4VQVJMA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Jun 13 15:16:44 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oo1-f58.google.com ([209.85.161.58]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1q93t6-0003uz-18 for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 13 Jun 2023 15:16:44 +0200 Original-Received: by mail-oo1-f58.google.com with SMTP id 006d021491bc7-55afacd3d2dsf5065531eaf.0 for ; Tue, 13 Jun 2023 06:16:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1686662203; x=1689254203; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:message-id:to:from:date:sender:from:to:cc :subject:date:message-id:reply-to; bh=RNF3TiuQaMFwbxDkRt7qXxlwRGbBfkEerAn5KQUwFjQ=; b=LVt9i+WPTIdHVdM6K4WymHE4YYaG9ISdy7U/encCsmHyWjGDl2YgSRhmT0ZlIc/S35 g1WPb/cBAhRS6HyVlOoy+bicNHglR6Hfcoz9CjGt/h0JzlFyXlerPEE+d4+UGAe7H3gj 1NfmeD114FSOX5uG/20krVlNdKp6lK+kv7pdZlW3K9/YAHzVcZ7L0Dmtm7IG2mSIU1rI Ka/x279ZyPPOhqmAetosVUYITYsB35Wlo+gzGRZK5VUIPhbYOvaVq/U/ogCbykl47Shd WjOxCduMzcV6AbF0CzMKWEsuzsRVdKuU7pb7RlG835vc6+F0koFNv0xlX0DRvB3h3GtW fGfw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686662203; x=1689254203; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:message-id:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=RNF3TiuQaMFwbxDkRt7qXxlwRGbBfkEerAn5KQUwFjQ=; b=HuXj1gn7wqdSePlSvib32plie9JWGYJ/fGXpX+xBfowmQe5Frrjl5CBkes5mTWv4cR /G0Sm/UUOsEWsEDGBWh04+htUymhNaW+8chsV9DTNfMvEUq33570CCLxiui04ROpC7cx tXp9gnrKcxzKNqYJQpLzw9QRwxWdPGO14d8H/u08hNwR8Afwx7rd8PdqNA8iA8MAhkwc FbTfD0r5zWqGE5v/k4ctnWl+3gjVjrV2e9sfPWZisbTq8Q8NOskdG0kApdpN6NN5jW5S IMz/z7JvokL/DQRlJGcHgpbMP1bQ8a2GzdLvWtxCCAa23pjgFRpGPh6YA5PvGFvqgBeU uqNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686662203; x=1689254203; 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:message-id:to:from:date :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=RNF3TiuQaMFwbxDkRt7qXxlwRGbBfkEerAn5KQUwFjQ=; b=DswEI8XxbWrdhLrpLd6iQClkFHkgJw2IYckCafd3x8WZPMJB7VwFVe/ZnW/sPzSnwA 5TpRAwJYV/9jyqDqO+xZZm75JUTJ25J1kreC5ZOAJUDyiTZ6G9ptnhMQI5QuYMXG/h24 tkar38FDVp1s7mcxANob2Km3pEplUQ4hao7YNo09mc/W2PsM5vWmCGGb2nEkindSV382 X/zRaGReS3iUNI4eEePGDiv/aI0eHwWtZhkojqSYSGqerAwXDC78yWHbqnWUD4dTREeO xmSHkqiyH3yrQ3xj4d3tNzlJL5i9myvruwArj3mfA4gL2+pHg37Ov9Ma99Dui1C4twIm Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AC+VfDy4acID6XdNo7AT4KAn7D8/ziPeozcmTuFKGQIOwiYHnkGXZQ+S 206A7Ygqw+NSdsuHaaQpVrQ= X-Google-Smtp-Source: ACHHUZ5BHSyBxSpBT0zp0K0G8n6WwL7/81fJPPcmeznW9hgW8GbMKjPpl7ZJ6Oh+XVsRblI2z4dB1Q== X-Received: by 2002:a4a:e9e2:0:b0:558:b424:8c31 with SMTP id w2-20020a4ae9e2000000b00558b4248c31mr7097171ooc.0.1686662202872; Tue, 13 Jun 2023 06:16:42 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a4a:df01:0:b0:558:a120:51a2 with SMTP id i1-20020a4adf01000000b00558a12051a2ls4550980oou.1.-pod-prod-01-us; Tue, 13 Jun 2023 06:16:40 -0700 (PDT) X-Received: by 2002:aca:c1c2:0:b0:39c:f00f:4ae with SMTP id r185-20020acac1c2000000b0039cf00f04aemr732826oif.1.1686662200080; Tue, 13 Jun 2023 06:16:40 -0700 (PDT) X-Original-Sender: stephan2boltzmann-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:32797 Archived-At: ------=_Part_17770_1192632962.1686662199490 Content-Type: multipart/alternative; boundary="----=_Part_17771_717063661.1686662199490" ------=_Part_17771_717063661.1686662199490 Content-Type: text/plain; charset="UTF-8" Hello everybody out there using Pandoc, The following Lua (used with RMarkdown in RStudio) filter should put "*Figure n.*" in bold at the beginning of every figure caption, but it doesn't change my output: function Image (img) if FORMAT:match 'docx' then caption = pandoc.utils.stringify(img.caption) if (string.find(caption, 'Fig') ~= nil) then img.caption[1] = pandoc.Strong(img.caption[1]) img.caption[3] = pandoc.Str(string.gsub(img.caption[3].text, ":", ".")) img.caption[3] = pandoc.Strong(img.caption[3]) fig_num_string = string.sub(pandoc.utils.stringify(img.caption[3]),1,2) fig_num = math.floor(tonumber(fig_num_string)) if (fig_num > 6) then img.caption[3] = pandoc.Strong("S" .. tostring(8-fig_num) .. '.') end img.caption.long = pandoc.Strong('A') img.caption = pandoc.Strong('A') end end print(pandoc.utils.stringify(img.caption.long)) return img end By putting print statements, I can partially verify that the filter operates on the correct elements, but it doesn't change the output. -- 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/534b2214-42e6-4be9-8b0e-537509f5be3an%40googlegroups.com. ------=_Part_17771_717063661.1686662199490 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello everybody out there using Pandoc,

The= following Lua (used with RMarkdown in RStudio) filter should put "Figur= e n." in bold at the beginning of every figure caption, but it doesn't = change my output:

function Image (img)
=C2=A0 if FORMAT:match 'docx' then=C2=A0 =C2=A0 caption =3D pandoc.utils.stringify(img.caption)
=C2= =A0 =C2=A0 if (string.find(caption, 'Fig') ~=3D nil) then
=C2=A0 =C2= =A0 =C2=A0 img.caption[1] =3D pandoc.Strong(img.caption[1])
=C2=A0 =C2= =A0 =C2=A0 img.caption[3] =3D pandoc.Str(string.gsub(img.caption[3].text, "= :", "."))
=C2=A0 =C2=A0 =C2=A0 img.caption[3] =3D pandoc.Strong(img.ca= ption[3])
=C2=A0 =C2=A0 =C2=A0 fig_num_string =3D string.sub(pandoc.ut= ils.stringify(img.caption[3]),1,2)
=C2=A0 =C2=A0 =C2=A0 fig_num =3D ma= th.floor(tonumber(fig_num_string))
=C2=A0 =C2=A0 =C2=A0 if (fig_num &g= t; 6) then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 img.caption[3] =3D pandoc.Stron= g("S" .. tostring(8-fig_num) .. '.')
=C2=A0 =C2=A0 =C2=A0 end
=C2= =A0 =C2=A0 =C2=A0 img.caption.long =3D pandoc.Strong('A')
=C2=A0 =C2= =A0 =C2=A0 img.caption =3D pandoc.Strong('A')
=C2=A0 =C2=A0 end
= =C2=A0 end
=C2=A0 print(pandoc.utils.stringify(img.caption.long))
=C2=A0 return img
end

By putting print statements, I can part= ially verify that the filter operates on the correct elements, but it doesn= 't change the output.

--
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/534b2214-42e6-4be9-8b0e-537509f5be3an%40googlegroups.= com.
------=_Part_17771_717063661.1686662199490-- ------=_Part_17770_1192632962.1686662199490--