File tree Expand file tree Collapse file tree 7 files changed +44
-0
lines changed
Expand file tree Collapse file tree 7 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,8 @@ export function asciidocFormat(): Format {
5252 plaintextFormat ( "Asciidoc" , "adoc" ) ,
5353 {
5454 pandoc : {
55+ // This is required because Pandoc is wrapping asciidoc images which must be on one line
56+ wrap : "none" ,
5557 template : formatResourcePath (
5658 "asciidoc" ,
5759 join (
Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ function processFigure(el, captionContent)
4444 tprepend (captionContent , {
4545 pandoc .RawInline (' latex' , ' \\ label{' .. label .. ' }' )
4646 })
47+ elseif _quarto .format .isAsciiDocOutput () then
48+ el .attr .identifier = label
4749 else
4850 tprepend (captionContent , figureTitlePrefix (order ))
4951 end
Original file line number Diff line number Diff line change @@ -67,6 +67,8 @@ function resolveRefs()
6767 -- for latex inject a \ref, otherwise format manually
6868 if _quarto .format .isLatexOutput () then
6969 ref :extend ({pandoc .RawInline (' latex' , ' \\ ref{' .. label .. ' }' )})
70+ elseif _quarto .format .isAsciiDocOutput () then
71+ ref :extend ({pandoc .RawInline (' asciidoc' , ' <<' .. label .. ' >>' )})
7072 else
7173 if not resolve then
7274 local refClasses = pandoc .List ({" quarto-unresolved-ref" })
Original file line number Diff line number Diff line change 1+ -- asciidoc.lua
2+ -- Copyright (C) 2020-2022 Posit Software, PBC
3+
4+ function asciidocFigure (image )
5+ local renderedCaption = pandoc .write (pandoc .Pandoc ({image .caption }))
6+ return pandoc .RawBlock (" asciidoc" , " ." .. renderedCaption .. " \n [#" .. image .attr .identifier .. " ]\n image::" .. image .src .. " []" )
7+ end
8+
9+ function asciidocDivFigure (el )
10+
11+ local figure = pandoc .List ({})
12+ local id = el .attr .identifier
13+
14+ -- append everything before the caption
15+ local contents = tslice (el .content , 1 , # el .content - 1 )
16+
17+ -- return the figure and caption
18+ local caption = refCaptionFromDiv (el )
19+ if not caption then
20+ caption = pandoc .Inlines ()
21+ end
22+ local renderedCaption = pandoc .write (pandoc .Pandoc ({caption }), " asciidoc" )
23+
24+ figure :insert (pandoc .RawBlock (' asciidoc' , ' .' .. renderedCaption ))
25+ figure :insert (pandoc .RawBlock (' asciidoc' , ' [#' .. id .. ' ]\n ' ))
26+ tappend (figure , contents )
27+ return figure
28+ end
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ function extendedFigures()
1414 return latexImageFigure (image )
1515 elseif _quarto .format .isDocxOutput () then
1616 return wpDivFigure (createFigureDiv (el , image ))
17+ elseif _quarto .format .isAsciiDocOutput () then
18+ return asciidocFigure (image )
1719 end
1820 end
1921 end ,
@@ -28,6 +30,8 @@ function extendedFigures()
2830 return wpDivFigure (el )
2931 elseif _quarto .format .isJatsOutput () then
3032 return jatsDivFigure (el )
33+ elseif _quarto .format .isAsciiDocOutput () then
34+ return asciidocDivFigure (el )
3135 end
3236 end
3337 end
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ import("./normalize/normalize.lua")
8484import (" ./normalize/parsehtml.lua" )
8585import (" ./normalize/extractquartodom.lua" )
8686
87+ import (" ./layout/asciidoc.lua" )
8788import (" ./layout/meta.lua" )
8889import (" ./layout/width.lua" )
8990import (" ./layout/latex.lua" )
Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ local function isLatexOutput()
3030 return FORMAT == " latex" or FORMAT == " beamer" or FORMAT == " pdf"
3131end
3232
33+ local function isAsciiDocOutput ()
34+ return FORMAT == " asciidoc"
35+ end
36+
3337local function isBeamerOutput ()
3438 return FORMAT == " beamer"
3539end
193197
194198
195199return {
200+ isAsciiDocOutput = isAsciiDocOutput ,
196201 isRawHtml = isRawHtml ,
197202 isRawLatex = isRawLatex ,
198203 isFormat = isFormat ,
You can’t perform that action at this time.
0 commit comments