organic/org_mode_samples/element_container_priority
Tom Alexander 1a3e26c148
All checks were successful
rustfmt Build rustfmt has succeeded
rust-test Build rust-test has succeeded
rust-build Build rust-build has succeeded
Update plain list greater block exit matcher priority test to match blog post.
It is still testing the same thing, but I changed the contents a bit to match what is being used in my blog post.
2023-08-27 21:03:16 -04:00
..
drawer_drawer.org Add the drawer first tests. 2023-04-16 17:41:14 -04:00
drawer_dynamic_block.org Add the drawer first tests. 2023-04-16 17:41:14 -04:00
drawer_footnote_definition.org Add the drawer first tests. 2023-04-16 17:41:14 -04:00
drawer_greater_block.org Add the greater block second tests. 2023-04-16 17:33:33 -04:00
drawer_paragraph.org Add more paragraph tests. 2023-04-17 20:40:23 -04:00
drawer_plain_list.org Add the drawer first tests. 2023-04-16 17:41:14 -04:00
dynamic_block_drawer.org Add the drawer second tests. 2023-04-16 17:50:16 -04:00
dynamic_block_dynamic_block.org Add the dynamic block first tests. 2023-04-16 17:56:03 -04:00
dynamic_block_footnote_definition.org Add the dynamic block first tests. 2023-04-16 17:56:03 -04:00
dynamic_block_greater_block.org Add the greater block second tests. 2023-04-16 17:33:33 -04:00
dynamic_block_paragraph.org Add more paragraph tests. 2023-04-17 20:40:23 -04:00
dynamic_block_plain_list.org Add the dynamic block first tests. 2023-04-16 17:56:03 -04:00
footnote_definition_drawer.org Add the drawer second tests. 2023-04-16 17:50:16 -04:00
footnote_definition_dynamic_block.org Add footnote definition first tests. 2023-04-16 18:01:47 -04:00
footnote_definition_greater_block.org Add the greater block second tests. 2023-04-16 17:33:33 -04:00
greater_block_drawer.org Add greater block first tests. 2023-04-16 17:18:41 -04:00
greater_block_dynamic_block.org Add greater block first tests. 2023-04-16 17:18:41 -04:00
greater_block_footnote_definition.org Add greater block first tests. 2023-04-16 17:18:41 -04:00
greater_block_greater_block.org Add greater block first tests. 2023-04-16 17:18:41 -04:00
greater_block_paragraph.org Add more paragraph tests. 2023-04-17 20:40:23 -04:00
greater_block_plain_list.org Add greater block first tests. 2023-04-16 17:18:41 -04:00
paragraph_drawer.org It looks like paragraphs inside empty drawers just capture the first new line and then the rest are trailing whitespace capture. 2023-04-22 21:11:22 -04:00
paragraph_dynamic_block.org More paragraph tests. 2023-04-17 20:33:51 -04:00
paragraph_greater_block.org You can have a block containing only whitespace which gets matched as a paragraph whose value is just a single newline. 2023-04-18 20:58:25 -04:00
plain_list_drawer.org Identify a mistake in the plain list drawer test. 2023-04-17 17:29:35 -04:00
plain_list_dynamic_block.org Add plain list first tests. 2023-04-17 16:41:58 -04:00
plain_list_greater_block.org Update plain list greater block exit matcher priority test to match blog post. 2023-08-27 21:03:16 -04:00
plain_list_plain_list.org Add plain list first tests. 2023-04-17 16:41:58 -04:00
README.org More notes. 2023-04-17 20:53:51 -04:00
section_drawer.org Add all the section-first tests. 2023-04-16 17:06:08 -04:00
section_dynamic_block.org Add all the section-first tests. 2023-04-16 17:06:08 -04:00
section_footnote_definition.org Add all the section-first tests. 2023-04-16 17:06:08 -04:00
section_greater_block.org Add the first test. 2023-04-16 16:55:53 -04:00
section_plain_list.org Add all the section-first tests. 2023-04-16 17:06:08 -04:00
test_case_1.org Update test case 1. 2023-04-17 19:45:50 -04:00

What are the possible element containers

Sections

Sections are divided by headlines.

  Zeroth section
  * First headline
  First section
  ** Child headline
  Child section
  * Second top-level headline
  Second top-level section

Greater blocks

  #+begin_center
  elements
  #+end_center

Drawers

  :drawername:
  elements
  :end:

Dynamic blocks

  * Headline
  #+BEGIN: clocktable :scope subtree :maxlevel 2
  #+CAPTION: Clock summary at [2023-04-16 Sun 16:13]
  | Headline     | Time   |
  |--------------+--------|
  | *Total time* | *0:00* |
  #+END:

Footnote definitions

  [fn:1] A footnote definition.

  [fn:2] A multi-line

  footnote definition.

Plain Lists

  1. foo
     1. bar
  2. baz

Which container takes priority

This test interleaves the opening and closing of each element container to see which element becomes parsed vs gets broken up. The row determines the first opening element and the column determines the second opening element.

Section Greater Block Drawer Dynamic Block Footnote Definition Plain List Paragraph
Section - Section Section Section Section Section Section
Greater Block Section First First First First First First
Drawer Section First First First First First First
Dynamic Block Section First First First First First First
Footnote Definition Section First First First - - -
Plain List Section Second Second Second - - -
Paragraph Section Second Second Second - - -

Possible solutions

Greater blocks, drawers, and dynamic blocks disable plain list exit matcher

Test Case 1

  1. foo
     #+begin_center
     2. bar


     baz
     #+end_center

Parse out headlines first

Then go through elements parsing them in-order

Should paragraph exit matcher apply to the element matcher in the exit matcher

No. But paragraph exit matcher needs to apply to the object matcher.

Maybe two groups of elements: alpha and beta

When entering an alpha element, ignore beta exit matchers above this in the context.