From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32798 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "'William Lupton' via pandoc-discuss" Newsgroups: gmane.text.pandoc Subject: Re: Bold figure caption prefix in docx output with filter Date: Tue, 13 Jun 2023 14:56:48 +0100 Message-ID: References: <534b2214-42e6-4be9-8b0e-537509f5be3an@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000087d58d05fe033545" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29793"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCS4HJ6WSAHBBLXLUGSAMGQE74X5VQQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Jun 13 15:57:07 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-wm1-f57.google.com ([209.85.128.57]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1q94WA-0007Yr-LI for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 13 Jun 2023 15:57:06 +0200 Original-Received: by mail-wm1-f57.google.com with SMTP id 5b1f17b1804b1-3f7ef0e0292sf21892955e9.3 for ; Tue, 13 Jun 2023 06:57:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686664626; cv=pass; d=google.com; s=arc-20160816; b=no/m801o93WYtzYZZQ2yLbcezio2rhZBaW9yyr8iMtpdhKi0sFigvuyJ2yft38iAph OS8BqjhOHARk6nJ2lJUk9GLBVIjJKZXokEoZ+tmpMIseJc6wvPncj3D6t/G8jK6yUTbE WR+gy81eNYJlr/j/xF5FfjjM25DRBPuhplYEZeY/w44x8Jei053Bnazx+ZOqJPIhMgf2 U8g0CaB8ntIH5ExByP9S9cteYyxtDH99F68u84PYVLJwJ1EtcF62HPiB+jpGS3wm16jK r9c3Tl3DSes1G8bAMNE6+YEf1AR9piGTFs7wVRzmMz3g0ihxC1EO/mrLK73aJj+6tf3u vByg== 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=WnS7sms1LhNAN5bnRuH8G13RQ5D94Yz5Q6wFL2qjw2I=; b=b1xVInL7BeEE5ViH7JXtE+rrxPK0K3TXhZ862CjNVYdD2ga1z7tfFCt97aF/Ju/eP2 ZlBH3t5aarughAUKtIHFePERzcP0nzrQXsNmyza0iM1GhkLq99d9kOROklI6ng4obLEe FUQU9IFNlw303odEm1HumL3gOXKDhKXhwKOzuARC8i/r2MdozNKW+U5PSzWkqlh4o7yb /pLpBICrZIzemiuUoQp2i3i8tV+ygnylbFaFfd3YyN47Rm9jkzLbIdE6r1kwva0HCGJz n3RJDDR8ZEaaTGHbTUSfqcN8Wmdc/e+7FTLAACZd9TNKxnGCO0r3E+a3f3qHDXVURm4w D1AA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@broadband-forum.org header.s=google header.b=gjSLxzYA; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::634 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=1686664626; x=1689256626; 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=WnS7sms1LhNAN5bnRuH8G13RQ5D94Yz5Q6wFL2qjw2I=; b=qTEFjQA+ZWa4GIohyZLBhf6dmtfHsnl25E4SWLV/IwaqpRkEsq2jAq3VxXKU6Nqq7i 7RpXHaLstp+uWFyT2ctuMHgpxRK33Q9XHLfwgEzLcJmSFV6mZPolkQCZo9tkMWKZVl6H fIgsubxBzdHVRmZf9RrViMNv/ZpsqX4xid8pg+Zg9CPB0QOSJhvRuPWlV4bmY09728WF r+Jwu+SKT6trAEjFPR36xsj39JcrExL2/0oq16ND5z7jBk6O8gLlNszKSf5JxHh3UAce ER8jAxA5gq/a04qYStjb3RyJDT0rU29w91IHqfd24/QH7cpgd0gvxDe4XudTN7QpHsQ3 n/ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686664626; x=1689256626; 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=WnS7sms1LhNAN5bnRuH8G13RQ5D94Yz5Q6wFL2qjw2I=; b=hsG2riBkX3CbMlX2V6OC2o9LBvMwGrt6yUL6uCav134cck8gS3sf+tpvZwdOFuqmU8 Gq8C3sf3643eMS+LKfgSGzQXXV9jcWlYiW/ddzwghHWVk7b8PVMuPEILKfOkZu0pErSr o0cwVsB+uriexNPmEhdprDFV76/rF0IZUoms9ooVP0WucAa2I5Ovab7JzrAs4sp9vtZM TeODvSyYdbGeCadOTgzSJUJPvhXebN/Q5tSKrPyI0fZhOmiQ2GFnNKZRoGVIh7f/4Tzw 3wiQITT+RQI5E X-Gm-Message-State: AC+VfDyDtnu7IvCXpXu3ls94DYs3tuMhS2/YFAHjbh0DgCyVW6L2njH5 jS83XE6bXhiw05Qnin25ZiI= X-Google-Smtp-Source: ACHHUZ5gYO166cVa35wpeaSCu8V+Yeb2acbjblxrg4KvQSLtaZniy96TqvZxVRP3EmKzonUvhs9klw== X-Received: by 2002:a7b:cd9a:0:b0:3f8:cbd9:7724 with SMTP id y26-20020a7bcd9a000000b003f8cbd97724mr1096753wmj.16.1686664625748; Tue, 13 Jun 2023 06:57:05 -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-20020a05600c511000b003f315cee16cls419948wms.0.-pod-prod-01-eu; Tue, 13 Jun 2023 06:57:01 -0700 (PDT) X-Received: by 2002:a7b:cd12:0:b0:3f8:13b0:a665 with SMTP id f18-20020a7bcd12000000b003f813b0a665mr6119224wmj.36.1686664620880; Tue, 13 Jun 2023 06:57:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686664620; cv=none; d=google.com; s=arc-20160816; b=l0bRpNWAyjYHj07NcSBTR46eA7iwWh5exg4ysBqI7o732qquSlbH35ts4mNF+Qnxl3 +yChULOnNaUtCEm7wbJMPg8rRWZ9YmuFx6WSOyMfBs2dygm7TqfwCUtdTXhRt69knJa0 mh969IjCebBGbcYBG/M82KZKWdaUDbSItUJRRMPyA86RqvRSH+JDEN4Y02GnT6LJ4slF DY/wIjv0W0P/B9E6tGOz/xJKwSI5PzW/D5WV/uALByXNaasDyqsa6e/vmKTj5liq1UWB Bxn6bpMt2AHpV0tcjWwDCaj1h5vV84vYs6SND24lTSOo1/arKV/syqXV6Slg2ppizP42 fKYA== 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=dkEm+kjNdbXU0RB7RbBagwaiPOxl/oFzIlXTGP4W+4c=; b=wS03BsTyWbTuMXd9Qh1uffbmfTxsck0rDkb1AS2esDf5XpQEF6A1sUld1PM4jXHQZ/ oRoZA1BS6MXlCuPmUSRByUG1/CWSkZAvGHfI1agvd/SaYfoRMggu8CwXCXsPOWbKU6LR oZxkyacOqvwl7cPNk7oJyroJqXK7YPRjabnC1XIr8/x/zxHt+pC/8w4EyaCTRIOQHbdd mNaOXjlhMqjVZGSCVv+CFmNE7G71/Tyyll5/PvBSn9S94Pkxv81ZCiAOFi57qmNanutT anfmXI7JRNQWCs+lKM4tE06Cje1S56vKYHl8tyY/Wd2klE55aEHJidWunN1XRyIJt9P4 ZrSQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@broadband-forum.org header.s=google header.b=gjSLxzYA; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::634 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-x634.google.com (mail-ej1-x634.google.com. [2a00:1450:4864:20::634]) by gmr-mx.google.com with ESMTPS id h5-20020a05600c350500b003f735bd6e61si124460wmq.4.2023.06.13.06.57.00 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Jun 2023 06:57:00 -0700 (PDT) Received-SPF: pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::634 as permitted sender) client-ip=2a00:1450:4864:20::634; Original-Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-9823de726c3so121934766b.0 for ; Tue, 13 Jun 2023 06:57:00 -0700 (PDT) X-Received: by 2002:a17:907:628a:b0:982:3ee4:7062 with SMTP id nd10-20020a170907628a00b009823ee47062mr1503993ejc.57.1686664619997; Tue, 13 Jun 2023 06:56:59 -0700 (PDT) In-Reply-To: <534b2214-42e6-4be9-8b0e-537509f5be3an-/JYPxA39Uh5TLH3MbocFFw@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=gjSLxzYA; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::634 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:32798 Archived-At: --00000000000087d58d05fe033545 Content-Type: text/plain; charset="UTF-8" I think that the main thing here is that you need to operate on the Figure rather than the Image. Also note that image and figure captions are different: - An image caption is an Inlines list; https://pandoc.org/lua-filters.html#type-image - A figure caption is a Caption object, which has a long (Blocks list) caption with option short (Inlines list) caption; https://pandoc.org/lua-filters.html#type-figure I'm not quite sure when or if you should use the short figure caption, but am pretty sure that you do need to set the long figure caption. Finally, a plug for the https://github.com/pandoc-ext/logging module, which can help to shed light on the AST structure. With this document (I guessed your input format): ![Figure 1: Cat](Cat.png) ...and with this lua filter (derived from yours): local logging = require 'logging' function Figure(fig) logging.temp('figure', fig) end function Image(img) logging.temp('image', img) local 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]) local fig_num_string = string.sub( pandoc.utils.stringify(img.caption[3]),1,2) local 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 logging.temp('->', img) return img end ...you get this output: % pandoc figure.md -L figure.lua (#) image Image { attr: Attr { attributes: AttributeList {} classes: List {} identifier: "" } caption: Inlines[5] { [1] Str "Figure" [2] Space [3] Str "1:" [4] Space [5] Str "Cat" } src: "Cat.png" title: "" } (#) -> Image { attr: Attr { attributes: AttributeList {} classes: List {} identifier: "" } caption: Inlines[1] { [1] Strong { content: Inlines[1] { [1] Str "A" } } } src: "Cat.png" title: "" } (#) figure Figure { attr: Attr { attributes: AttributeList {} classes: List {} identifier: "" } caption: { long: Blocks[1] { [1] Plain { content: Inlines[5] { [1] Str "Figure" [2] Space [3] Str "1:" [4] Space [5] Str "Cat" } } } } content: Blocks[1] { [1] Plain { content: Inlines[1] { [1] Image { attr: Attr { attributes: AttributeList {} classes: List {} identifier: "" } caption: Inlines[1] { [1] Strong { content: Inlines[1] { [1] Str "A" } } } src: "Cat.png" title: "" } } } } }
A
Figure 1: Cat
On Tue, 13 Jun 2023 at 14:16, Stephan Boltzmann wrote: > 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 > > . > -- 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_xxgZwgmFNJ%2Bs60WJvnvXfk4kGg8UWPoqV2cEPPg_uBev8w%40mail.gmail.com. --00000000000087d58d05fe033545 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I think that the main thing here is that you need to opera= te on the Figure rather than the Image. Also note that image and figure cap= tions are different:=C2=A0
I= 'm not quite sure when or if you should use the short figure caption, b= ut am pretty sure that you do need to set the long figure caption.

