-
I have this markdown which causes problems during further processing and I guess is even invalid: # Hello
- ### One
- Abc
- ### Two
- Def I would like to remove the outer bullets and turn them into simple headers using a Lua filter. So I would like to get this: # Hello
### One
- Abc
### Two
- Def I managed to get to the right point but I fail to return the right thing. IIUC, if I manage to return list of headers, it would replace the bullet list. function BulletList(list)
if list.content[1][1].t == 'Header' and list.content[1][1].level == 3 then
return list.content
end
end The List {
[Header 3 ("one",[],[]) [Str "One"],BulletList [[Plain [Str "Abc"]]]],
[Header 3 ("two",[],[]) [Str "Two"],BulletList [[Plain [Str "Def"]]]]
}
Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I'm actually not sure! @tarleb should be able to answer this. |
Beta Was this translation helpful? Give feedback.
-
This is what I came up with: local function flatten (list)
local result = {}
for i, item in ipairs(list) do
for j, block in ipairs(item) do
result[#result + 1] = block
end
end
return result
end
function BulletList(list)
if list.content[1][1].t == 'Header' and list.content[1][1].level == 3 then
return flatten(list.content)
end
end Does it do what you need? |
Beta Was this translation helpful? Give feedback.
This is what I came up with:
Does it do what you need?