Skip to content

Commit 5e114ab

Browse files
committed
Merge branch 'main' into device_type_requirements
2 parents 4002324 + f672052 commit 5e114ab

160 files changed

Lines changed: 13702 additions & 5029 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

asciidoc/attributes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (al *AttributeList) ReadAttributes(el Element, attributes ...Attribute) (er
7070
switch positionIndex {
7171
case 0:
7272
switch el.(type) {
73-
case *InlineImage, *BlockImage, *Link, *LinkMacro, *DocumentCrossReference:
73+
case *InlineImage, *BlockImage, *Link, *LinkMacro, *DocumentCrossReference, *CrossReference:
7474
a.ImpliedName = AttributeNameAlternateText
7575
default:
7676
sa := parseShorthandAttribute(a)

asciidoc/overlay/overlay.go

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

asciidoc/overlay/state.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import (
77
)
88

99
type conditionalBlock struct {
10-
open asciidoc.Element
11-
suppress bool
10+
open asciidoc.Element
11+
suppress bool
12+
addToCell bool
1213
}
1314

1415
type overlayState struct {

0 commit comments

Comments
 (0)