Lua: restore content property on Header elements

This commit is contained in:
Albert Krewinkel 2021-11-01 15:43:51 +01:00
parent 1c02145d93
commit 759aa50951
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
2 changed files with 25 additions and 0 deletions

View file

@ -340,6 +340,7 @@ getBlockContent = \case
-- inline content
Para inlns -> Actual $ ContentInlines inlns
Plain inlns -> Actual $ ContentInlines inlns
Header _ _ inlns -> Actual $ ContentInlines inlns
-- inline content
BlockQuote blks -> Actual $ ContentBlocks blks
Div _ blks -> Actual $ ContentBlocks blks
@ -357,6 +358,7 @@ setBlockContent = \case
-- inline content
Para _ -> Actual . Para . inlineContent
Plain _ -> Actual . Plain . inlineContent
Header attr lvl _ -> Actual . Header attr lvl . inlineContent
-- block content
BlockQuote _ -> Actual . BlockQuote . blockContent
Div attr _ -> Actual . Div attr . blockContent

View file

@ -245,6 +245,29 @@ return {
)
end),
},
group 'Header' {
test('access inlines via property `content`', function ()
local header = pandoc.Header(1, 'test')
assert.are_same(header.content, {pandoc.Str 'test'})
header.content = {'new text'}
assert.are_equal(header, pandoc.Header(1, 'new text'))
end),
test('access Attr via property `attr`', function ()
local header = pandoc.Header(1, 'test', {'my-test'})
assert.are_same(header.attr, pandoc.Attr{'my-test'})
header.attr = 'second-test'
assert.are_equal(header, pandoc.Header(1, 'test', 'second-test'))
end),
test('access level via property `level`', function ()
local header = pandoc.Header(3, 'test')
assert.are_same(header.level, 3)
header.level = 2
assert.are_equal(header, pandoc.Header(2, 'test'))
end),
},
group 'LineBlock' {
test('access lines via property `content`', function ()
local spc = pandoc.Space()