From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32212 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ben Menashe Newsgroups: gmane.text.pandoc Subject: Re: docx -> gfm with custom styles Date: Mon, 20 Feb 2023 13:24:14 -0800 (PST) Message-ID: <32f5e6dc-baa9-4d92-a351-29bfacb7c38dn@googlegroups.com> References: <3909f520-e8db-4cf9-900d-6a5a858c1a18n@googlegroups.com> <52ada5c3-e26e-4c8c-8b3f-b55bb8ce8e1en@googlegroups.com> <5aeae8ad-aec8-4f00-b51c-9ffddf8c112fn@googlegroups.com> <085f9581-c85a-4511-ad94-ec9bca0ab8c8n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_260_1626175089.1676928254428" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25760"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDNMLY433MCBBAGKZ6PQMGQEDQ5VBHA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon Feb 20 22:24:20 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-qv1-f64.google.com ([209.85.219.64]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pUDe0-0006Us-GQ for gtp-pandoc-discuss@m.gmane-mx.org; Mon, 20 Feb 2023 22:24:20 +0100 Original-Received: by mail-qv1-f64.google.com with SMTP id pm5-20020ad446c5000000b0056eb3830243sf957561qvb.16 for ; Mon, 20 Feb 2023 13:24:20 -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=vl0J0OjXa2W1gQYL/dDQCUnw340cg+ZpDLHwKP5DkaQ=; b=QfUMjBKlCUBjJGNUzrW4+POk8Ya6bgTy0SWgnXHL9MIOwke1/6+b0MvoEtm5FQyOPT Kw64srvKO4ug9Gxl5iD3NMaBvMFUeV/aDL58ArexnFOk7GjDWNMF+X30+4VMHLHnGDni gbi9x1m3vRSi/3CfmBnVkIuf1VIegUTVl/OG4LWSnLFGpzH/yM36tz8l3VeUKDAoiWsi V36nvtDe4qBrIb2xhQCRc2gMgaZw3EhyJzPxvexif6BAjD6XgLB3nHjCC4P2ODrrTwAa Cn1KEfptjScpZ5KhCUe8oFj0lTMTqtuf484RizZiYsJK9wrO5dT3xAhb60kHwB0lMI27 uJgw== 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=vl0J0OjXa2W1gQYL/dDQCUnw340cg+ZpDLHwKP5DkaQ=; b=FJvo4epRhji/1YkyI1IhQjhVoD0/TOSSfDM9tG4c7Dai2npBnzdiOHAtw1WpkayqH+ DUg6n2YHDGQTaahl82+hi/6BBalecM/SQikmBeej6mdw0zSKYGUkfPiFvhsgrdUIotyy BrpiwRVPnKf+EEguiaH8nHogT4jvIqVPsi+VXAELRcbTN3gOxXembrSIW4vFFFCJIpW2 tT/szYz0Qe5XUI1YVhJ0+Wm8oxUCbwHyjinPkmxrhxguDJIESTJuOi4N8hnv9ivA8W98 LbS8ag/4JIeLlaWQ7LStSDh1xxmI6q/9hkh1ns0xw/iovsKf4vGk+BLVbM0KBUY5bgxM WPaw== 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=vl0J0OjXa2W1gQYL/dDQCUnw340cg+ZpDLHwKP5DkaQ=; b=8JVOGlrM4oUa1/m1YCxwA9Uu180J46EcCzKwyLKgPn7ECwf5S7o7tB5V4lEEn8UR45 ivBvuVGN2fNqZSvHW0d7wiAE4ZIDwkNfO1s75z36qbjQMtFnVe+nOH5tGF1vcVtd/r3w 3vy0D3zsWB0WdNf98cSiCKV1vpvti27lJ6ySouZtu+QPW88mx+xYVCIfToYr1rNSkkll RQAbuZPEl4lEvTt8V7nOlwGscfzN/ARr81AJlHP4hIF9mT/hDtqVhPScL0/wkqLjnyH5 9ZPX+1ikC5tddmhM0ByQHB29YO/2ACF2a1GELrP95NC/XokWEWrzn4cA3Ix4DfSowETT XxVQ== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AO0yUKXg3jLWmmSX+zYW1zJZANQyJaLRs4Bx+7f7re6DSTpxNLhkgewP Ncdg/20S8Rv0Vd/u2udoG4s= X-Google-Smtp-Source: AK7set+tsRWWrdTyXWX19E2WbCJIThX2xvKS83XUUFUD2N/5FsiHH/QCwU3py+nhngQ4gf0/eEKBSA== X-Received: by 2002:a0c:8c4b:0:b0:56e:9dfa:b0a5 with SMTP id o11-20020a0c8c4b000000b0056e9dfab0a5mr372237qvb.1.1676928259430; Mon, 20 Feb 2023 13:24:19 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6214:aae:b0:56e:9f70:6724 with SMTP id ew14-20020a0562140aae00b0056e9f706724ls1676811qvb.8.-pod-prod-gmail; Mon, 20 Feb 2023 13:24:16 -0800 (PST) X-Received: by 2002:a05:6214:3185:b0:56e:952e:23ec with SMTP id lb5-20020a056214318500b0056e952e23ecmr361590qvb.2.1676928255348; Mon, 20 Feb 2023 13:24:15 -0800 (PST) In-Reply-To: <085f9581-c85a-4511-ad94-ec9bca0ab8c8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Original-Sender: benm5678-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:32212 Archived-At: ------=_Part_260_1626175089.1676928254428 Content-Type: multipart/alternative; boundary="----=_Part_261_509032087.1676928254428" ------=_Part_261_509032087.1676928254428 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, can I pls get another bit of related advice - 1) See below implementation -- is this the cleanest approach to get it to= =20 handle errors? I'm trying to find a way to print out debug info only in=20 case of error. 2) Is there a way to access the position of AST/input file so can print it= =20 in log as well? ``` return { { Div =3D function (div) local success, res =3D pcall(function () if (div.attributes['custom-style'] =3D=3D 'Internal Heading') then return pandoc.Header(2, div.content[1].content) end if (div.attributes['custom-style'] =3D=3D 'Example') then if pandoc.utils.type(div.content[1].content) =3D=3D "Blocks" then return pandoc.Header(2, div.content[1].content[1].content) else return pandoc.Header(2, div.content[1].content) end end return div end) -- Quit processing on error if (success ~=3D true) then print("Failed to process element!\r\nError: ", res, "\r\nElement: ", div) error("Processing Exception!") else return res end end, } } ``` On Saturday, February 18, 2023 at 1:15:41 PM UTC-7 Ben Menashe wrote: > Oh sorry, there are few with same string, the one it fails one shows in= =20 > gfm like this (w/o Lua filter): > > ``` >
> > > *Example666:* > >
> ``` > > hmm, I guess I see issue, it would not work to convert as: "## > ..." --= =20 > OK, perhaps header isn't the right approach for the Example style... at= =20 > least I have some idea now how to work with it and print out debug info.= =20 > Thanks for your guidance! > > On Saturday, February 18, 2023 at 12:59:21 PM UTC-7 Bastien DUMONT wrote: > >> Sorry, I don't understand why there is a block quote in native output an= d=20 >> not in gfm. However, has a style been applied to the "Example:" string i= n=20 >> the DOCX file that triggers it to be parsed as a block quote?=20 >> >> Le Saturday 18 February 2023 =C3=A0 11:46:56AM, Ben Menashe a =C3=A9crit= :=20 >> > If I take out the Lua filter, I can see this is the result in md=20 >> file... I'm=20 >> > not sure either why it's not working.=20 >> >=20 >> >
=20 >> >=20 >> > *Example:*=20 >> >=20 >> >
=20 >> >=20 >> > On Saturday, February 18, 2023 at 12:39:39 PM UTC-7 Bastien DUMONT=20 >> wrote:=20 >> >=20 >> > Inline formatting should be preserved without any problem. The cause o= f=20 >> the=20 >> > trouble here is is that you have a block quote inside what should be= =20 >> your=20 >> > header, which IMO does not make sense.=20 >> >=20 >> > Le Saturday 18 February 2023 =C3=A0 11:26:01AM, Ben Menashe a =C3=A9cr= it :=20 >> > > Hmm, yea, I see -- it's part of large original docx, so it was=20 >> failing on=20 >> > > another element styled as Example & had italics applied.=20 >> > > I printed the div in Lua filter, when it works I see this:=20 >> > >=20 >> > > ```=20 >> > >=20 >> > > Div ("",[],[("custom-style","Example")]) [Para [Str "Test",Space,Str= =20 >> > > "example"]]=20 >> > >=20 >> > > ```=20 >> > >=20 >> > > and when fails this:=20 >> > > ```=20 >> > >=20 >> > > Div ("",[],[("custom-style","Example")]) [BlockQuote [Para [Emph [St= r=20 >> > > "Example:"]]]]=20 >> > >=20 >> > > ```=20 >> > >=20 >> > >=20 >> > > is there any clean way to approach this so it will work in a generic= =20 >> way=20 >> > and=20 >> > > preserve any other formatting applied?=20 >> > >=20 >> > > On Saturday, February 18, 2023 at 1:19:46 AM UTC-7 Bastien DUMONT=20 >> wrote:=20 >> > >=20 >> > > With your examples, I get:=20 >> > >=20 >> > > ## Scope=20 >> > >=20 >> > >
=20 >> > >=20 >> > > Test body=20 >> > >=20 >> > >
=20 >> > >=20 >> > > ## Test nested=20 >> > >=20 >> > > Le Friday 17 February 2023 =C3=A0 07:00:47AM, Ben Menashe a =C3=A9cr= it :=20 >> > > > Thank you so much...that worked - I was missing the [1].content.= =20 >> > > > But let's say I have another 'Example' custom style under it... w/= o=20 >> Lua=20 >> > > filter=20 >> > > > it renders this structure:=20 >> > > >=20 >> > > > ```=20 >> > > >
=20 >> > > >=20 >> > > > Scope=20 >> > > >=20 >> > > >
=20 >> > > >=20 >> > > >
=20 >> > > >=20 >> > > > Test body=20 >> > > >=20 >> > > >
=20 >> > > >=20 >> > > >
=20 >> > > >=20 >> > > > Test nested=20 >> > > >=20 >> > > >
=20 >> > > > ```=20 >> > > >=20 >> > > > And with filter below it fails on line 8 w/ this error "Inline,=20 >> list of=20 >> > > > Inlines, or string expected, got Blocks"... any idea on how to=20 >> > > troubleshoot=20 >> > > > such issues?:=20 >> > > >=20 >> > > > ```=20 >> > > > return {=20 >> > > > {=20 >> > > > Div =3D function (div)=20 >> > > > if (div.attributes['custom-style'] =3D=3D 'Internal Heading') then= =20 >> > > > return pandoc.Header(2, div.content[1].content)=20 >> > > > end=20 >> > > > if (div.attributes['custom-style'] =3D=3D 'Example') then=20 >> > > > return pandoc.Header(2, div.content[1].content)=20 >> > > > end=20 >> > > >=20 >> > > > return div=20 >> > > > end,=20 >> > > > }=20 >> > > > }=20 >> > > > ```=20 >> > > > On Friday, February 17, 2023 at 1:10:11 AM UTC-7 Bastien DUMONT=20 >> wrote:=20 >> > > >=20 >> > > > In this case, it would be preferable to turn the div into a Header= =20 >> > > element=20 >> > > > and let Pandoc format it itself:=20 >> > > >=20 >> > > > ```=20 >> > > > function Div(div)=20 >> > > > if div.attributes['custom-style'] =3D=3D 'Internal Heading' then= =20 >> > > > return pandoc.Header(2, div.content[1].content)=20 >> > > > end=20 >> > > > end=20 >> > > > ```=20 >> > > >=20 >> > > > Le Thursday 16 February 2023 =C3=A0 08:00:08PM, Ben Menashe a =C3= =A9crit :=20 >> > > > > Hi,=20 >> > > > > We have a need to convert docx to gfm.=20 >> > > > > Since docx has some user defined styles we use this "+styles"=20 >> > > extension:=20 >> > > > >=20 >> > > > >=20 >> > > > > pandoc --to=3Dgfm -f docx+styles --output=3Drtb.md --extract-med= ia=3D.=20 >> > --wrap=20 >> > > =3D=20 >> > > > none=20 >> > > > > 'rtb.docx'=20 >> > > > >=20 >> > > > >=20 >> > > > > So now we have html div that wraps our content. Let's say I wan= t=20 >> to=20 >> > > > transform=20 >> > > > > this:=20 >> > > > >=20 >> > > > >
=20 >> > > > >=20 >> > > > > Scope=20 >> > > > >=20 >> > > > >
=20 >> > > > >=20 >> > > > > Into:=20 >> > > > >=20 >> > > > > ## Scope=20 >> > > > >=20 >> > > > > How can it be done? I tried to setup a Lua filter but not having= =20 >> > > success=20 >> > > > to=20 >> > > > > have it output "##" along with the div content.=20 >> > > > >=20 >> > > > >=20 >> > > > > --=20 >> > > > > You received this message because you are subscribed to the=20 >> Google=20 >> > > Groups=20 >> > > > > "pandoc-discuss" group.=20 >> > > > > To unsubscribe from this group and stop receiving emails from it= ,=20 >> > send=20 >> > > an=20 >> > > > email=20 >> > > > > to [1]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org=20 >> > > > > To view this discussion on the web visit [2][1][1]https://=20 >> > > [1]groups.google.com/=20 >> > > > d/msgid/=20 >> > > > > pandoc-discuss/3909f520-e8db-4cf9-900d-6a5a858c1a18n%[2]=20 >> > > > [2][2]40googlegroups.com.=20 >> > > > >=20 >> > > > > References:=20 >> > > > >=20 >> > > > > [1] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org=20 >> > > > > [2] [3][3][3]https://groups.google.com/d/msgid/pandoc-discuss/= =20 >> > > > 3909f520-e8db-4cf9-900d-6a5a858c1a18n%[4][4]40googlegroups.com?=20 >> > utm_medium=3D=20 >> > > email&=20 >> > > > utm_source=3Dfooter=20 >> > > >=20 >> > > >=20 >> > > > --=20 >> > > > You received this message because you are subscribed to the Google= =20 >> > Groups=20 >> > > > "pandoc-discuss" group.=20 >> > > > To unsubscribe from this group and stop receiving emails from it,= =20 >> send=20 >> > an=20 >> > > email=20 >> > > > to [4]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org=20 >> > > > To view this discussion on the web visit [5][5][5]https://=20 >> > groups.google.com/=20 >> > > d/msgid/=20 >> > > > pandoc-discuss/52ada5c3-e26e-4c8c-8b3f-b55bb8ce8e1en%[6]=20 >> > > [6]40googlegroups.com.=20 >> > > >=20 >> > > > References:=20 >> > > >=20 >> > > > [1] [7][7]https://groups.google.com/d/msgid/=20 >> > > > [2] [8][8]http://40googlegroups.com/=20 >> > > > [3] [9][9]https://groups.google.com/d/msgid/pandoc-discuss/=20 >> > > 3909f520-e8db-4cf9-900d-6a5a858c1a18n%[10] >> 40googlegroups.com?utm_medium=3D=20 >> > email&=20 >> > > utm_source=3Dfooter=20 >> > > > [4] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org=20 >> > > > [5] [10][11]https://groups.google.com/d/msgid/pandoc-discuss/=20 >> > > 52ada5c3-e26e-4c8c-8b3f-b55bb8ce8e1en%[12] >> 40googlegroups.com?utm_medium=3D=20 >> > email&=20 >> > > utm_source=3Dfooter=20 >> > >=20 >> > >=20 >> > > --=20 >> > > You received this message because you are subscribed to the Google= =20 >> Groups=20 >> > > "pandoc-discuss" group.=20 >> > > To unsubscribe from this group and stop receiving emails from it,=20 >> send an=20 >> > email=20 >> > > to [11]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org=20 >> > > To view this discussion on the web visit [12][13]https://=20 >> > groups.google.com/d/msgid/=20 >> > > pandoc-discuss/ef5a0088-1df4-4540-98d5-a0120df8f3cen%[14]=20 >> > 40googlegroups.com.=20 >> > >=20 >> > > References:=20 >> > >=20 >> > > [1] [15]https://groups.google.com/=20 >> > > [2] [16]http://40googlegroups.com/=20 >> > > [3] [17]https://groups.google.com/d/msgid/pandoc-discuss/=20 >> > > [4] [18]http://40googlegroups.com/?utm_medium=3Demail&=20 >> > > [5] [19]https://groups.google.com/d/msgid/=20 >> > > [6] [20]http://40googlegroups.com/=20 >> > > [7] [21]https://groups.google.com/d/msgid/=20 >> > > [8] [22]http://40googlegroups.com/=20 >> > > [9] [23]https://groups.google.com/d/msgid/pandoc-discuss/=20 >> > 3909f520-e8db-4cf9-900d-6a5a858c1a18n% >> 40googlegroups.com?utm_medium=3Demail&=20 >> > utm_source=3Dfooter=20 >> > > [10] [24]https://groups.google.com/d/msgid/pandoc-discuss/=20 >> > 52ada5c3-e26e-4c8c-8b3f-b55bb8ce8e1en% >> 40googlegroups.com?utm_medium=3Demail&=20 >> > utm_source=3Dfooter=20 >> > > [11] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org=20 >> > > [12] [25]https://groups.google.com/d/msgid/pandoc-discuss/=20 >> > ef5a0088-1df4-4540-98d5-a0120df8f3cen% >> 40googlegroups.com?utm_medium=3Demail&=20 >> > utm_source=3Dfooter=20 >> >=20 >> >=20 >> > --=20 >> > You received this message because you are subscribed to the Google=20 >> Groups=20 >> > "pandoc-discuss" group.=20 >> > To unsubscribe from this group and stop receiving emails from it, send= =20 >> an email=20 >> > to [26]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org=20 >> > To view this discussion on the web visit [27] >> https://groups.google.com/d/msgid/=20 >> > pandoc-discuss/5aeae8ad-aec8-4f00-b51c-9ffddf8c112fn%40googlegroups.co= m.=20 >> >> >=20 >> > References:=20 >> >=20 >> > [1] http://groups.google.com/=20 >> > [2] http://40googlegroups.com/=20 >> > [3] https://groups.google.com/d/msgid/pandoc-discuss/=20 >> > [4] http://40googlegroups.com/?utm_medium=3D=20 >> > [5] https://groups.google.com/=20 >> > [6] http://40googlegroups.com/=20 >> > [7] https://groups.google.com/d/msgid/=20 >> > [8] http://40googlegroups.com/=20 >> > [9] https://groups.google.com/d/msgid/pandoc-discuss/=20 >> > [10] http://40googlegroups.com/?utm_medium=3Demail&=20 >> > [11] https://groups.google.com/d/msgid/pandoc-discuss/=20 >> > [12] http://40googlegroups.com/?utm_medium=3Demail&=20 >> > [13] https://groups.google.com/d/msgid/=20 >> > [14] http://40googlegroups.com/=20 >> > [15] https://groups.google.com/=20 >> > [16] http://40googlegroups.com/=20 >> > [17] https://groups.google.com/d/msgid/pandoc-discuss/=20 >> > [18] http://40googlegroups.com/?utm_medium=3Demail&=20 >> > [19] https://groups.google.com/d/msgid/=20 >> > [20] http://40googlegroups.com/=20 >> > [21] https://groups.google.com/d/msgid/=20 >> > [22] http://40googlegroups.com/=20 >> > [23]=20 >> https://groups.google.com/d/msgid/pandoc-discuss/3909f520-e8db-4cf9-900d= -6a5a858c1a18n%40googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter=20 >> > [24]=20 >> https://groups.google.com/d/msgid/pandoc-discuss/52ada5c3-e26e-4c8c-8b3f= -b55bb8ce8e1en%40googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter=20 >> > [25]=20 >> https://groups.google.com/d/msgid/pandoc-discuss/ef5a0088-1df4-4540-98d5= -a0120df8f3cen%40googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter=20 >> > [26] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org=20 >> > [27]=20 >> https://groups.google.com/d/msgid/pandoc-discuss/5aeae8ad-aec8-4f00-b51c= -9ffddf8c112fn%40googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter=20 >> >> --=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/32f5e6dc-baa9-4d92-a351-29bfacb7c38dn%40googlegroups.com. ------=_Part_261_509032087.1676928254428 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, can I pls get another bit of related advice -
1) See below implemen= tation -- is this the cleanest approach to get it to handle errors? I'm try= ing to find a way to print out debug info only in case of error.
= 2) Is there a way to access the position of AST/input file so can print it = in log as well?

```
retu= rn {
{
Div =3D function (div)
=C2= =A0 local success, res =3D pcall(function ()
=C2=A0 if (d= iv.attributes['custom-style'] =3D=3D 'Internal Heading') then
= =C2=A0 =C2=A0 return pandoc.Header(2, div.content[1].content)
<= div> =C2=A0 end
=C2=A0 if (div.attributes['custom-= style'] =3D=3D 'Example') then
=C2=A0 =C2=A0 if pandoc.= utils.type(div.content[1].content) =3D=3D "Blocks" then
= =C2=A0 =C2=A0 =C2=A0 return pandoc.Header(2, div.content[1].content[1].c= ontent)
=C2=A0 =C2=A0 else
=C2=A0= =C2=A0 =C2=A0 return pandoc.Header(2, div.content[1].content)
= =C2=A0 =C2=A0end
=C2=A0end

= return div
end)

-- Quit processing = on error
if (success ~=3D true) then
=C2= =A0 print("Failed to process element!\r\nError: ", res, "\r\nElement: ", di= v)
=C2=A0 error("Processing Exception!")
= else
=C2=A0 return res
end
= end,
}
}
```

<= /div>
On Saturday, February 18, 2023 at 1:15:41 PM UTC-7 Ben Menashe wrot= e:
Oh sorry, = there are few with same string, the one it fails one shows in gfm like this= (w/o Lua filter):

```
<div custo= m-style=3D"Example">

