-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lua - accessing div.content
in empty div changes its content
#9613
Comments
@tarleb would know about this. |
Just to add a bit to the weirdness: local div = pandoc.Div({})
print(div)
x = div.content
print(div)
print(pandoc.Div(pandoc.Blocks{}))
div.content = pandoc.Blocks{}
print(div) prints
Which makes |
Same issue with BlockQuote: local bq = pandoc.BlockQuote({})
print(bq)
x = bq.content
print(bq)
|
I'm still in the dark. What I can say so far is that the empty list is pushed correctly, it's an empty list in Lua: print(#div.content, rawlen(div.content)) -- 0 0 Also, the print(pandoc.Div(div.content)) -- Div ("",[],[]) [] So the problem must be in the way that empty lists are read back from lazy properties. Apparently the list is treated as if it was nested. That might be a hint. print(pandoc.Div(pandoc.Blocks{{}})) -- Div ("",[],[]) [Plain []] |
Also, the problem doesn't exist with local note = pandoc.Note({})
print(note)
x = note.content
print(note)
|
Found it. The issue was hidden in the Patch incoming. |
An empty list on Div, Figure, and BlockQuote elements is no longer read back as `[Plain []]`. See also: jgm/pandoc#9613
Explain the problem.
In a Lua filter, accessing the
content
field of an emptydiv
element appears to introduce an emptyPlain []
element into the content.Here's a repro:
test.md
test.lua
repro
Pandoc version?
3.1.12.3, (ARM macOS).
This appears to not be a regression, and reproduces going back to at least 2.19.2 (any other versions I tried further back would fail from a lack of a
:walk{}
method.)The text was updated successfully, but these errors were encountered: