CR+LF and linenos in code highlight

if markdown EOL is windows style (0xD,0x0A) vs 0x0A, code highlighting failed.

eg overview-code-blocks.md file from abridge theme

Looks like we should convert them to unix style.

Can you paste the windows style in a codeblock here?

a markdown

```json,linenos
{
“no”: 1,
“name”: “Hannah Buckland”,
“age”: 50,
“tel”: “+1 (123) 456-7894”,
“email”: “hbuckland@gmail.com
}
```

if EOL are LF, Parser::new_ext@components\rendering\src\markdown.rs returns a tree with 3 events entries

  • Root
  • FencedCodeBlock
  • a string[16…126] content
0x000001E3B8E514B0  7b 0a 22 6e 6f 22 3a 20 31 2c 0a 22 6e 61 6d 65 22 3a 20  {."no": 1,."name": 
0x000001E3B8E514C3  22 48 61 6e 6e 61 68 20 42 75 63 6b 6c 61 6e 64 22 2c 0a  "Hannah Buckland",.
0x000001E3B8E514D6  22 61 67 65 22 3a 20 35 30 2c 0a 22 74 65 6c 22 3a 20 22  "age": 50,."tel": "
0x000001E3B8E514E9  2b 31 20 28 31 32 33 29 20 34 35 36 2d 37 38 39 34 22 2c  +1 (123) 456-7894",
0x000001E3B8E514FC  0a 22 65 6d 61 69 6c 22 3a 20 22 68 62 75 63 6b 6c 61 6e  ."email": "hbucklan
0x000001E3B8E5150F  64 40 67 6d 61 69 6c 2e 63 6f 6d 22 0a 7d 0a              d@gmail.com".}.

if EOL are CR+LF the returned text is

0x000001B86A57B5B0  60 60 60 6a 73 6f 6e 2c 6c 69 6e 65 6e 6f 73 0d 0a 7b 0d  ```json,linenos..{.
0x000001B86A57B5C3  0a 22 6e 6f 22 3a 20 31 2c 0d 0a 22 6e 61 6d 65 22 3a 20  ."no": 1,.."name": 
0x000001B86A57B5D6  22 48 61 6e 6e 61 68 20 42 75 63 6b 6c 61 6e 64 22 2c 0d  "Hannah Buckland",.
0x000001B86A57B5E9  0a 22 61 67 65 22 3a 20 35 30 2c 0d 0a 22 74 65 6c 22 3a  ."age": 50,.."tel":
0x000001B86A57B5FC  20 22 2b 31 20 28 31 32 33 29 20 34 35 36 2d 37 38 39 34   "+1 (123) 456-7894
0x000001B86A57B60F  22 2c 0d 0a 22 65 6d 61 69 6c 22 3a 20 22 68 62 75 63 6b  ",.."email": "hbuck
0x000001B86A57B622  6c 61 6e 64 40 67 6d 61 69 6c 2e 63 6f 6d 22 0d 0a 7d 0d  land@gmail.com"..}.
0x000001B86A57B635  0a

and event tree is now 10 nodes

  • Root
  • FencedCodeBlock
  • String[17…18] → 7b {
  • String[19…28] → 0a 22 6e 6f 22 3a 20 31 2c .“no”: 1,
  • String[29…56] → 0a 22 6e 61 6d 65 22 3a 20 22 48 61 6e 6e 61 68 20 42 75 63 6b 6c 61 6e 64 22 2c

each event while match Event::Text and each one start a block code highlighting

Looks like it’s Text events in code block start with newlines · Issue #507 · raphlinus/pulldown-cmark · GitHub ?

pulldown-cmark normalizes EOL removing ‘\r’. This split the stream into several text events.
It seems to be client responsibility to support strings split in multiple events ?!

https://github.com/raphlinus/pulldown-cmark/issues/507#issuecomment-739540021

  1. Clarify the docs to specify that text events (perhaps other events as well – HTML for example) aren’t currently guaranteed to be continuous blocks of text, and that clients may need to handle multiple events of the same type in a row to get all the text for an object. Since this is a doc change, it should be non-breaking.