From my labelled-lists filter (https://github.com/dialoa/dialectica-filters/blob/main/labelled-lists/labelled-lists.lua), here is a filter + function that checks whether every item in a bullet list starts with a Span element. ```lua --- is_custom_labelled_list: Look for custom labels markup -- Custom label markup requires each item starting with a span -- containing the label -- @param element pandoc BulletList element function is_custom_labelled_list (element) local is_cl_list = true -- the content of BulletList is a List of List of Blocks for _,blocks in ipairs(element.c) do -- check that the first element of the first block is Span if not( blocks[1].c[1].t == 'Span' ) then is_cl_list = false break end end return is_cl_list end return {{ BulletList = function(element) if is_custom_labelled_list(element) then return pandoc.Para(pandoc.Str('Was a list of the required kind!))) end end, }} ``` The difficulty with manipulating lists is to follow their intricate structure: a BulletList element as a content (element.c) that is a pandoc List. Each item in it (element.c[1], element.c[2]) is of Blocks type, i.e. a pandoc.List where the each element is a block. In your case you should check that the list item only contains one block of type ordered list: if #elem.c[i] == 1 then list_item_contains_one_block_only = true end and check that this block is of type OrderedList: if #elem.c[i]==1 and elem.c[i].t == 'OrderedList' then ... you should then add that block to the previous item, and remove the current item. Hope this helps, J On Saturday, February 25, 2023 at 10:06:45 PM UTC JDTS wrote: > Thanks. Any pointers to lua filters that do something similar? > > On Saturday, February 25, 2023 at 10:01:08 AM UTC-5 Julien Dutant wrote: > >> Looks feasible. Pandoc converts the first html to: >> >> [ BulletList >> [ [ Plain >> [ ... Inlines ] >> ] >> , [ BulletList >> [ [ Plain >> [ ... Inlines ] >> ] >> , [ Plain >> [ ... Inlines ] >> ] >> ] >> ] >> , [ Plain >> [ Inlines ] >> ] >> ] >> ] >> >> I.e., the sublist is converted to its own list item. So the filter should >> pick up list, check if any item within them consists of a lone sublist, and >> if so, move it to the previous item. (And best, apply the filter >> recursively to that sublist itself.) >> >> On Saturday, February 25, 2023 at 2:26:04 PM UTC JDTS wrote: >> >>> The Apple Notes app produces (via AppleScript) HTML for notes with >>> nested lists structured like: >>> >>> >>> >>> As you can see, the sublist is incorrectly positioned. It should be >>> positioned *within* the
  • Level 1 element 1 item, ala: >>> >>> >>> >>> Is there a straightforward way with Lua filters to fix this at the AST >>> level, for arbitrary-depth sublist nesting? >>> >> -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/80183457-60c8-4fc3-aa16-13d2f93104f1n%40googlegroups.com.