mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-01 05:33:41 +08:00
Lua: add normalize function to *Pandoc* objects
This function performs a normalization of Pandoc documents. E.g., multiple successive spaces are collapsed, and tables are normalized such that all rows and columns contain the same number of cells. Closes: #10356
This commit is contained in:
@@ -1039,6 +1039,24 @@ equal in Lua if and only if they are equal in Haskell.
|
||||
`meta`
|
||||
: document meta information ([Meta] object)
|
||||
|
||||
### Methods {#type-pandoc-methods}
|
||||
|
||||
#### normalize
|
||||
|
||||
`normalize(self)`
|
||||
|
||||
Perform a normalization of Pandoc documents. E.g., multiple
|
||||
successive spaces are collapsed, and tables are normalized, so
|
||||
that all rows and columns contain the same number of cells.
|
||||
|
||||
Parameters:
|
||||
|
||||
`self`
|
||||
: the element ([Pandoc][])
|
||||
|
||||
Results:
|
||||
|
||||
- cloned and normalized document. ([Pandoc][])
|
||||
|
||||
### walk {#type-pandoc:walk}
|
||||
|
||||
|
||||
@@ -164,6 +164,13 @@ return {
|
||||
assert.are_same(meta.test, {pandoc.Plain{pandoc.Str 'check'}})
|
||||
end),
|
||||
},
|
||||
group 'Pandoc' {
|
||||
test('normalize', function ()
|
||||
local doc = pandoc.Pandoc({{'a', pandoc.Space(), pandoc.Space(), 'b'}})
|
||||
local normalized = pandoc.Pandoc({{'a', pandoc.Space(), 'b'}})
|
||||
assert.are_equal(normalized, doc:normalize())
|
||||
end),
|
||||
},
|
||||
group 'Other types' {
|
||||
group 'ReaderOptions' {
|
||||
test('returns a userdata value', function ()
|
||||
|
||||
Reference in New Issue
Block a user