mobiledoc-kit icon indicating copy to clipboard operation
mobiledoc-kit copied to clipboard

Error in the order of markup opening

Open randohinn opened this issue 5 years ago • 1 comments

I am tesing my renderer, and seem to have uncovered an error, in at a bare minimum, your demo site - have yet not tested standalone

MCVE:

Writing "Hello world", with Hello in bold, and from the o in Hello, to the end of the string also italicized, gives this mobiledoc:

{
  "version": "0.3.1",
  "atoms": [],
  "cards": [],
  "markups": [
    [
      "strong"
    ],
    [
      "em"
    ]
  ],
  "sections": [
    [
      1,
      "p",
      [
        [
          0,
          [
            0
          ],
          1,
          "Hell"
        ],
        [
          0,
          [
            1,
            0
          ],
          1,
          "o"
        ],
        [
          0,
          [],
          1,
          " world"
        ]
      ]
    ]
  ]
}

The error is in the opened markups of

[
          0,
          [
            1,
            0
          ],
          1,
          "o"
        ],

As it is this way, and markups are closed in the order of opening, the em tag gets closed first and the "world" part of the text remains bold, not italic.. Manually swapping the 1 and 0 there causes a correct output.

randohinn avatar Sep 21 '18 20:09 randohinn

I think you are probably reading the diff wrong.

The example with the error reads as follows:

  1. add markup 1 (em) on the stack (Stack: em)
  2. add markup 0 (strong) on the stack (Stack: em > strong)
  3. render text (Stack: em > strong)
  4. close 1 markup, which is strong as it is at the top of the stack (Stack: em).

Which looks correct to me?

apfelbox avatar Oct 31 '18 01:10 apfelbox

This is working correctly

gpoitch avatar Aug 11 '22 16:08 gpoitch