From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32192 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: Fri, 17 Feb 2023 07:00:47 -0800 (PST) Message-ID: <52ada5c3-e26e-4c8c-8b3f-b55bb8ce8e1en@googlegroups.com> References: <3909f520-e8db-4cf9-900d-6a5a858c1a18n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_74_1352937144.1676646047294" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24885"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDNMLY433MCBBINNX2PQMGQE7XU6MBQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Feb 17 16:00:53 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-qk1-f185.google.com ([209.85.222.185]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pT2EG-0006HJ-PU for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 17 Feb 2023 16:00:52 +0100 Original-Received: by mail-qk1-f185.google.com with SMTP id bk26-20020a05620a1a1a00b0073b88cae2f5sf270332qkb.8 for ; Fri, 17 Feb 2023 07:00:52 -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=kc/FTK2h/+VspinRbghYGJbat2H2K3SfjD8LSn5SMQo=; b=m7b6cVQh/NEi9Aev0F1zcz1FJhhRLJOmlYj/z3q31ziIadiesGOP00RGcV6LvqKOsK OgMzJpN4vw/Z4rEbOKacLlLiktOZzjCH98j4dc5B9bZHK3JuCqvr7ViEI61qH0YT0Dzv CGzptjqXrP4QfpunKMwzUbhuJQBIylG1iuwSbvjq3/fz342JU7C/1jZXCgNVhTFkaksE JBo4MP/6ebkLkzewn+NrMcMtVCohEYvQm0hAULzZwjpW9WBJ8v5GwIlLxSG4bLM4ECWr ta1+irFqtnsELbRDOwRyD2wA+VlkNWZ/CAH8aKlEJxVMjRDesjM7w/TEd9LlhzGJafkr v62g== 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=kc/FTK2h/+VspinRbghYGJbat2H2K3SfjD8LSn5SMQo=; b=egDUw/CxX/xVOT7n8gbtWY9qOSUiBW2ZdqU3NMK3bh5+Ji1ZQfye7QJq/zxtLTJl/3 TW5CdgIF1lySHnM+I1XsFneQN6QQEfl/jTZLWQO3cjO+8TINr9bpAeSXUkmCqGJz2V3P afwgO6/xJP0FBtkoWIw/9FpPlk7ujkRrQo8v/d67mTObd04RaIiKjbl+oSZuSrtHc6CV nnvzmgjZPiDNvxV0sMysueFy/5WYk6xnVkTbEmMzO9APK9EkyJe1oF2WosmZ1MTWxmTI sK1tYL+xh39Oe6GNNSBQ3MYlNeqrKoHaRK3RgAtDA0sv4a5Oxgy0Tpov/QwDHQ9RRqcH KjXA== 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=kc/FTK2h/+VspinRbghYGJbat2H2K3SfjD8LSn5SMQo=; b=zqMECdDcPvKFRvBnSQngCrgFrxS7ZYLZbWkQ53TNZ2V0470CRwJda0mkBZh+SdEn7+ 8QtPyNckJtl1polP9TqZ/QLoBR+P+t5diVuXXJmGxfg2k/ZSTi0Z4tmtjYwaolHoK4A/ rZQeEqcReS8Rm4E+9FLZj+Pl05qf2crnte8eJxBiC1kE4cDnPocCeGqSh1VHzooi47W5 8nie2pIOiPa19+l1HOcxDyoaety6qYOgyAvQSiLPE087sVs9UCNLLktWJY/6ELiiu6zg yNWvzRn9GOkNuH4tUolBZ8W7ZXztYmGVcvKNRbpoVKuGALkm4RpCzRJF9y8bU/xCpyO5 iOeQ== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AO0yUKX55iZ8C5ovJu2BCvPkKgJA5sOpioE2+541YHPF3BvZthvJPOGw xeVm3cM/OZWjf1UTngbQ3Xk= X-Google-Smtp-Source: AK7set/N5RxAv6wHOGdr2I0FRapFEDE/xw3txN0GJR7FJowJpGuZEzVjYZybjm7hKv6YaDNQL/gCiQ== X-Received: by 2002:a05:6214:9ab:b0:56e:fbc3:2b86 with SMTP id du11-20020a05621409ab00b0056efbc32b86mr233621qvb.6.1676646051605; Fri, 17 Feb 2023 07:00:51 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:ad4:5a10:0:b0:56e:92b0:a9da with SMTP id ei16-20020ad45a10000000b0056e92b0a9dals1284889qvb.3.-pod-prod-gmail; Fri, 17 Feb 2023 07:00:48 -0800 (PST) X-Received: by 2002:a0c:a919:0:b0:56c:262e:400d with SMTP id y25-20020a0ca919000000b0056c262e400dmr104846qva.30.1676646048055; Fri, 17 Feb 2023 07:00:48 -0800 (PST) In-Reply-To: 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:32192 Archived-At: ------=_Part_74_1352937144.1676646047294 Content-Type: multipart/alternative; boundary="----=_Part_75_996183632.1676646047294" ------=_Part_75_996183632.1676646047294 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you so much...that worked - I was missing the [1].content. But let's say I have another 'Example' custom style under it... w/o Lua=20 filter it renders this structure: ```
Scope
Test body
Test nested
``` And with filter below it fails on line 8 w/ this error "Inline, list of=20 Inlines, or string expected, got Blocks"... any idea on how to troubleshoot= =20 such issues?: ``` return { { Div =3D function (div) 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 return pandoc.Header(2, div.content[1].content) end return div end, } } ``` On Friday, February 17, 2023 at 1:10:11 AM UTC-7 Bastien DUMONT wrote: > In this case, it would be preferable to turn the div into a Header elemen= t=20 > and let Pandoc format it itself: > > ``` > function Div(div) > if div.attributes['custom-style'] =3D=3D '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= : > >=20 > >=20 > > pandoc --to=3Dgfm -f docx+styles --output=3Drtb.md --extract-media=3D.= =20 > --wrap=3Dnone > > 'rtb.docx' > >=20 > >=20 > > So now we have html div that wraps our content. Let's say I want to=20 > transform > > this: > >=20 > >
> >=20 > > Scope > >=20 > >
> >=20 > > Into: > >=20 > > ## Scope > >=20 > > How can it be done? I tried to setup a Lua filter but not having succes= s=20 > to > > have it output "##" along with the div content. > >=20 > >=20 > > -- > > You received this message because you are subscribed to the Google Grou= ps > > "pandoc-discuss" group. > > To unsubscribe from this group and stop receiving emails from it, send= =20 > an email > > to [1]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit [2] > https://groups.google.com/d/msgid/ > > pandoc-discuss/3909f520-e8db-4cf9-900d-6a5a858c1a18n%40googlegroups.com= . > >=20 > > References: > >=20 > > [1] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > [2]=20 > https://groups.google.com/d/msgid/pandoc-discuss/3909f520-e8db-4cf9-900d-= 6a5a858c1a18n%40googlegroups.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/52ada5c3-e26e-4c8c-8b3f-b55bb8ce8e1en%40googlegroups.com. ------=_Part_75_996183632.1676646047294 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you so much...that worked - I was missing the [1].content.
But le= t's say I have another 'Example' custom style under it... w/o Lua filter it= renders this structure:

```
<div custom-style=3D"Internal Heading">

Scope
<= br />
</div>

<div custom-style=3D"Body Text"&g= t;

Test body

</div>

&= lt;div custom-style=3D"Example">

Test nested

=
</div>
```

And with = filter below it fails on line 8 w/ this error "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 'Internal Heading') then
return pan= doc.Header(2, div.content[1].content)
end
i= f (div.attributes['custom-style'] =3D=3D '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 Bastien = 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 'Internal Headin= g' 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=A9cri= t :
> Hi,
> We have a need to convert docx to gfm.
> Since docx has some user defined styles we use this "+styles&= quot; extension:
>=20
>=20
> pandoc --to=3Dgfm -f docx+styles --output=3Drtb.md --extract-media= =3D. --wrap=3Dnone
> 'rtb.docx'
>=20
>=20
> So now we have html div that wraps our content. =C2=A0Let's sa= y I want to transform
> this:
>=20
> <div custom-style=3D"Internal Heading">
>=20
> Scope
>=20
> </div>
>=20
> Into:
>=20
> ## Scope
>=20
> How can it be done? I tried to setup a Lua filter but not having s= uccess to
> have it output "##" along with the div content.
>=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 [1]pandoc-discus...@= googlegroups.com.
> To view this discussion on the web visit [2]https://groups.google.com/d/msgid/
> pandoc-discuss/3909f520-e8db-4cf9-900d-6a5a858c1a18n%40googlegroups.com.
>=20
> References:
>=20
> [1] mailto:pandoc-discu= s...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [2] https://groups= .google.com/d/msgid/pandoc-discuss/3909f520-e8db-4cf9-900d-6a5a858c1a18n%40= googlegroups.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/52ada5c3-e26e-4c8c-8b3f-b55bb8ce8e1en%40googlegroups.= com.
------=_Part_75_996183632.1676646047294-- ------=_Part_74_1352937144.1676646047294--