public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* latex to markdown (gfm or commonMark)
@ 2023-09-17 19:06 primejade
  0 siblings, 0 replies; only message in thread
From: primejade @ 2023-09-17 19:06 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1471 bytes --]

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.

[-- Attachment #1.2: Type: text/html, Size: 3349 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-17 19:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-17 19:06 latex to markdown (gfm or commonMark) primejade

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).