| 1 | = Vertical vs. Horizontal Parsing in Trac Wiki = |
| 2 | |
| 3 | When one look at a Trac Wiki markup source, the primary structure one can see is along the "vertical" direction. |
| 4 | |
| 5 | Of course, one can find in nearly any text a vertical sequence of group of lines ("paragraphs"), vertically isolated lines corresponding to section titles, etc. |
| 6 | |
| 7 | But in Trac or other wiki markups, this goes further: |
| 8 | - wiki processors use "blocks" of lines (`{{{` ... `}}}`), eventually nested |
| 9 | - lists, blockquotes, definition lists all rely on a consistent indentation, |
| 10 | - citation quotes ('> ...') also stand out first in the vertical direction |
| 11 | |
| 12 | Yet the wiki parsing up to Trac 0.11 is heavily line oriented. The detection of code blocks is one exception to this, where matching `{{{` / `}}}` pairs of lines are first detected, then their content processed, even recursively if needed. |
| 13 | |
| 14 | By analyzing the structure of lines one after the other, one has to maintain a lot of state in order to keep a correct sense of context. Also the code is often fragile as it's not always obvious to decide what HTML elements have to be closed first before proceeding. |
| 15 | |
| 16 | The idea with VH parsing is that the existing vertical structure in the markup should be exploited first before tackling the horizontal parsing, which is better suited to intra-paragraph markup. |
| 17 | |
| 18 | In 0.12, the parsing of citation quotes ('> ...') now uses this approach, and this enabled to address the #4235 issue in a comprehensive way relatively painlessly. |
| 19 | |
| 20 | In future versions, the lists and other kind of markup could also benefit from this approach. |