Skip to content

Commit

Permalink
feat(parser/renderer): support 'header' and 'footer' options in tables (
Browse files Browse the repository at this point in the history
bytesparadise#862)

Supports the shorthand (`%header%footer`) syntax and the explicit
one (`options="header,footer"`)

also, fixes a bug in column settings when multiplier is used

Fixes bytesparadise#861

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon authored Nov 21, 2021
1 parent efe9f73 commit f1156b7
Show file tree
Hide file tree
Showing 12 changed files with 570 additions and 56 deletions.
27 changes: 27 additions & 0 deletions pkg/parser/attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,12 +522,39 @@ var _ = DescribeTable("valid block attributes",
},
),

// options (explicit)
Entry(`[options=header]`, `[options=header]`,
types.Attributes{
types.AttrOptions: []interface{}{"header"},
},
),
Entry(`[options="header,footer"]`, `[options="header,footer"]`,
types.Attributes{
types.AttrOptions: []interface{}{"header", "footer"},
},
),

// option shorthand
Entry(`[%hardbreaks]`, `[%hardbreaks]`,
types.Attributes{
types.AttrOptions: []interface{}{"hardbreaks"},
},
),
Entry(`[%header]`, `[%header]`,
types.Attributes{
types.AttrOptions: []interface{}{"header"},
},
),
Entry(`[%footer]`, `[%footer]`,
types.Attributes{
types.AttrOptions: []interface{}{"footer"},
},
),
Entry(`[%header%footer]`, `[%header%footer]`,
types.Attributes{
types.AttrOptions: []interface{}{"header", "footer"},
},
),

// id (alone)
Entry(`[#an_id]`, `[#an_id]`,
Expand Down
5 changes: 5 additions & 0 deletions pkg/parser/document_processing_apply_substitutions.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ func applySubstitutionsOnBlockWithElements(ctx *ParseContext, block types.BlockW
return err
}
}
if b.Footer != nil {
if err = s.processBlockWithElements(ctx, b.Footer, opts...); err != nil {
return err
}
}
}
if err := s.processBlockWithElements(ctx, block, opts...); err != nil {
return err
Expand Down
Loading

0 comments on commit f1156b7

Please sign in to comment.