> *Example666:*

</div>
```

hmm, I guess I see issue, it would not work to= convert as: "## > ..." -- OK, perhaps header isn't the ri= ght approach for the Example style... at least I have some idea now how to = work with it and print out debug info. =C2=A0Thanks for your guidance!

On Saturday, February 18, 2023 at 12:59:21 PM UTC-7 Bastien DUMONT w= rote:
Sorry, I don'= ;t understand why there is a block quote in native output and not in gfm. H= owever, has a style been applied to the "Example:" string in the = DOCX file that triggers it to be parsed as a block quote?

Le Saturday 18 February 2023 =C3=A0 11:46:56AM, Ben Menashe a =C3=A9cri= t :
> If I take out the Lua filter, I can see this is the result in md f= ile... I'm
> not sure either why it's not working.
>=20
> <div custom-style=3D"Example">
>=20
> *Example:*
>=20
> </div>
>=20
> On Saturday, February 18, 2023 at 12:39:39 PM UTC-7 Bastien DUMONT= wrote:
>=20
> Inline formatting should be preserved without any problem. The= cause of the
> trouble here is is that you have a block quote inside what sho= uld be your
> header, which IMO does not make sense.
>=20
> Le Saturday 18 February 2023 =C3=A0 11:26:01AM, Ben Menashe a = =C3=A9crit :
> > Hmm, yea, I see -- it's part of large original docx, = so it was failing on
> > another element styled as Example & had italics appli= ed.
> > I printed the div in Lua filter, when it works I see this= :
> >
> > ```
> >
> > Div ("",[],[("custom-style","Exa= mple")]) [Para [Str "Test",Space,Str
> > "example"]]
> >
> > ```
> >
> > and when fails this:
> > ```
> >
> > Div ("",[],[("custom-style","Exa= mple")]) [BlockQuote [Para [Emph [Str
> > "Example:"]]]]
> >
> > ```
> >
> >
> > is there any clean way to approach this so it will work i= n a generic way
> and
> > preserve any other formatting applied?
> >
> > On Saturday, February 18, 2023 at 1:19:46 AM UTC-7 Bastie= n DUMONT wrote:
> >
> > With your examples, I get:
> >
> > ## Scope
> >
> > <div custom-style=3D"Body Text">
> >
> > Test body
> >
> > </div>
> >
> > ## Test nested
> >
> > Le Friday 17 February 2023 =C3=A0 07:00:47AM, Ben Menashe= a =C3=A9crit :
> > > Thank you so much...that worked - I was missing the = [1].content.
> > > But let's say I have another 'Example' c= ustom style under it... w/o Lua
> > filter
> > > it renders this structure:
> > >
> > > ```
> > > <div custom-style=3D"Internal Heading"&= gt;
> > >
> > > Scope
> > >
> > > </div>
> > >
> > > <div custom-style=3D"Body Text">
> > >
> > > Test body
> > >
> > > </div>
> > >
> > > <div custom-style=3D"Example">
> > >
> > > Test nested
> > >
> > > </div>
> > > ```
> > >
> > > And with filter below it fails on line 8 w/ this err= or "Inline, list of
> > > Inlines, or string expected, got Blocks"... any= idea on how to
> > troubleshoot
> > > such issues?:
> > >
> > > ```
> > > return {
> > > {
> > > Div =3D function (div)
> > > if (div.attributes['custom-style'] =3D=3D &#= 39;Internal Heading') then
> > > return pandoc.Header(2, div.content[1].content)
> > > end
> > > if (div.attributes['custom-style'] =3D=3D &#= 39;Example') then
> > > return pandoc.Header(2, div.content[1].content)
> > > end
> > >
> > > return div
> > > end,
> > > }
> > > }
> > > ```
> > > On Friday, February 17, 2023 at 1:10:11 AM UTC-7 Bas= tien DUMONT wrote:
> > >
> > > In this case, it would be preferable to turn the div= into a Header
> > element
> > > and let Pandoc format it itself:
> > >
> > > ```
> > > function Div(div)
> > > if div.attributes['custom-style'] =3D=3D = 9;Internal Heading' then
> > > return pandoc.Header(2, div.content[1].content)
> > > end
> > > end
> > > ```
> > >
> > > Le Thursday 16 February 2023 =C3=A0 08:00:08PM, Ben = Menashe a =C3=A9crit :
> > > > Hi,
> > > > We have a need to convert docx to gfm.
> > > > Since docx has some user defined styles we use = this "+styles"
> > extension:
> > > >
> > > >
> > > > pandoc --to=3Dgfm -f docx+styles --output=3Drtb= .md --extract-media=3D.
> --wrap
> > =3D
> > > none
> > > > 'rtb.docx'
> > > >
> > > >
> > > > So now we have html div that wraps our content.= =C2=A0Let's say I want to
> > > transform
> > > > this:
> > > >
> > > > <div custom-style=3D"Internal Heading&q= uot;>
> > > >
> > > > Scope
> > > >
> > > > </div>
> > > >
> > > > Into:
> > > >
> > > > ## Scope
> > > >
> > > > How can it be done? I tried to setup a Lua filt= er but not having
> > success
> > > to
> > > > have it output "##" along with the di= v content.
> > > >
> > > >
> > > > --
> > > > You received this message because you are subsc= ribed to the Google
> > Groups
> > > > "pandoc-discuss" group.
> > > > To unsubscribe from this group and stop receivi= ng emails from it,
> send
> > an
> > > email
> > > > to [1]pandoc-discus...@goog= legroups.com.
> > > > To view this discussion on the web visit [2][1]= [1]https://
> > [1]groups.google.com/
> > > d/msgid/
> > > > pandoc-discuss/3909f520-e8db-4cf9-900d-6a5a858c= 1a18n%[2]
> > > [2][2]40googlegroups.com<= /a>.
> > > >
> > > > References:
> > > >
> > > > [1] mailto:
pandoc-discus...= @googlegroups.com
> > > > [2] [3][3][3]https://groups.google.com/d/msgid/= pandoc-discuss/
> > > 3909f520-e8db-4cf9-900d-6a5a858c1a18n%[4][4]40googlegroups.com?
> utm_medium=3D
> > email&
> > > utm_source=3Dfooter
> > >
> > >
> > > --
> > > You received this message because you are subscribed= to the Google
> Groups
> > > "pandoc-discuss" group.
> > > To unsubscribe from this group and stop receiving em= ails from it, send
> an
> > email
> > > to [4]pandoc-discus...@googlegro= ups.com.
> > > To view this discussion on the web visit [5][5][5]ht= tps://
> groups.google.com/
> > d/msgid/
> > > pandoc-discuss/52ada5c3-e26e-4c8c-8b3f-b55bb8ce8e1en= %[6]
> > [6]40googlegroups.com.
> > >
> > > References:
> > >
> > > [1] [7][7]https://groups.google.com/d/msgid/
> > > [2] [8][8]http://40goog= legroups.com/
> > > [3] [9][9]https://groups.google.com/d/msgid/pandoc-d= iscuss/
> > 3909f520-e8db-4cf9-900d-6a5a858c1a18n%[10]40googlegroups.com?utm_medium=3D
> email&
> > utm_source=3Dfooter
> > > [4] mailto:
pandoc-discus...@goog= legroups.com
> > > [5] [10][11]https://groups.google.com/d/msgid/pandoc= -discuss/
> > 52ada5c3-e26e-4c8c-8b3f-b55bb8ce8e1en%[12]40googlegroups.com?utm_medium=3D
> email&
> > utm_source=3Dfooter
> >
> >
> > --
> > You received this message because you are subscribed to t= he Google Groups
> > "pandoc-discuss" group.
> > To unsubscribe from this group and stop receiving emails = from it, send an
> email
> > to [11]
pandoc-discus...@googlegroups.= com.
> > To view this discussion on the web visit [12][13]https://
> groups.google.com/d= /msgid/
> > pandoc-discuss/ef5a0088-1df4-4540-98d5-a0120df8f3cen%[14]
> 40googlegroups.com.
> >
> > References:
> >
> > [1] [15]https://groups.googl= e.com/
> > [2] [16]http://40googlegroup= s.com/
> > [3] [17]https://groups.google.com/d/msgid/pandoc-discuss/=
> > [4] [18]http://40googlegroups.com/?utm_medium=3Demail&am= p;
> > [5] [19]http= s://groups.google.com/d/msgid/
> > [6] [20]http://40googlegroup= s.com/
> > [7] [21]http= s://groups.google.com/d/msgid/
> > [8] [22]http://40googlegroup= s.com/
> > [9] [23]https://groups.google.com/d/msgid/pandoc-discuss/=
> 3909f520-e8db-4cf9-900d-6a5a858c1a18n%40googlegroups.com?utm_med= ium=3Demail&
> utm_source=3Dfooter
> > [10] [24]https://groups.google.com/d/msgid/pandoc-discuss= /
> 52ada5c3-e26e-4c8c-8b3f-b55bb8ce8e1en%40googlegroups.com?utm_med= ium=3Demail&
> utm_source=3Dfooter
> > [11] mailto:pandoc-discus...@googlegr= oups.com
> > [12] [25]https://groups.google.com/d/msgid/pandoc-discuss= /
> ef5a0088-1df4-4540-98d5-a0120df8f3cen%40googlegroups.com?utm_med= ium=3Demail&
> utm_source=3Dfooter
>=20
>=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 [26]pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
> To view this discussion on the web visit [27]https://groups.google.com/d/msgid/
> pandoc-discuss/5aeae8ad-aec8-4f00-b51c-9ffddf8c112fn%40googlegroups.com.
>=20
> References:
>=20
> [1] http://groups.google.com/
> [2] http://40googlegroups.com/
> [3] https://groups.google.com/d/msgid/pandoc-discuss/
> [4] http:= //40googlegroups.com/?utm_medium=3D
> [5] https://groups.google.com/
> [6] http://40googlegroups.com/
> [7] https://groups.= google.com/d/msgid/
> [8] http://40googlegroups.com/
> [9] https://groups.google.com/d/msgid/pandoc-discuss/
> [10] http://40googlegroups.com/?utm_medium=3Demail&
> [11] https://groups.google.com/d/msgid/pandoc-discuss/
> [12] http://40googlegroups.com/?utm_medium=3Demail&
> [13] https://groups.= google.com/d/msgid/
> [14] http://40googlegroups.com/
> [15] https://groups.google.com/
> [16] http://40googlegroups.com/
> [17] https://groups.google.com/d/msgid/pandoc-discuss/
> [18] http://40googlegroups.com/?utm_medium=3Demail&
> [19] https://groups.= google.com/d/msgid/
> [20] http://40googlegroups.com/
> [21] https://groups.= google.com/d/msgid/
> [22] http://40googlegroups.com/
> [23] https://group= s.google.com/d/msgid/pandoc-discuss/3909f520-e8db-4cf9-900d-6a5a858c1a18n%4= 0googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter
> [24] https://group= s.google.com/d/msgid/pandoc-discuss/52ada5c3-e26e-4c8c-8b3f-b55bb8ce8e1en%4= 0googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter
> [25] https://group= s.google.com/d/msgid/pandoc-discuss/ef5a0088-1df4-4540-98d5-a0120df8f3cen%4= 0googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter
> [26] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<= /a>
> [27]
https://group= s.google.com/d/msgid/pandoc-discuss/5aeae8ad-aec8-4f00-b51c-9ffddf8c112fn%4= 0googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter

--
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/32f5e6dc-baa9-4d92-a351-29bfacb7c38dn%40googlegroups.= com.
------=_Part_261_509032087.1676928254428-- ------=_Part_260_1626175089.1676928254428--