Finally, a plug for the=C2=A0https://github.com/pandoc-ext/logging module= , which can help to shed light on the AST structure. With this document (I = guessed your input format):

![Figure 1: Cat](Cat.png)

...and wit= h this lua filter (derived from yours):

local logging =3D require 'logging'

function = Figure(fig)
=C2=A0 =C2=A0 logging.temp('figure', fig)
end
=
function Image(img)
=C2=A0 =C2=A0 logging.temp('image', img)=
=C2=A0 =C2=A0 local 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 =C2=A0 img.caption[1] =3D pandoc.Strong(img.caption[1])=C2=A0 =C2=A0 =C2=A0 =C2=A0 img.caption[3] =3D pandoc.Str(string.gsub(img= .caption[3].text, ":", "."))
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 img.caption[3] =3D pandoc.Strong(img.caption[3])
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 local fig_num_string =3D string.sub(
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 pandoc.utils.stringify(img.caption[3]),1,2)
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 local fig_num =3D math.floor(tonumber(fig_num_string))=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (fig_num > 6) then
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 img.caption[3] =3D pandoc.Strong("S" = .. tostring(8-fig_num) .. '.')
=C2=A0 =C2=A0 =C2=A0 =C2=A0 end=C2=A0 =C2=A0 =C2=A0 =C2=A0 img.caption.long =3D pandoc.Strong('A'= ;)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 img.caption =3D pandoc.Strong('A'= )
=C2=A0 =C2=A0 end
=C2=A0 =C2=A0 logging.temp('->', img)<= br>=C2=A0 =C2=A0 return img
end

