@@ -29,6 +29,7 @@ _quarto.ast.add_handler({
2929 parse = function (div )
3030 preState .hasCallouts = true
3131 local caption = resolveHeadingCaption (div )
32+ local old_attr = div .attr
3233 local appearanceRaw = div .attr .attributes [" appearance" ]
3334 local icon = div .attr .attributes [" icon" ]
3435 local collapse = div .attr .attributes [" collapse" ]
@@ -42,7 +43,8 @@ _quarto.ast.add_handler({
4243 collapse = collapse ,
4344 content = div .content ,
4445 icon = icon ,
45- type = calloutType (div )
46+ type = calloutType (div ),
47+ id = div .attr .identifier ,
4648 })
4749 end ,
4850
@@ -128,6 +130,7 @@ _quarto.ast.add_handler({
128130 appearance = appearance ,
129131 icon = icon ,
130132 type = t ,
133+ id = tbl .id
131134 }
132135 end
133136})
@@ -364,9 +367,6 @@ function calloutLatex(node)
364367 local icon = node .icon
365368 local div = pandoc .Div ({})
366369
367- div .attr .attributes [" caption" ] = nil
368- div .attr .attributes [" collapse" ] = nil
369-
370370 -- generate the callout box
371371 local callout
372372 if calloutAppearance == kCalloutAppearanceDefault then
@@ -511,41 +511,6 @@ function latexCalloutBoxSimple(caption, type, icon)
511511 }
512512end
513513
514- function processCalloutDiv (div )
515-
516- local type = calloutType (div )
517- local iconDefault = true
518- local appearanceDefault = nil
519- if type == " none" then
520- iconDefault = false
521- appearanceDefault = " simple"
522- end
523-
524- local icon = div .attr .attributes [" icon" ]
525- div .attr .attributes [" icon" ] = nil
526- if icon == nil then
527- icon = option (" callout-icon" , iconDefault )
528- elseif icon == " false" then
529- icon = false
530- end
531-
532-
533- local appearanceRaw = div .attr .attributes [" appearance" ]
534- div .attr .attributes [" appearance" ] = nil
535- if appearanceRaw == nil then
536- appearanceRaw = option (" callout-appearance" , appearanceDefault )
537- end
538-
539- local appearance = nameForCalloutStyle (appearanceRaw );
540- if appearance == " minimal" then
541- icon = false
542- appearance = " simple"
543- end
544-
545- return { icon = icon , appearance = appearance }
546-
547- end
548-
549514function calloutDocx (node )
550515 local type = node .type
551516 local appearance = node .appearance
@@ -715,7 +680,7 @@ function calloutDocxSimple(node, type, hasIcon)
715680 </w:tbl>
716681 ]] )})
717682
718- local calloutContents = pandoc .List ({});
683+ local calloutContents = pandoc .List ({})
719684 tappend (calloutContents , prefix )
720685
721686 -- deal with the caption, if present
@@ -744,7 +709,6 @@ function calloutDocxSimple(node, type, hasIcon)
744709end
745710
746711function epubCallout (node )
747- local div = pandoc .Div ({})
748712 local caption = node .caption
749713 local type = node .type
750714 local calloutAppearance = node .appearance
@@ -792,16 +756,15 @@ function epubCallout(node)
792756 end
793757 attributes :insert (" callout-style-" .. calloutAppearance )
794758
795- return pandoc .Div ({calloutBody }, pandoc .Attr (div . attr . identifier , attributes ))
759+ return pandoc .Div ({calloutBody }, pandoc .Attr (node . id or " " , attributes ))
796760end
797761
798762function jatsCallout (node )
799- local div = pandoc .Div ({})
800763 local contents = resolveCalloutContents (node , true )
801764
802765 local boxedStart = ' <boxed-text>'
803- if node .attr . identifier and node .attr . identifier ~= ' ' then
804- boxedStart = " <boxed-text id='" .. node .attr . identifier .. " '>"
766+ if node .id and node .id ~= " " then
767+ boxedStart = " <boxed-text id='" .. node .id .. " '>"
805768 end
806769 contents :insert (1 , pandoc .RawBlock (' jats' , boxedStart ))
807770 contents :insert (pandoc .RawBlock (' jats' , ' </boxed-text>' ))
@@ -810,20 +773,14 @@ function jatsCallout(node)
810773end
811774
812775function simpleCallout (node )
813- local div = pandoc .Div ({})
814776 local contents = resolveCalloutContents (node , true )
815777 local callout = pandoc .BlockQuote (contents )
816- return pandoc .Div (callout , pandoc .Attr (div . attr . identifier ))
778+ return pandoc .Div (callout , pandoc .Attr (node . id or " " ))
817779end
818780
819781function resolveCalloutContents (node , requireCaption )
820- local div = node .div
821782 local caption = node .caption
822783
823- div .attr .attributes [" caption" ] = nil
824- div .attr .attributes [" icon" ] = nil
825- div .attr .attributes [" collapse" ] = nil
826-
827784 local contents = pandoc .List ({})
828785
829786 -- Add the captions and contents
@@ -837,7 +794,7 @@ function resolveCalloutContents(node, requireCaption)
837794 if caption ~= nil then
838795 contents :insert (pandoc .Para (pandoc .Strong (caption )))
839796 end
840- tappend (contents , div .content )
797+ tappend (contents , node .content )
841798
842799 return contents
843800end
0 commit comments