@mdsvex/parse 1.0.0-next.0 → 1.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +213 -0
- package/WIRE_FORMAT.md +5 -1
- package/dist/buf-utils.js +23 -23
- package/dist/buf_utils.d.ts +1 -1
- package/dist/cursor.d.ts +17 -13
- package/dist/cursor.js +118 -31
- package/dist/main.d.ts +362 -26
- package/dist/main.js +5841 -3420
- package/dist/node_view-bvM0i0-p.js +407 -0
- package/dist/node_view.d.ts +11 -12
- package/dist/opcodes.d.ts +23 -6
- package/dist/plugin_dispatch.d.ts +22 -8
- package/dist/tree-builder.js +185 -66
- package/dist/tree_builder.d.ts +42 -11
- package/dist/undo_log.d.ts +11 -1
- package/dist/utils.d.ts +77 -51
- package/dist/utils.js +687 -209
- package/dist/wire-tree-builder.js +69 -71
- package/dist/wire_tree_builder.d.ts +4 -7
- package/package.json +1 -1
- package/src/buf_utils.ts +10 -14
- package/src/cursor.ts +74 -57
- package/src/main.ts +9898 -5593
- package/src/node_view.ts +159 -140
- package/src/opcodes.ts +39 -7
- package/src/plugin_dispatch.ts +328 -219
- package/src/tree_builder.ts +278 -98
- package/src/undo_log.ts +58 -24
- package/src/utils.spec.ts +86 -9
- package/src/utils.ts +769 -392
- package/src/wire_emitter.ts +6 -0
- package/src/wire_tree_builder.ts +39 -52
- package/test/block_quotes.spec.ts +78 -7
- package/test/code_spans.spec.ts +158 -6
- package/test/crlf.spec.ts +49 -1
- package/test/directives.spec.ts +530 -1
- package/test/emphasis.spec.ts +10 -4
- package/test/fixtures/pfm/block_quotes/pfm_fence_close.md +4 -0
- package/test/fixtures/pfm/block_quotes/pfm_fence_close_compact.md +4 -0
- package/test/fixtures/pfm/block_quotes/pfm_fence_close_end_quote.md +5 -0
- package/test/fixtures/pfm/block_quotes/pfm_fence_close_info.md +5 -0
- package/test/fixtures/pfm/block_quotes/pfm_fence_close_longer.md +4 -0
- package/test/fixtures/pfm/block_quotes/pfm_fence_close_nested.md +3 -0
- package/test/fixtures/pfm/block_quotes/pfm_fence_close_twice.md +6 -0
- package/test/fixtures/pfm/block_quotes/pfm_fence_info_eof.md +1 -0
- package/test/fixtures/pfm/block_quotes/pfm_fence_unclosed.md +2 -0
- package/test/fixtures/pfm/code_spans/pfm_328_5.md +1 -0
- package/test/fixtures/pfm/code_spans/pfm_328_6.md +1 -0
- package/test/fixtures/pfm/code_spans/pfm_328_7.md +1 -0
- package/test/fixtures/pfm/code_spans/pfm_328_8.md +1 -0
- package/test/fixtures/pfm/code_spans/pfm_328_9.md +2 -0
- package/test/fixtures/pfm/fenced_code_blocks/pfm_info_eof.md +1 -0
- package/test/fixtures/pfm/fenced_code_blocks/pfm_info_eof_no_lf.md +1 -0
- package/test/fixtures/pfm/generic_directives/106.md +1 -0
- package/test/fixtures/pfm/generic_directives/107.md +3 -0
- package/test/fixtures/pfm/generic_directives/108.md +1 -0
- package/test/fixtures/pfm/generic_directives/109.md +1 -0
- package/test/fixtures/pfm/generic_directives/110.md +1 -0
- package/test/fixtures/pfm/generic_directives/111.md +1 -0
- package/test/fixtures/pfm/generic_directives/112.md +1 -0
- package/test/fixtures/pfm/generic_directives/113.md +1 -0
- package/test/fixtures/pfm/generic_directives/114.md +2 -0
- package/test/fixtures/pfm/generic_directives/115.md +1 -0
- package/test/fixtures/pfm/generic_directives/116.md +6 -0
- package/test/fixtures/pfm/generic_directives/117.md +3 -0
- package/test/fixtures/pfm/generic_directives/118.md +6 -0
- package/test/fixtures/pfm/generic_directives/119.md +3 -0
- package/test/fixtures/pfm/generic_directives/120.md +5 -0
- package/test/fixtures/pfm/generic_directives/121.md +3 -0
- package/test/fixtures/pfm/generic_directives/122.md +4 -0
- package/test/fixtures/pfm/generic_directives/123.md +2 -0
- package/test/html.spec.ts +44 -1
- package/test/html_block_containers.spec.ts +445 -0
- package/test/incremental.spec.ts +271 -0
- package/test/lists.spec.ts +107 -1
- package/test/parser_reuse.spec.ts +40 -0
- package/test/plugins.spec.ts +196 -226
- package/test/print.ts +2 -3
- package/test/run_bytecode.spec.ts +36 -0
- package/test/snapshots/hybrid/component-children.snap.ast +9 -16
- package/test/snapshots/hybrid/component-simple-00.snap.ast +1 -2
- package/test/snapshots/hybrid/component-simple-01.snap.ast +1 -2
- package/test/snapshots/hybrid/component-simple-03.snap.ast +13 -13
- package/test/snapshots/hybrid/component-simple-04.snap.ast +1 -2
- package/test/snapshots/hybrid/error.snap.ast +1 -2
- package/test/snapshots/markdown/blockquote-nested-markdown.snap.ast +2 -1
- package/test/snapshots/markdown/emphasis.snap.ast +2 -2
- package/test/snapshots/markdown/encodeHTMLCodeTags.snap.ast +1 -2
- package/test/snapshots/markdown/github-style-codeblock-inside-quote.snap.ast +8 -1
- package/test/snapshots/markdown/html-comments.snap.ast +11 -13
- package/test/snapshots/markdown/html5-strutural-tags.snap.ast +16 -31
- package/test/snapshots/markdown/line-starts-with-html.snap.ast +5 -6
- package/test/snapshots/markdown/literal-html-tags.snap.ast +11 -14
- package/test/snapshots/markdown/nested-blockquote.snap.ast +3 -3
- package/test/snapshots/markdown/pre-code-tags.snap.ast +5 -8
- package/test/snapshots/pfm/block_quotes/237.snap.ast +1 -2
- package/test/snapshots/pfm/block_quotes/251.snap.ast +5 -5
- package/test/snapshots/pfm/block_quotes/pfm_fence_close.snap.ast +6 -0
- package/test/snapshots/pfm/block_quotes/pfm_fence_close_compact.snap.ast +6 -0
- package/test/snapshots/pfm/block_quotes/pfm_fence_close_end_quote.snap.ast +8 -0
- package/test/snapshots/pfm/block_quotes/pfm_fence_close_info.snap.ast +4 -0
- package/test/snapshots/pfm/block_quotes/pfm_fence_close_longer.snap.ast +6 -0
- package/test/snapshots/pfm/block_quotes/pfm_fence_close_nested.snap.ast +5 -0
- package/test/snapshots/pfm/block_quotes/pfm_fence_close_twice.snap.ast +5 -0
- package/test/snapshots/pfm/block_quotes/pfm_fence_info_eof.snap.ast +3 -0
- package/test/snapshots/pfm/block_quotes/pfm_fence_unclosed.snap.ast +3 -0
- package/test/snapshots/pfm/code_spans/344.snap.ast +1 -1
- package/test/snapshots/pfm/code_spans/347.snap.ast +1 -2
- package/test/snapshots/pfm/code_spans/pfm_328_5.snap.ast +6 -0
- package/test/snapshots/pfm/code_spans/pfm_328_6.snap.ast +6 -0
- package/test/snapshots/pfm/code_spans/pfm_328_7.snap.ast +6 -0
- package/test/snapshots/pfm/code_spans/pfm_328_8.snap.ast +8 -0
- package/test/snapshots/pfm/code_spans/pfm_328_9.snap.ast +10 -0
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/417.snap.ast +2 -2
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/438.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/441.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/444.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/445.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/450.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/453.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/456.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/457.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/473.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/475.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/476.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/477.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/478.snap.ast +3 -4
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/479.snap.ast +3 -4
- package/test/snapshots/pfm/fenced_code_blocks/126.snap.ast +1 -2
- package/test/snapshots/pfm/fenced_code_blocks/pfm_info_eof.snap.ast +2 -0
- package/test/snapshots/pfm/fenced_code_blocks/pfm_info_eof_no_lf.snap.ast +2 -0
- package/test/snapshots/pfm/generic_directives/011.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/015.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/016.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/017.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/019.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/020.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/030.snap.ast +4 -6
- package/test/snapshots/pfm/generic_directives/034.snap.ast +6 -2
- package/test/snapshots/pfm/generic_directives/036.snap.ast +5 -1
- package/test/snapshots/pfm/generic_directives/038.snap.ast +6 -2
- package/test/snapshots/pfm/generic_directives/039.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/040.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/044.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/046.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/089.snap.ast +1 -1
- package/test/snapshots/pfm/generic_directives/103.snap.ast +6 -2
- package/test/snapshots/pfm/generic_directives/106.snap.ast +9 -0
- package/test/snapshots/pfm/generic_directives/107.snap.ast +9 -0
- package/test/snapshots/pfm/generic_directives/108.snap.ast +5 -0
- package/test/snapshots/pfm/generic_directives/109.snap.ast +4 -0
- package/test/snapshots/pfm/generic_directives/110.snap.ast +10 -0
- package/test/snapshots/pfm/generic_directives/111.snap.ast +7 -0
- package/test/snapshots/pfm/generic_directives/112.snap.ast +18 -0
- package/test/snapshots/pfm/generic_directives/113.snap.ast +7 -0
- package/test/snapshots/pfm/generic_directives/114.snap.ast +12 -0
- package/test/snapshots/pfm/generic_directives/115.snap.ast +10 -0
- package/test/snapshots/pfm/generic_directives/116.snap.ast +13 -0
- package/test/snapshots/pfm/generic_directives/117.snap.ast +9 -0
- package/test/snapshots/pfm/generic_directives/118.snap.ast +10 -0
- package/test/snapshots/pfm/generic_directives/119.snap.ast +9 -0
- package/test/snapshots/pfm/generic_directives/120.snap.ast +12 -0
- package/test/snapshots/pfm/generic_directives/121.snap.ast +3 -0
- package/test/snapshots/pfm/generic_directives/122.snap.ast +3 -0
- package/test/snapshots/pfm/generic_directives/123.snap.ast +3 -0
- package/test/snapshots/pfm/hard_line_breaks/642.snap.ast +1 -1
- package/test/snapshots/pfm/hard_line_breaks/643.snap.ast +1 -1
- package/test/snapshots/pfm/html/148.snap.ast +1 -1
- package/test/snapshots/pfm/html/150.snap.ast +1 -1
- package/test/snapshots/pfm/html/159.snap.ast +2 -3
- package/test/snapshots/pfm/html/162.snap.ast +3 -4
- package/test/snapshots/pfm/html/163.snap.ast +1 -1
- package/test/snapshots/pfm/html/164.snap.ast +3 -4
- package/test/snapshots/pfm/html/166.snap.ast +1 -1
- package/test/snapshots/pfm/html/168.snap.ast +2 -3
- package/test/snapshots/pfm/html/169.snap.ast +5 -7
- package/test/snapshots/pfm/html/174.snap.ast +3 -3
- package/test/snapshots/pfm/html/182.snap.ast +1 -1
- package/test/snapshots/pfm/html/613.snap.ast +2 -2
- package/test/snapshots/pfm/html/615.snap.ast +2 -2
- package/test/snapshots/pfm/images/585.snap.ast +1 -1
- package/test/snapshots/pfm/images/589.snap.ast +1 -1
- package/test/snapshots/pfm/link_reference_definitions/201.snap.ast +1 -1
- package/test/snapshots/pfm/link_reference_definitions/208.snap.ast +1 -1
- package/test/snapshots/pfm/links/491.snap.ast +1 -1
- package/test/snapshots/pfm/links/494.snap.ast +2 -2
- package/test/snapshots/pfm/links/516.snap.ast +8 -9
- package/test/snapshots/pfm/links/521.snap.ast +1 -1
- package/test/snapshots/pfm/links/530.snap.ast +8 -12
- package/test/snapshots/pfm/links/534.snap.ast +1 -1
- package/test/snapshots/pfm/links/552.snap.ast +2 -2
- package/test/snapshots/pfm/links/559.snap.ast +1 -1
- package/test/snapshots/pfm/links/564.snap.ast +1 -1
- package/test/snapshots/pfm/list_items/260.snap.ast +3 -4
- package/test/snapshots/pfm/list_items/293.snap.ast +2 -2
- package/test/snapshots/pfm/tabs/16.snap.ast +2 -3
- package/test/snapshots/pfm/tabs/4.snap.ast +6 -5
- package/test/snapshots/svelte/00-introduction/00-hello-world/App.snap.ast +3 -4
- package/test/snapshots/svelte/00-introduction/02-styling/App.snap.ast +2 -3
- package/test/snapshots/svelte/00-introduction/03-nested-components/App.snap.ast +2 -3
- package/test/snapshots/svelte/00-introduction/03-nested-components/Nested.snap.ast +1 -2
- package/test/snapshots/svelte/00-introduction/04-html-tags/App.snap.ast +1 -2
- package/test/snapshots/svelte/01-reactivity/00-reactive-assignments/App.snap.ast +5 -6
- package/test/snapshots/svelte/01-reactivity/01-reactive-declarations/App.snap.ast +11 -14
- package/test/snapshots/svelte/01-reactivity/02-reactive-statements/App.snap.ast +5 -6
- package/test/snapshots/svelte/02-props/00-declaring-props/Nested.snap.ast +2 -3
- package/test/snapshots/svelte/02-props/01-default-values/App.snap.ast +1 -1
- package/test/snapshots/svelte/02-props/01-default-values/Nested.snap.ast +2 -3
- package/test/snapshots/svelte/02-props/02-spread-props/Info.snap.ast +16 -17
- package/test/snapshots/svelte/03-logic/00-if-blocks/App.snap.ast +4 -8
- package/test/snapshots/svelte/03-logic/01-else-blocks/App.snap.ast +4 -8
- package/test/snapshots/svelte/03-logic/02-else-if-blocks/App.snap.ast +6 -9
- package/test/snapshots/svelte/03-logic/03-each-blocks/App.snap.ast +5 -8
- package/test/snapshots/svelte/03-logic/04-keyed-each-blocks/App.snap.ast +4 -7
- package/test/snapshots/svelte/03-logic/04-keyed-each-blocks/Thing.snap.ast +4 -5
- package/test/snapshots/svelte/04-events/02-event-modifiers/App.snap.ast +2 -3
- package/test/snapshots/svelte/04-events/03-component-events/Inner.snap.ast +2 -3
- package/test/snapshots/svelte/04-events/04-event-forwarding/Inner.snap.ast +2 -3
- package/test/snapshots/svelte/04-events/05-dom-event-forwarding/FancyButton.snap.ast +2 -3
- package/test/snapshots/svelte/05-bindings/00-text-inputs/App.snap.ast +3 -4
- package/test/snapshots/svelte/05-bindings/01-numeric-inputs/App.snap.ast +9 -8
- package/test/snapshots/svelte/05-bindings/02-checkbox-inputs/App.snap.ast +7 -11
- package/test/snapshots/svelte/05-bindings/03-group-inputs/App.snap.ast +21 -30
- package/test/snapshots/svelte/05-bindings/04-textarea-inputs/App.snap.ast +1 -2
- package/test/snapshots/svelte/05-bindings/05-select-bindings/App.snap.ast +5 -9
- package/test/snapshots/svelte/05-bindings/06-multiple-select-bindings/App.snap.ast +18 -26
- package/test/snapshots/svelte/05-bindings/07-each-block-bindings/App.snap.ast +7 -11
- package/test/snapshots/svelte/05-bindings/08-media-elements/App.snap.ast +15 -19
- package/test/snapshots/svelte/05-bindings/09-dimensions/App.snap.ast +7 -9
- package/test/snapshots/svelte/05-bindings/11-component-bindings/App.snap.ast +1 -2
- package/test/snapshots/svelte/05-bindings/11-component-bindings/Keypad.snap.ast +32 -34
- package/test/snapshots/svelte/06-lifecycle/00-onmount/App.snap.ast +3 -6
- package/test/snapshots/svelte/06-lifecycle/01-ondestroy/App.snap.ast +6 -7
- package/test/snapshots/svelte/06-lifecycle/02-update/App.snap.ast +2 -4
- package/test/snapshots/svelte/07-stores/00-writable-stores/App.snap.ast +4 -5
- package/test/snapshots/svelte/07-stores/00-writable-stores/Decrementer.snap.ast +2 -3
- package/test/snapshots/svelte/07-stores/00-writable-stores/Incrementer.snap.ast +2 -3
- package/test/snapshots/svelte/07-stores/00-writable-stores/Resetter.snap.ast +2 -3
- package/test/snapshots/svelte/07-stores/01-auto-subscriptions/App.snap.ast +4 -5
- package/test/snapshots/svelte/07-stores/01-auto-subscriptions/Decrementer.snap.ast +2 -3
- package/test/snapshots/svelte/07-stores/01-auto-subscriptions/Incrementer.snap.ast +2 -3
- package/test/snapshots/svelte/07-stores/01-auto-subscriptions/Resetter.snap.ast +2 -3
- package/test/snapshots/svelte/07-stores/02-readable-stores/App.snap.ast +2 -3
- package/test/snapshots/svelte/07-stores/03-derived-stores/App.snap.ast +8 -10
- package/test/snapshots/svelte/07-stores/04-custom-stores/App.snap.ast +7 -11
- package/test/snapshots/svelte/08-motion/00-tweened/App.snap.ast +10 -15
- package/test/snapshots/svelte/08-motion/01-spring/App.snap.ast +10 -10
- package/test/snapshots/svelte/09-transitions/00-transition/App.snap.ast +3 -5
- package/test/snapshots/svelte/09-transitions/01-adding-parameters-to-transitions/App.snap.ast +3 -5
- package/test/snapshots/svelte/09-transitions/02-in-and-out/App.snap.ast +3 -5
- package/test/snapshots/svelte/09-transitions/03-custom-css-transitions/App.snap.ast +4 -6
- package/test/snapshots/svelte/09-transitions/04-custom-js-transitions/App.snap.ast +3 -5
- package/test/snapshots/svelte/09-transitions/05-transition-events/App.snap.ast +5 -8
- package/test/snapshots/svelte/10-animations/00-animate/App.snap.ast +16 -20
- package/test/snapshots/svelte/11-easing/00-easing/App.snap.ast +16 -11
- package/test/snapshots/svelte/11-easing/00-easing/Controls.snap.ast +11 -16
- package/test/snapshots/svelte/11-easing/00-easing/Grid.snap.ast +2 -2
- package/test/snapshots/svelte/12-svg/01-clock/App.snap.ast +2 -1
- package/test/snapshots/svelte/12-svg/02-bar-chart/App.snap.ast +7 -9
- package/test/snapshots/svelte/12-svg/03-area-chart/App.snap.ast +14 -15
- package/test/snapshots/svelte/12-svg/04-scatterplot/App.snap.ast +7 -5
- package/test/snapshots/svelte/12-svg/04-scatterplot/Scatterplot.snap.ast +6 -6
- package/test/snapshots/svelte/12-svg/05-svg-transitions/App.snap.ast +5 -6
- package/test/snapshots/svelte/13-actions/01-adding-parameters-to-actions/App.snap.ast +2 -3
- package/test/snapshots/svelte/14-classes/00-classes/App.snap.ast +3 -6
- package/test/snapshots/svelte/14-classes/01-class-shorthand/App.snap.ast +2 -3
- package/test/snapshots/svelte/15-composition/00-slots/App.snap.ast +3 -5
- package/test/snapshots/svelte/15-composition/01-slot-fallbacks/App.snap.ast +3 -5
- package/test/snapshots/svelte/15-composition/01-slot-fallbacks/Box.snap.ast +1 -2
- package/test/snapshots/svelte/15-composition/02-named-slots/App.snap.ast +7 -11
- package/test/snapshots/svelte/15-composition/02-named-slots/ContactCard.snap.ast +3 -6
- package/test/snapshots/svelte/15-composition/03-slot-props/App.snap.ast +9 -15
- package/test/snapshots/svelte/15-composition/04-modal/App.snap.ast +17 -26
- package/test/snapshots/svelte/15-composition/04-modal/Modal.snap.ast +3 -3
- package/test/snapshots/svelte/16-context/00-context-api/App.snap.ast +10 -5
- package/test/snapshots/svelte/17-special-elements/00-svelte-self/File.snap.ast +1 -2
- package/test/snapshots/svelte/17-special-elements/00-svelte-self/Folder.snap.ast +1 -2
- package/test/snapshots/svelte/17-special-elements/01-svelte-component/App.snap.ast +1 -2
- package/test/snapshots/svelte/17-special-elements/01-svelte-component/BlueThing.snap.ast +1 -2
- package/test/snapshots/svelte/17-special-elements/01-svelte-component/GreenThing.snap.ast +1 -2
- package/test/snapshots/svelte/17-special-elements/01-svelte-component/RedThing.snap.ast +1 -2
- package/test/snapshots/svelte/17-special-elements/02-svelte-window/App.snap.ast +3 -6
- package/test/snapshots/svelte/17-special-elements/03-svelte-window-bindings/App.snap.ast +2 -4
- package/test/snapshots/svelte/17-special-elements/05-svelte-head/App.snap.ast +6 -12
- package/test/snapshots/svelte/18-module-context/01-module-exports/App.snap.ast +2 -3
- package/test/snapshots/svelte/18-module-context/01-module-exports/AudioPlayer.snap.ast +4 -7
- package/test/snapshots/svelte/19-debugging/00-debug/App.snap.ast +5 -7
- package/test/snapshots/svelte/19-debugging/00-debug/Test.snap.ast +7 -11
- package/test/snapshots/svelte/20-7guis/01-7guis-counter/App.snap.ast +2 -3
- package/test/snapshots/svelte/20-7guis/02-7guis-temperature/App.snap.ast +2 -2
- package/test/snapshots/svelte/20-7guis/03-7guis-flight-booker/App.snap.ast +4 -7
- package/test/snapshots/svelte/20-7guis/04-7guis-timer/App.snap.ast +13 -17
- package/test/snapshots/svelte/20-7guis/05-7guis-crud/App.snap.ast +11 -13
- package/test/snapshots/svelte/20-7guis/06-7guis-circles/App.snap.ast +10 -11
- package/test/snapshots/svelte/21-miscellaneous/01-hacker-news/Comment.snap.ast +4 -6
- package/test/snapshots/svelte/21-miscellaneous/01-hacker-news/Item.snap.ast +9 -13
- package/test/snapshots/svelte/21-miscellaneous/01-hacker-news/List.snap.ast +3 -5
- package/test/snapshots/svelte/21-miscellaneous/01-hacker-news/Summary.snap.ast +7 -11
- package/test/snapshots/svelte/21-miscellaneous/02-immutable-data/App.snap.ast +2 -4
- package/test/snapshots/svelte/99-embeds/20181225-blog-svelte-css-in-js/App.snap.ast +6 -7
- package/test/snapshots/svelte/99-embeds/20181225-blog-svelte-css-in-js/Hero.snap.ast +3 -5
- package/test/snapshots/svelte/99-embeds/20190420-blog-write-less-code/App.snap.ast +6 -7
- package/test/svelte_expressions.spec.ts +93 -4
- package/test/svelte_tags.spec.ts +27 -12
- package/test/tables.spec.ts +347 -0
- package/test/tree_builder.spec.ts +286 -1
- package/test/unclosed_delimiters.spec.ts +529 -0
- package/tsc/buf_utils.d.ts +1 -1
- package/tsc/buf_utils.js +9 -9
- package/tsc/cursor.d.ts +17 -13
- package/tsc/cursor.js +60 -43
- package/tsc/main.d.ts +362 -26
- package/tsc/main.js +8955 -4891
- package/tsc/node_view.d.ts +11 -12
- package/tsc/node_view.js +134 -102
- package/tsc/opcodes.d.ts +23 -6
- package/tsc/plugin_dispatch.d.ts +22 -8
- package/tsc/plugin_dispatch.js +292 -170
- package/tsc/tree_builder.d.ts +42 -11
- package/tsc/tree_builder.js +237 -82
- package/tsc/undo_log.d.ts +11 -1
- package/tsc/undo_log.js +54 -19
- package/tsc/utils.d.ts +77 -51
- package/tsc/utils.js +687 -344
- package/tsc/utils.spec.js +83 -9
- package/tsc/wire_emitter.js +6 -0
- package/tsc/wire_tree_builder.d.ts +4 -7
- package/tsc/wire_tree_builder.js +34 -37
- package/dist/node_view-BEh2-H86.js +0 -373
|
@@ -0,0 +1 @@
|
|
|
1
|
+
::x[a *b]* c]
|
package/test/html.spec.ts
CHANGED
|
@@ -7,7 +7,9 @@ import {
|
|
|
7
7
|
print_all_nodes,
|
|
8
8
|
} from './utils';
|
|
9
9
|
|
|
10
|
-
import { parse_markdown_svelte } from '../src/main';
|
|
10
|
+
import { PFMParser, parse_markdown_svelte } from '../src/main';
|
|
11
|
+
import { TreeBuilder } from '../src/tree_builder';
|
|
12
|
+
import type { NodeBuffer } from '../src/utils';
|
|
11
13
|
|
|
12
14
|
describe('html - self-closing inline tags', () => {
|
|
13
15
|
test('simple self-closing tag <br />', () => {
|
|
@@ -784,3 +786,44 @@ describe('html - raw text elements (script, style)', () => {
|
|
|
784
786
|
expect(content.value).toBe('let x = 1;');
|
|
785
787
|
});
|
|
786
788
|
});
|
|
789
|
+
|
|
790
|
+
describe('html - unclosed tags', () => {
|
|
791
|
+
function texts(nodes: NodeBuffer, source: string, id = 0): string {
|
|
792
|
+
const n = nodes.get_node(id);
|
|
793
|
+
if (n.kind === 'text') return source.slice(n.value[0], n.value[1]);
|
|
794
|
+
return n.children.map((c: number) => texts(nodes, source, c)).join('');
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
function parse_incremental(source: string, chunk_size: number): NodeBuffer {
|
|
798
|
+
const tree = new TreeBuilder(source.length);
|
|
799
|
+
const parser = new PFMParser(tree);
|
|
800
|
+
parser.init();
|
|
801
|
+
for (let i = 0; i < source.length; i += chunk_size) {
|
|
802
|
+
parser.feed(source.slice(i, i + chunk_size));
|
|
803
|
+
}
|
|
804
|
+
parser.finish();
|
|
805
|
+
return tree.get_buffer();
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
const cases: [string, string][] = [
|
|
809
|
+
['a <b>x', 'a <b>x'],
|
|
810
|
+
['a <b a="1">x', 'a <b a="1">x'],
|
|
811
|
+
['a <b><i>x', 'a <b><i>x'],
|
|
812
|
+
['a <b>x\ny', 'a <b>xy'],
|
|
813
|
+
['- a <b>x', 'a <b>x'],
|
|
814
|
+
['> a <b>x\nfoo', 'a <b>xfoo'],
|
|
815
|
+
['<div>foo', '<div>foo'],
|
|
816
|
+
['<a href="foo\nbar">', '<a href="foo\nbar">'],
|
|
817
|
+
['a <b\nc="1">x', 'a <b\nc="1">x'],
|
|
818
|
+
];
|
|
819
|
+
|
|
820
|
+
for (const [input, expected] of cases) {
|
|
821
|
+
test(`keeps the text of ${JSON.stringify(input)} once`, () => {
|
|
822
|
+
const batch = parse_markdown_svelte(input);
|
|
823
|
+
expect(texts(batch.nodes, batch.source)).toBe(expected);
|
|
824
|
+
for (const size of [1, 2, 3]) {
|
|
825
|
+
expect(texts(parse_incremental(input, size), input)).toBe(expected);
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
});
|
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { PFMParser, parse_markdown_svelte } from '../src/main';
|
|
4
|
+
import { TreeBuilder } from '../src/tree_builder';
|
|
5
|
+
import type { NodeBuffer } from '../src/utils';
|
|
6
|
+
|
|
7
|
+
type Shape = string | [string, ...Shape[]];
|
|
8
|
+
|
|
9
|
+
function shape(nodes: NodeBuffer, source: string, id = 0): Shape {
|
|
10
|
+
const n = nodes.get_node(id);
|
|
11
|
+
if (n.kind === 'text') return `text:${source.slice(n.value[0], n.value[1])}`;
|
|
12
|
+
if (n.children.length === 0) return n.kind;
|
|
13
|
+
return [n.kind, ...n.children.map((c: number) => shape(nodes, source, c))];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function root_shape(input: string): Shape[] {
|
|
17
|
+
const { nodes, source } = parse_markdown_svelte(input);
|
|
18
|
+
const root = shape(nodes, source);
|
|
19
|
+
return Array.isArray(root) ? root.slice(1) : [];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function strip_line_breaks(s: Shape[]): Shape[] {
|
|
23
|
+
return s.filter((c) => c !== 'line_break');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function parse_incremental(source: string, chunk_size: number): NodeBuffer {
|
|
27
|
+
const tree = new TreeBuilder(source.length);
|
|
28
|
+
const parser = new PFMParser(tree);
|
|
29
|
+
parser.init();
|
|
30
|
+
for (let i = 0; i < source.length; i += chunk_size) {
|
|
31
|
+
parser.feed(source.slice(i, i + chunk_size));
|
|
32
|
+
}
|
|
33
|
+
parser.finish();
|
|
34
|
+
return tree.get_buffer();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const after = '\n\none\n\ntwo\n';
|
|
38
|
+
const after_shape: Shape[] = [
|
|
39
|
+
['paragraph', 'text:one'],
|
|
40
|
+
['paragraph', 'text:two'],
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
describe('html block closing containers opened inside it', () => {
|
|
44
|
+
test('list on the opener line keeps later paragraphs', () => {
|
|
45
|
+
expect(strip_line_breaks(root_shape(`<div>- a\n</div>${after}`))).toEqual([
|
|
46
|
+
['html', ['list', ['list_item', 'text:a']], 'line_break'],
|
|
47
|
+
...after_shape,
|
|
48
|
+
]);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('an element closing on its opener line holds inline content', () => {
|
|
52
|
+
expect(strip_line_breaks(root_shape(`<div>- a</div>${after}`))).toEqual([
|
|
53
|
+
['html', 'text:- a'],
|
|
54
|
+
...after_shape,
|
|
55
|
+
]);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('list on its own line keeps later paragraphs', () => {
|
|
59
|
+
expect(
|
|
60
|
+
strip_line_breaks(
|
|
61
|
+
root_shape('<div>\n- item</div>\n\npara one\n\npara two\n')
|
|
62
|
+
)
|
|
63
|
+
).toEqual([
|
|
64
|
+
['html', 'line_break', ['list', ['list_item', 'text:item']]],
|
|
65
|
+
['paragraph', 'text:para one'],
|
|
66
|
+
['paragraph', 'text:para two'],
|
|
67
|
+
]);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('list inside an html list element', () => {
|
|
71
|
+
expect(strip_line_breaks(root_shape(`<ul>\n- a</ul>${after}`))).toEqual([
|
|
72
|
+
['html', 'line_break', ['list', ['list_item', 'text:a']]],
|
|
73
|
+
...after_shape,
|
|
74
|
+
]);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('empty list item followed by a stray angle bracket', () => {
|
|
78
|
+
expect(root_shape('<div>\n- </div><\n')).toEqual([
|
|
79
|
+
['html', 'line_break', ['list', 'list_item']],
|
|
80
|
+
['paragraph', 'text:<'],
|
|
81
|
+
'line_break',
|
|
82
|
+
]);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('inline element followed by a stray angle bracket', () => {
|
|
86
|
+
expect(root_shape('<p>- </p><\n')).toEqual([
|
|
87
|
+
['html', 'text:- '],
|
|
88
|
+
'text:<',
|
|
89
|
+
'line_break',
|
|
90
|
+
]);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('list closed by the html tag is marked tight', () => {
|
|
94
|
+
const { nodes } = parse_markdown_svelte(`<div>- a\n</div>${after}`);
|
|
95
|
+
const html = nodes.get_node(nodes.get_node().children[0]);
|
|
96
|
+
const list = nodes.get_node(html.children[0]);
|
|
97
|
+
expect(list.kind).toBe('list');
|
|
98
|
+
expect(list.metadata.tight).toBe(true);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('loose list closed by the html tag keeps its paragraphs', () => {
|
|
102
|
+
expect(
|
|
103
|
+
strip_line_breaks(root_shape(`<div>\n- a\n\n- b</div>${after}`))
|
|
104
|
+
).toEqual([
|
|
105
|
+
[
|
|
106
|
+
'html',
|
|
107
|
+
'line_break',
|
|
108
|
+
[
|
|
109
|
+
'list',
|
|
110
|
+
['list_item', ['paragraph', 'text:a']],
|
|
111
|
+
['list_item', ['paragraph', 'text:b']],
|
|
112
|
+
],
|
|
113
|
+
],
|
|
114
|
+
...after_shape,
|
|
115
|
+
]);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('nested lists', () => {
|
|
119
|
+
expect(
|
|
120
|
+
strip_line_breaks(root_shape(`<div>\n- a\n - b</div>${after}`))
|
|
121
|
+
).toEqual([
|
|
122
|
+
[
|
|
123
|
+
'html',
|
|
124
|
+
'line_break',
|
|
125
|
+
['list', ['list_item', 'text:a', ['list', ['list_item', 'text:b']]]],
|
|
126
|
+
],
|
|
127
|
+
...after_shape,
|
|
128
|
+
]);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('blockquote inside a list item', () => {
|
|
132
|
+
expect(strip_line_breaks(root_shape(`<div>\n- > a</div>${after}`))).toEqual(
|
|
133
|
+
[
|
|
134
|
+
[
|
|
135
|
+
'html',
|
|
136
|
+
'line_break',
|
|
137
|
+
['list', ['list_item', ['block_quote', ['paragraph', 'text:a']]]],
|
|
138
|
+
],
|
|
139
|
+
...after_shape,
|
|
140
|
+
]
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('svelte block keeps its branch expression short of the close tag', () => {
|
|
145
|
+
const input = `<div>\n{#if x}\n- a</div>${after}`;
|
|
146
|
+
expect(strip_line_breaks(root_shape(input))).toEqual([
|
|
147
|
+
[
|
|
148
|
+
'html',
|
|
149
|
+
'line_break',
|
|
150
|
+
[
|
|
151
|
+
'svelte_block',
|
|
152
|
+
['svelte_branch', 'line_break', ['list', ['list_item', 'text:a']]],
|
|
153
|
+
],
|
|
154
|
+
],
|
|
155
|
+
...after_shape,
|
|
156
|
+
]);
|
|
157
|
+
const { nodes, source } = parse_markdown_svelte(input);
|
|
158
|
+
const html = nodes.get_node(nodes.get_node().children[0]);
|
|
159
|
+
const block = nodes.get_node(html.children[1]);
|
|
160
|
+
const branch = nodes.get_node(block.children[0]);
|
|
161
|
+
expect(source.slice(branch.value[0], branch.value[1])).toBe('x');
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test('blockquote inside a svelte block', () => {
|
|
165
|
+
expect(
|
|
166
|
+
strip_line_breaks(root_shape(`<div>\n{#if x}\n> a</div>${after}`))
|
|
167
|
+
).toEqual([
|
|
168
|
+
[
|
|
169
|
+
'html',
|
|
170
|
+
'line_break',
|
|
171
|
+
[
|
|
172
|
+
'svelte_block',
|
|
173
|
+
[
|
|
174
|
+
'svelte_branch',
|
|
175
|
+
'line_break',
|
|
176
|
+
['block_quote', ['paragraph', 'text:a']],
|
|
177
|
+
],
|
|
178
|
+
],
|
|
179
|
+
],
|
|
180
|
+
...after_shape,
|
|
181
|
+
]);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test('directive container inside a svelte block', () => {
|
|
185
|
+
const input = `<div>\n{#if x}\n:::note[hi]\nfoo</div>${after}`;
|
|
186
|
+
expect(strip_line_breaks(root_shape(input))).toEqual([
|
|
187
|
+
[
|
|
188
|
+
'html',
|
|
189
|
+
'line_break',
|
|
190
|
+
[
|
|
191
|
+
'svelte_block',
|
|
192
|
+
[
|
|
193
|
+
'svelte_branch',
|
|
194
|
+
'line_break',
|
|
195
|
+
[
|
|
196
|
+
'directive_container',
|
|
197
|
+
['directive_label', 'text:hi'],
|
|
198
|
+
['paragraph', 'text:foo'],
|
|
199
|
+
],
|
|
200
|
+
],
|
|
201
|
+
],
|
|
202
|
+
],
|
|
203
|
+
...after_shape,
|
|
204
|
+
]);
|
|
205
|
+
const { nodes, source } = parse_markdown_svelte(input);
|
|
206
|
+
const html = nodes.get_node(nodes.get_node().children[0]);
|
|
207
|
+
const block = nodes.get_node(html.children[1]);
|
|
208
|
+
const branch = nodes.get_node(block.children[0]);
|
|
209
|
+
const dir = nodes.get_node(branch.children[1]);
|
|
210
|
+
expect(dir.kind).toBe('directive_container');
|
|
211
|
+
expect(source.slice(dir.value[0], dir.value[1])).toBe('hi');
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test('table', () => {
|
|
215
|
+
expect(
|
|
216
|
+
strip_line_breaks(
|
|
217
|
+
root_shape(`<div>\n| a | b |\n|---|---|\n| c</div>\n\none | x\n`)
|
|
218
|
+
)
|
|
219
|
+
).toEqual(
|
|
220
|
+
strip_line_breaks([
|
|
221
|
+
[
|
|
222
|
+
'html',
|
|
223
|
+
'line_break',
|
|
224
|
+
[
|
|
225
|
+
'table',
|
|
226
|
+
[
|
|
227
|
+
'table_header',
|
|
228
|
+
['table_cell', 'text:a'],
|
|
229
|
+
['table_cell', 'text:b'],
|
|
230
|
+
],
|
|
231
|
+
['table_row', ['table_cell', 'text:c'], 'table_cell'],
|
|
232
|
+
],
|
|
233
|
+
],
|
|
234
|
+
...root_shape('one | x\n'),
|
|
235
|
+
])
|
|
236
|
+
);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
test('heading', () => {
|
|
240
|
+
expect(
|
|
241
|
+
strip_line_breaks(root_shape('<div>\n# h</div>\n\n*one\ntwo*\n'))
|
|
242
|
+
).toEqual([
|
|
243
|
+
['html', 'line_break', ['heading', 'text:h']],
|
|
244
|
+
['paragraph', ['strong_emphasis', 'text:one', 'soft_break', 'text:two']],
|
|
245
|
+
]);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
test('unclosed delimiter in a tight list item stays literal', () => {
|
|
249
|
+
expect(strip_line_breaks(root_shape(`<div>\n- *a</div>${after}`))).toEqual([
|
|
250
|
+
['html', 'line_break', ['list', ['list_item', 'text:*a']]],
|
|
251
|
+
...after_shape,
|
|
252
|
+
]);
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
describe('every later block stays a root child', () => {
|
|
257
|
+
const inners = [
|
|
258
|
+
'- a',
|
|
259
|
+
'- a\n- b',
|
|
260
|
+
'- a\n\n- b',
|
|
261
|
+
'- a\n - b',
|
|
262
|
+
'- a\n - b\n - c',
|
|
263
|
+
'1. a',
|
|
264
|
+
'- > a',
|
|
265
|
+
'- > - a',
|
|
266
|
+
'{#if x}\na',
|
|
267
|
+
'{#if x}\n- a',
|
|
268
|
+
'{#if x}\n> a',
|
|
269
|
+
'{#if x}\n{#each y as z}\n- a',
|
|
270
|
+
'{#if x}\n:::note[]\na',
|
|
271
|
+
'{#if x}\n:::note[]\n- a',
|
|
272
|
+
'- {#if x}\n- a',
|
|
273
|
+
'| a |\n|---|\n| b',
|
|
274
|
+
'# h',
|
|
275
|
+
'# *h',
|
|
276
|
+
'- *a',
|
|
277
|
+
'- :x[a',
|
|
278
|
+
'<section>\n- a',
|
|
279
|
+
];
|
|
280
|
+
const tail =
|
|
281
|
+
'\n\none\n\n- two\n\n> three\n\n{#if y}\nfour\n{/if}\n\n:::note[]\nfive\n:::\n\n*six\nseven*\n';
|
|
282
|
+
const tail_shape = strip_line_breaks(root_shape(tail.slice(2)));
|
|
283
|
+
|
|
284
|
+
for (const inner of inners) {
|
|
285
|
+
for (const [open, close] of [
|
|
286
|
+
['<div>', '</div>'],
|
|
287
|
+
['<div>\n', '</div>'],
|
|
288
|
+
]) {
|
|
289
|
+
const input = `${open}${inner}${close}${tail}`;
|
|
290
|
+
test(JSON.stringify(input), () => {
|
|
291
|
+
const kids = strip_line_breaks(root_shape(input));
|
|
292
|
+
expect(kids[0][0]).toBe('html');
|
|
293
|
+
expect(kids.slice(1)).toEqual(tail_shape);
|
|
294
|
+
|
|
295
|
+
const batch = parse_markdown_svelte(input);
|
|
296
|
+
for (const size of [1, 2, 7]) {
|
|
297
|
+
const inc = parse_incremental(input, size);
|
|
298
|
+
expect(shape(inc, batch.source)).toEqual(
|
|
299
|
+
shape(batch.nodes, batch.source)
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
describe('unclosed inline html at the end of a block quote', () => {
|
|
308
|
+
const cases: [string, Shape[]][] = [
|
|
309
|
+
['> <l>\nfoo', [['block_quote', ['paragraph', 'text:<l>']]]],
|
|
310
|
+
['><div>\nfoo', [['block_quote', ['paragraph', 'text:<div>']]]],
|
|
311
|
+
['> <span>\nfoo', [['block_quote', ['paragraph', 'text:<span>']]]],
|
|
312
|
+
[
|
|
313
|
+
'> > <l>\nfoo',
|
|
314
|
+
[['block_quote', ['block_quote', ['paragraph', 'text:<l>']]]],
|
|
315
|
+
],
|
|
316
|
+
[
|
|
317
|
+
'- > <l>\nfoo',
|
|
318
|
+
[['list', ['list_item', ['block_quote', ['paragraph', 'text:<l>']]]]],
|
|
319
|
+
],
|
|
320
|
+
[
|
|
321
|
+
'> <l>\n> bar\nfoo',
|
|
322
|
+
[['block_quote', ['paragraph', 'text:<l>', 'soft_break', 'text:bar']]],
|
|
323
|
+
],
|
|
324
|
+
];
|
|
325
|
+
|
|
326
|
+
for (const [input, quote] of cases) {
|
|
327
|
+
test(JSON.stringify(input), () => {
|
|
328
|
+
const error = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
329
|
+
try {
|
|
330
|
+
expect(strip_line_breaks(root_shape(input))).toEqual([
|
|
331
|
+
...quote,
|
|
332
|
+
['paragraph', 'text:foo'],
|
|
333
|
+
]);
|
|
334
|
+
|
|
335
|
+
const batch = parse_markdown_svelte(input);
|
|
336
|
+
for (const size of [1, 2, 3]) {
|
|
337
|
+
const inc = parse_incremental(input, size);
|
|
338
|
+
expect(shape(inc, batch.source)).toEqual(
|
|
339
|
+
shape(batch.nodes, batch.source)
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
expect(error).not.toHaveBeenCalled();
|
|
343
|
+
} finally {
|
|
344
|
+
error.mockRestore();
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
describe('a container close tag on its own line ends the paragraph', () => {
|
|
351
|
+
const cases: [string, string, Shape[]][] = [
|
|
352
|
+
[
|
|
353
|
+
'component',
|
|
354
|
+
'<Card>\npara\n</Card>\n',
|
|
355
|
+
[['html', 'line_break', ['paragraph', 'text:para'], 'line_break']],
|
|
356
|
+
],
|
|
357
|
+
[
|
|
358
|
+
'indented component close',
|
|
359
|
+
'<Card>\n para\n </Card>\n',
|
|
360
|
+
[['html', 'line_break', ['paragraph', 'text:para'], 'line_break']],
|
|
361
|
+
],
|
|
362
|
+
[
|
|
363
|
+
'tight list item',
|
|
364
|
+
'<Card>\n- a\n- b\n</Card>\n',
|
|
365
|
+
[
|
|
366
|
+
[
|
|
367
|
+
'html',
|
|
368
|
+
'line_break',
|
|
369
|
+
['list', ['list_item', 'text:a'], ['list_item', 'text:b']],
|
|
370
|
+
'line_break',
|
|
371
|
+
],
|
|
372
|
+
],
|
|
373
|
+
],
|
|
374
|
+
[
|
|
375
|
+
'inline element opened in the paragraph',
|
|
376
|
+
'<Card>\na <b>bold\n</b> c\n</Card>\n',
|
|
377
|
+
[
|
|
378
|
+
[
|
|
379
|
+
'html',
|
|
380
|
+
'line_break',
|
|
381
|
+
[
|
|
382
|
+
'paragraph',
|
|
383
|
+
'text:a ',
|
|
384
|
+
['html', 'text:bold', 'soft_break'],
|
|
385
|
+
'text: c',
|
|
386
|
+
],
|
|
387
|
+
'line_break',
|
|
388
|
+
],
|
|
389
|
+
],
|
|
390
|
+
],
|
|
391
|
+
];
|
|
392
|
+
|
|
393
|
+
for (const [name, input, expected] of cases) {
|
|
394
|
+
test(name, () => {
|
|
395
|
+
expect(strip_line_breaks(root_shape(input))).toEqual(expected);
|
|
396
|
+
for (const size of [1, 3]) {
|
|
397
|
+
const { source } = parse_markdown_svelte(input);
|
|
398
|
+
const root = shape(parse_incremental(input, size), source) as Shape[];
|
|
399
|
+
expect(strip_line_breaks(root.slice(1))).toEqual(expected);
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
describe('paragraphs that start with a tag', () => {
|
|
406
|
+
const inputs = [
|
|
407
|
+
'<X />\n',
|
|
408
|
+
'<X /> <Y />\n',
|
|
409
|
+
'<X />\n<Y />\n\nafter\n',
|
|
410
|
+
'<X /> hello\n',
|
|
411
|
+
'<X />\nhello *world*\n',
|
|
412
|
+
'<div><p>hi</p></div>\n',
|
|
413
|
+
'<div>a</div> b\n',
|
|
414
|
+
'<X>`<div>`</X> c\n',
|
|
415
|
+
'{@html raw}\n',
|
|
416
|
+
'{@html raw} text\n',
|
|
417
|
+
'> <X />\n> <Y />\n',
|
|
418
|
+
'> <X />\n> text\n',
|
|
419
|
+
'{#if a}\n<X />\n{/if}\n',
|
|
420
|
+
'<div>\n<X />\n</div>\n',
|
|
421
|
+
'<p>\nline\n\nline\n</p>\n',
|
|
422
|
+
'<span>unclosed\n\nnext\n',
|
|
423
|
+
];
|
|
424
|
+
|
|
425
|
+
for (const input of inputs) {
|
|
426
|
+
test(`${JSON.stringify(input)} matches when fed in chunks`, () => {
|
|
427
|
+
const { nodes, source } = parse_markdown_svelte(input);
|
|
428
|
+
const batch = shape(nodes, source);
|
|
429
|
+
for (const size of [1, 2, 5]) {
|
|
430
|
+
expect(shape(parse_incremental(input, size), source)).toEqual(batch);
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
test('a long tag only paragraph survives feed window trims', () => {
|
|
436
|
+
const input = '<X />\n'.repeat(400) + 'tail text\n\n<Y />\n';
|
|
437
|
+
const { nodes, source } = parse_markdown_svelte(input);
|
|
438
|
+
const batch = shape(nodes, source) as Shape[];
|
|
439
|
+
expect((batch[1] as Shape[])[0]).toBe('paragraph');
|
|
440
|
+
expect(batch[batch.length - 2]).toBe('html');
|
|
441
|
+
for (const size of [1, 7, 64]) {
|
|
442
|
+
expect(shape(parse_incremental(input, size), source)).toEqual(batch);
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
});
|