@@ -123,17 +123,17 @@ func preparseFile(cxt OverlayContext, pps *overlayFileState, d *asciidoc.Documen
123123 }
124124 remove = true
125125 case * asciidoc.IfDef :
126- suppressStack .Push (& conditionalBlock {suppress : suppress , open : el })
126+ suppressStack .Push (& conditionalBlock {suppress : suppress , open : el , addToCell : addToCell })
127127 suppress = suppress || ! el .Eval (pps )
128128 remove = true
129- addToCell = el .Inline
129+ addToCell = el .Inline || isContentIfDef ( parent , index )
130130 case * asciidoc.IfNDef :
131- suppressStack .Push (& conditionalBlock {suppress : suppress , open : el })
131+ suppressStack .Push (& conditionalBlock {suppress : suppress , open : el , addToCell : addToCell })
132132 suppress = suppress || ! el .Eval (pps )
133133 remove = true
134- addToCell = el .Inline
134+ addToCell = el .Inline || isContentIfDef ( parent , index )
135135 case * asciidoc.IfEval :
136- suppressStack .Push (& conditionalBlock {suppress : suppress , open : el })
136+ suppressStack .Push (& conditionalBlock {suppress : suppress , open : el , addToCell : addToCell })
137137 if ! suppress {
138138 var include bool
139139 include , err = el .Eval (pps )
@@ -144,7 +144,7 @@ func preparseFile(cxt OverlayContext, pps *overlayFileState, d *asciidoc.Documen
144144 suppress = ! include
145145 }
146146 remove = true
147- addToCell = el .Inline
147+ addToCell = el .Inline || isContentIfDef ( parent , index )
148148 case * asciidoc.IfDefBlock , * asciidoc.IfNDefBlock , * asciidoc.IfEvalBlock :
149149 err = fmt .Errorf ("unexpected type in preparse: %T" , el )
150150 should = parse .SearchShouldStop
@@ -163,7 +163,7 @@ func preparseFile(cxt OverlayContext, pps *overlayFileState, d *asciidoc.Documen
163163 }
164164 suppress = cb .suppress
165165 remove = true
166- addToCell = false
166+ addToCell = cb . addToCell
167167 case * asciidoc.InlineIfDef :
168168 if ! suppress {
169169 if el .Eval (pps ) {
@@ -365,3 +365,26 @@ func parseLevelOffset(el asciidoc.Parent, elements asciidoc.Elements) (leveloffs
365365 leveloffset , relative , err = text .ParseRelativeNumber (val )
366366 return
367367}
368+
369+ func isContentIfDef (parent asciidoc.ParentElement , index int ) bool {
370+ if _ , ok := parent .(* asciidoc.Table ); ! ok {
371+ return false
372+ }
373+ children := parent .Children ()
374+ depth := 0
375+ for i := index + 1 ; i < len (children ); i ++ {
376+ child := children [i ]
377+ switch child .(type ) {
378+ case * asciidoc.IfDef , * asciidoc.IfNDef , * asciidoc.IfEval :
379+ depth ++
380+ case * asciidoc.EndIf :
381+ if depth == 0 {
382+ return true
383+ }
384+ depth --
385+ case * asciidoc.TableRow :
386+ return false
387+ }
388+ }
389+ return false
390+ }
0 commit comments