Skip to content

Allowed Headings

Nicholas Hoyt edited this page Jun 28, 2019 · 19 revisions

The scenarios for which decisions are needed

This document details the various scenarios we account for in the new Heading / Paragraph algorithm that includes a look-ahead feature used in determining which heading levels are allowed for a particular situation.

We label the scenarios by referencing the index values indexPrev and indexNext, which correspond to the indices for the previous and next heading, respectively, relative to the headings array [h1, h2, h3, h4, h5, h6]. For example, the index for h2 is 1.

The following are the three scenarios with example cases:

indexPrev < indexNext

  • Cursor is between h3 and h4

    • Old: h1, h2, h3, h4
    • New: h3, h4
  • Cursor is between h3 and h5

    • Old: h1, h2, h3, h4
    • New: h3, h4, h5
  • Cursor is between h3 and h6

    • Old: h1, h2, h3, h4
    • New: h3, h4, h5, h6

indexPrev == indexNext

  • Cursor is between h4 and h4

    • Old: h1, h2, h3, h4, h5
    • New: h3, h4, h5

indexPrev > indexNext

  • Cursor is between h4 and h3

    • Old: h1, h2, h3, h4, h5
    • New: h2, h3, h4, h5
  • Cursor is between h5 and h3

    • Old: h1, h2, h3, h4, h5, h6
    • New: h2, h3, h4, h5, h6
  • Cursor is between h6 and h3

    • Old: h1, h2, h3, h4, h5, h6
    • New: h2, h3, h4, h5, h6

Clone this wiki locally