From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/33126 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: primejade Newsgroups: gmane.text.pandoc Subject: latex to markdown (gfm or commonMark) Date: Sun, 17 Sep 2023 12:06:23 -0700 (PDT) Message-ID: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_12585_351078839.1694977583675" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12074"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBC5KL7VR5UNRBMM4TWUAMGQEJUJIL4I-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sun Sep 17 21:06:28 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oa1-f60.google.com ([209.85.160.60]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1qhx6C-0002w8-L3 for gtp-pandoc-discuss@m.gmane-mx.org; Sun, 17 Sep 2023 21:06:28 +0200 Original-Received: by mail-oa1-f60.google.com with SMTP id 586e51a60fabf-1d711697ae1sf258864fac.0 for ; Sun, 17 Sep 2023 12:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1694977587; x=1695582387; darn=m.gmane-mx.org; 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=jwbQm51i6XzKkLNyTAtf3WyGsxtgRAz87tz3NhjqhkE=; b=WYKuE6xVzTUU4XoH2wO9Sjx8occnQqB6SiixMGg5UTxM3JuGt86bOHIzNjJlaURGqB 7LIIPSPgrj/AxW9yaRrvUvDXWVknuHuUhgQERqPdFQpHaYQWF7RgvG5d0g53fsQKvGKh FQIgPvX4mok58Bh0a0xDHQJtuO4mGQUnhXtZwztFpK6B+ZgbALQ+TP6RIbSFouW8aD5p Dd/EU707RNFOYBAUxOnq5FFEBTDq9pXpgL/RQ3BNe4srItYgtACp06ExrcLGU2wTHo7C mUVKztUBgMKxsHl+9+24Q8u9cHkQD0FRLF+28hmKju4u7xUoh6e72uwhYr7EervbeIgt ZAQQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694977587; x=1695582387; darn=m.gmane-mx.org; 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=jwbQm51i6XzKkLNyTAtf3WyGsxtgRAz87tz3NhjqhkE=; b=HeVSCHkwVumc/bC5Xe98IMylDY7cJB6453Nxnx+a+1vCujEygFmCYRAHwdMGC8/utN Q3JRexV+kuRmFa9Ya/PeZPLXESP0iohKhG5g02qCjZ/S4sMPKDF3sPeWgc0eSkGkUm2b s0H9+m2RFoR9c7nPUCFbUBxikIwlnXEly4/NIPNk82rsHbBCfYqMkHtVeGtNbBdZBgtf qBWp/ftyb8D9VKH/OUiz5TTMZk3QziKufmvzw8iPT1NNk5GydfK6B9aRHNWS1JW0tlzM GL/1ks+V+ZYLdH595JAx3cY/QETBmWXDPKRRoScMvlvoDsLtVNhTUF+Db88MuOACO7rT 139A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694977587; x=1695582387; 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=jwbQm51i6XzKkLNyTAtf3WyGsxtgRAz87tz3NhjqhkE=; b=ti4hhnxeAct4HdUV/lb+TLH4w+vGqqnX5FMSBp8oRMaC5RgsBW9NHEO8ZzJ6O7tt4D itv32vtfNyhvMUtuAtmidBPy+L3nrNm5JM1iWWBaGfcoeaBUZrxktbj3PoJhuUPKOmS/ 79ldtjp2w/UhFB/SXiqX71YgEOzTGl2O4UrUM5AAVh3A07A2LwfWT956v59HTpZvMhLs NWpeIwCupXLgekYIfeig3ylBR1YIKxJ0poC9eO0TsGDcF7lRwF9rjXnibNrx9NpSPYMo qOLinZJSYOkkNb2BtBOjKtcLa5WzZF00l+L4Bwdg1foD4IJMahHK0vU/JVQeHx/e1Df9 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOJu0YwcpQFV09FL6+0eANBhvc+onHTZpmZGNxMBx59vrMunZby14e2O 4MtcLe22O/joaKlXuHJ0lIQ= X-Google-Smtp-Source: AGHT+IGBoRNgKF0jQ3xf51FGuRoUx5kqtLAtJ82J20rrrpwzHTCJLArAmtKAKgsKFJkijKq5dwpU7g== X-Received: by 2002:a05:6870:b010:b0:1d4:eefb:3ae5 with SMTP id y16-20020a056870b01000b001d4eefb3ae5mr6364870oae.15.1694977587518; Sun, 17 Sep 2023 12:06:27 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6870:3313:b0:1d0:e2e8:7edf with SMTP id x19-20020a056870331300b001d0e2e87edfls497985oae.1.-pod-prod-05-us; Sun, 17 Sep 2023 12:06:24 -0700 (PDT) X-Received: by 2002:a05:6870:b7ad:b0:1d5:a24a:c33 with SMTP id ed45-20020a056870b7ad00b001d5a24a0c33mr2681139oab.8.1694977584451; Sun, 17 Sep 2023 12:06:24 -0700 (PDT) X-Original-Sender: hosteam01-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:33126 Archived-At: ------=_Part_12585_351078839.1694977583675 Content-Type: multipart/alternative; boundary="----=_Part_12586_818312097.1694977583675" ------=_Part_12586_818312097.1694977583675 Content-Type: text/plain; charset="UTF-8" Hi, I have some LaTeX files which I need to convert them to Markdown (gfm or commonMark). But I need the LaTeX's \title{} (I guess metadata.title in pandoc) to be a # (h1). I have some lua filters to do a header.level shift, but I cannot add the metadata.title as a # heading. lua-filter-1: shift headings local title function promote_header(header) if header.level < 6 then header.level = header.level + 1 return header end if not title then title = header.content print(title) return {} end local msg = '[WARNING] title already set; discarding header "%s"\n' io.stderr:write(msg:format(pandoc.utils.stringify(header))) return {} end return { {Meta = function (meta) title = meta.title end}, -- init title {Header = promote_header}, {Meta = function (meta) meta.title = title; return meta end}, -- set title } lua-filter-2: append metadata.title at the beginning of the file as # function Meta(m) if m.title then local title_text = pandoc.utils.stringify(m.title) -- io.write("# " .. title_text .. "\n") end return {} end Any ideas how to achieve this? -- 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/f2ccb8c5-7628-453e-a22e-041a7fc898f7n%40googlegroups.com. ------=_Part_12586_818312097.1694977583675 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi, I have some LaTeX files which I need to convert them to Markdown (= gfm or commonMark). But I need the LaTeX's \title= {} (I guess metadata.title in pando= c) to be a # (h1). I have some lua filters to do a header.level shift, but = I cannot add the metadata.title as a # heading.

= lua-filter-1: shift headings
local title
function promote_header(header)
if header.level < 6 then
header.level =3D header.level + 1
return header
end
if not title then
title = =3D header.content
print(ti= tle)
return {}
end
local msg =3D '[WARNING] title already set; discarding header "%= s"\n'
io.stderr:write(msg:fo= rmat(pandoc.utils.stringify(header)))
{Meta =3D function (meta) title =3D meta.title end}, -- init= title
{Header =3D promote_h= eader},
{Meta =3D function (= meta) meta.title =3D title; return meta end}, -- set title
}

l= ua-filter-2: append metadata.titl= e at the beginning of the file as #
functi= on Meta(m)
if m.title then local title_text =3D pandoc.= utils.stringify(m.title)
--= io.write("# " .. title_text .. "\n")
return {}
end

Any ideas how to achi= eve this?

--
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/f2ccb8c5-7628-453e-a22e-041a7fc898f7n%40googlegroups.= com.
------=_Part_12586_818312097.1694977583675-- ------=_Part_12585_351078839.1694977583675--