Is there a way to use h1 as title:
in metadata if title:
isn't specified?
#6757
-
I've got 50+ qmd files with When I render the files as html, the title gets duplicated, with 2 If I remove |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Would you be able to share the code ? I am not fully sure to understand your case. |
Beta Was this translation helpful? Give feedback.
-
I have a file like this: ---
title: "Grand Title"
author: "Pranesh Prakash"
date: 2011-01-25
standalone: true
shift-heading-level-by: 0
---
# Grand Title
Lorem.
## Heading 2
Lorem ipsum. The ---
title: "Grand Title"
author: "Pranesh Prakash"
date: 2011-01-25
standalone: true
shift-heading-level-by: -1
---
# Grand Title
Lorem.
## Heading 2
Lorem ipsum.
If I use ---
author: "Pranesh Prakash"
date: 2011-01-25
standalone: true
shift-heading-level-by: 0
---
# Grand Title
Lorem.
## Heading 2
Lorem ipsum. If I remove ---
title: "Grand Title"
author: "Pranesh Prakash"
date: 2011-01-25
standalone: true
shift-heading-level-by: 0
---
Lorem.
## Heading 2
Lorem ipsum.
What I'd like is ideally this while keeping |
Beta Was this translation helpful? Give feedback.
-
If anyone reading this wants to know how to get this done, either: local title
-- Set title from level 1 header, or
-- discard level 1 header if title is already set.
function promote_header_title (header)
if header.level >= 2 then
return header
end
if not title then
title = header.content
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_title},
{Meta = function (meta) meta.title = title; return meta end}, -- set title
} |
Beta Was this translation helpful? Give feedback.
If anyone reading this wants to know how to get this done, either:
# title
, or