Skip to content

Commit ae31198

Browse files
committed
Book chapter cross reference support
We need to pull the identifier up out of the title
1 parent fe7794d commit ae31198

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/resources/filters/quarto-post/render-asciidoc.lua

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,23 @@ function renderAsciidoc()
1717
Meta = function(meta)
1818
if hasMath then
1919
meta['asciidoc-stem'] = 'latexmath'
20-
return meta
2120
end
21+
22+
-- We construct the title with cross ref information into the metadata
23+
-- if we see such a title, we need to move the identifier up outside the title
24+
local titleInlines = meta['title']
25+
if #titleInlines == 1 and titleInlines[1].t == 'Span' then
26+
local span = titleInlines[1]
27+
local identifier = span.identifier
28+
if refType(identifier) == "sec" then
29+
-- this is a chapter title, tear out the id and make it ourselves
30+
local titleContents = pandoc.write(pandoc.Pandoc(span.content), "asciidoc")
31+
meta['title'] = pandoc.RawInline("asciidoc", titleContents)
32+
meta['title-prefix'] = pandoc.RawInline("asciidoc", "[[" .. identifier .. "]]")
33+
end
34+
end
35+
36+
return meta
2237
end,
2338
Math = function(el)
2439
hasMath = true;

src/resources/formats/asciidoc/pandoc/template.asciidoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
$if(titleblock)$
2+
$if(title-prefix)$
3+
$title-prefix$
4+
$endif$
25
= $title$
36
$if(by-author)$
47
$for(by-author)$$it.name.literal$$if(it.email)$ <$it.email$>$endif$$sep$; $endfor$

0 commit comments

Comments
 (0)