...y= ou get this output:

% pan= doc figure.md -L figure.lua
(#) image Image {
=C2=A0 attr: Attr {
= =C2=A0 =C2=A0 attributes: AttributeList {}
=C2=A0 =C2=A0 classes: List {= }
=C2=A0 =C2=A0 identifier: ""
=C2=A0 }
=C2=A0 caption: = Inlines[5] {
=C2=A0 =C2=A0 [1] Str "Figure"
=C2=A0 =C2=A0 [= 2] Space
=C2=A0 =C2=A0 [3] Str "1:"
=C2=A0 =C2=A0 [4] Space=
=C2=A0 =C2=A0 [5] Str "Cat"
=C2=A0 }
=C2=A0 src: "= Cat.png"
=C2=A0 title: ""
}
(#) -> Image {
= =C2=A0 attr: Attr {
=C2=A0 =C2=A0 attributes: AttributeList {}
=C2=A0= =C2=A0 classes: List {}
=C2=A0 =C2=A0 identifier: ""
=C2= =A0 }
=C2=A0 caption: Inlines[1] {
=C2=A0 =C2=A0 [1] Strong {
=C2= =A0 =C2=A0 =C2=A0 content: Inlines[1] {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 [1] = Str "A"
=C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 }
=C2=A0 }<= br>=C2=A0 src: "Cat.png"
=C2=A0 title: ""
}
(#= ) figure Figure {
=C2=A0 attr: Attr {
=C2=A0 =C2=A0 attributes: Attri= buteList {}
=C2=A0 =C2=A0 classes: List {}
=C2=A0 =C2=A0 identifier: = ""
=C2=A0 }
=C2=A0 caption: {
=C2=A0 =C2=A0 long: Blocks= [1] {
=C2=A0 =C2=A0 =C2=A0 [1] Plain {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 co= ntent: Inlines[5] {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [1] Str "Fig= ure"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [2] Space
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 [3] Str "1:"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 [4] Space
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [5] Str "Cat&qu= ot;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 }
=C2=A0 = =C2=A0 }
=C2=A0 }
=C2=A0 content: Blocks[1] {
=C2=A0 =C2=A0 [1] Pl= ain {
=C2=A0 =C2=A0 =C2=A0 content: Inlines[1] {
=C2=A0 =C2=A0 =C2=A0= =C2=A0 [1] Image {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 attr: Attr {
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 attributes: AttributeList {}
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 classes: List {}
=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 identifier: ""
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 caption: Inlines[= 1] {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [1] Strong {
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 content: Inlines[1] {
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [1] Str "A"
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 src: "Cat.png"
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 title: ""
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
= =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 }
=C2=A0 }
}
<figure>= ;
<img src=3D"Cat.png" alt=3D"A" />
<fig= caption>Figure 1: Cat</figcaption>
</figure>
=

= On Tue, 13 Jun 2023 at 14:16, Stephan Boltzmann <stephan2boltzmann-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Hello everybody out= there using Pandoc,

The following Lua (used with = RMarkdown in RStudio) filter should put "Figure n." in bol= d at the beginning of every figure caption, but it doesn't change my ou= tput:

function Image (img)
=C2=A0 if FORMAT:match 'docx' then<= br>=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, &= quot;:", "."))
=C2=A0 =C2=A0 =C2=A0 img.caption[3] =3D pa= ndoc.Strong(img.caption[3])
=C2=A0 =C2=A0 =C2=A0 fig_num_string =3D stri= ng.sub(pandoc.utils.stringify(img.caption[3]),1,2)
=C2=A0 =C2=A0 =C2=A0 = fig_num =3D math.floor(tonumber(fig_num_string))
=C2=A0 =C2=A0 =C2=A0 if= (fig_num > 6) then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 img.caption[3] =3D pa= ndoc.Strong("S" .. tostring(8-fig_num) .. '.')
=C2=A0 = =C2=A0 =C2=A0 end
=C2=A0 =C2=A0 =C2=A0 img.caption.long =3D pandoc.Stron= g('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.stri= ngify(img.caption.long))
=C2=A0 return img
end

By put= ting print statements, I can partially verify that the filter operates on t= he 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 pandoc-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-537509f= 5be3an%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://group= s.google.com/d/msgid/pandoc-discuss/CAEe_xxgZwgmFNJ%2Bs60WJvnvXfk4kGg8UWPoq= V2cEPPg_uBev8w%40mail.gmail.com.
--00000000000087d58d05fe033545--