Skip to content

Commit 53b26df

Browse files
committed
fix tests
1 parent 61ef4ff commit 53b26df

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

src/__snapshots__/react.spec.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
22

33
exports[`handles a holistic example 1`] = `
4-
"<div><h1 id="markdown-syntax">Markdown: Syntax</h1><ul id="ProjectSubmenu"><li><a href="/projects/markdown/" title="Markdown Project Page">Main</a><li><a href="/projects/markdown/basics" title="Markdown Basics">Basics</a></li><li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li><li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li><li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li></li></ul><ul><li><a href="#overview">Overview</a><ul><li><a href="#philosophy">Philosophy</a></li><li><a href="#html">Inline HTML</a></li><li><a href="#autoescape">Automatic Escaping for Special Characters</a></li></ul></li><li><a href="#block">Block Elements</a><ul><li><a href="#p">Paragraphs and Line Breaks</a></li><li><a href="#header">Headers</a></li><li><a href="#blockquote">Blockquotes</a></li><li><a href="#list">Lists</a></li><li><a href="#precode">Code Blocks</a></li><li><a href="#hr">Horizontal Rules</a></li></ul></li><li><a href="#span">Span Elements</a><ul><li><a href="#link">Links</a></li><li><a href="#em">Emphasis</a></li><li><a href="#code">Code</a></li><li><a href="#img">Images</a></li></ul></li><li><a href="#misc">Miscellaneous</a><ul><li><a href="#backslash">Backslash Escapes</a></li><li><a href="#autolink">Automatic Links</a></li></ul></li></ul><p><strong>Note:</strong> This document is itself written using Markdown; you
4+
"<div><h1 id="markdown-syntax">Markdown: Syntax</h1><ul><li><a href="#overview">Overview</a><ul><li><a href="#philosophy">Philosophy</a></li><li><a href="#html">Inline HTML</a></li><li><a href="#autoescape">Automatic Escaping for Special Characters</a></li></ul></li><li><a href="#block">Block Elements</a><ul><li><a href="#p">Paragraphs and Line Breaks</a></li><li><a href="#header">Headers</a></li><li><a href="#blockquote">Blockquotes</a></li><li><a href="#list">Lists</a></li><li><a href="#precode">Code Blocks</a></li><li><a href="#hr">Horizontal Rules</a></li></ul></li><li><a href="#span">Span Elements</a><ul><li><a href="#link">Links</a></li><li><a href="#em">Emphasis</a></li><li><a href="#code">Code</a></li><li><a href="#img">Images</a></li></ul></li><li><a href="#misc">Miscellaneous</a><ul><li><a href="#backslash">Backslash Escapes</a></li><li><a href="#autolink">Automatic Links</a></li></ul></li></ul><p><strong>Note:</strong> This document is itself written using Markdown; you
55
can <a href="/projects/markdown/syntax.text">see the source for it by adding &#x27;.text&#x27; to the URL</a>.</p><hr/><h2 id="overview">Overview</h2><h3 id="philosophy">Philosophy</h3><p>Markdown is intended to be as easy-to-read and easy-to-write as is feasible.</p><p>Readability, however, is emphasized above all else. A Markdown-formatted
66
document should be publishable as-is, as plain text, without looking
77
like it&#x27;s been marked up with tags or formatting instructions. While

src/parse.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,12 +1238,12 @@ describe('HTML tags interrupting lists', () => {
12381238
it('should interrupt list when HTML tag appears at base indent or less', () => {
12391239
const md = '- foo\n\n\n\n<small>Hi</small>'
12401240
const result = p.parser(md)
1241-
1241+
12421242
// Should have a list with one item, then an HTML block
12431243
expect(result.length).toBe(2)
12441244
expect(result[0].type).toBe('unorderedList')
12451245
expect(result[1].type).toBe('paragraph') // HTML tag wrapped in paragraph
1246-
1246+
12471247
const list = result[0] as MarkdownToJSX.UnorderedListNode
12481248
expect(list.items.length).toBe(1)
12491249
expect(list.items[0][0].type).toBe('text')
@@ -1253,11 +1253,11 @@ describe('HTML tags interrupting lists', () => {
12531253
it('should interrupt indented list when HTML tag appears at column 0', () => {
12541254
const md = ' * You can have lists, like this one\n\n * Make things **bold** or *italic*\n\n * Embed snippets of `code`\n\n * Create [links](/)\n\n * ...\n\n\n\n<small>Sample content borrowed with thanks from [elm-markdown](http://elm-lang.org/examples/markdown) ❤️</small>'
12551255
const result = p.parser(md)
1256-
1256+
12571257
// Should have a list, then HTML content (not inside the list)
12581258
expect(result.length).toBeGreaterThan(1)
12591259
expect(result[0].type).toBe('unorderedList')
1260-
1260+
12611261
const list = result[0] as MarkdownToJSX.UnorderedListNode
12621262
// The last item should NOT contain the <small> tag
12631263
const lastItem = list.items[list.items.length - 1]
@@ -1269,11 +1269,11 @@ describe('HTML tags interrupting lists', () => {
12691269
it('should interrupt list with block-level HTML tag', () => {
12701270
const md = '- item 1\n- item 2\n<div>test</div>\n- item 3'
12711271
const result = p.parser(md)
1272-
1272+
12731273
// Should have a list with 2 items, then HTML block, then another list
12741274
expect(result.length).toBeGreaterThan(1)
12751275
expect(result[0].type).toBe('unorderedList')
1276-
1276+
12771277
const list = result[0] as MarkdownToJSX.UnorderedListNode
12781278
expect(list.items.length).toBe(2) // Should only have 2 items, not 3
12791279
})

src/react.spec.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,13 +1505,10 @@ comment -->`)
15051505
})
15061506

15071507
it('handles svg', () => {
1508-
render(
1509-
compiler(fs.readFileSync(__dirname + '/../docs/images/logo.svg', 'utf8'))
1510-
)
1508+
render(compiler(fs.readFileSync(__dirname + '/../public/icon.svg', 'utf8')))
15111509

15121510
expect(root.innerHTML).toMatchInlineSnapshot(
1513-
`"<svg width="246" height="369" xmlns="http://www.w3.org/2000/svg"><path d="M243.937.055a2 2 0 0 1 2.008 2.002v168.995c0 1.106-.814 2.388-1.802 2.855l-118.895 56.186c-.996.47-2.617.467-3.605 0L2.748 173.907c-.996-.47-1.803-1.742-1.803-2.855V2.057C.945.951 1.832.055 2.953.055h240.984zM110.391 139.367V66.383l-25.032 47.32h-9.843l-24.891-47.32v72.984h-15.68V42.055h20.18l25.594 49.64 25.804-49.64h19.688v97.312h-15.82zm104.101-48.656c0 9.562-.984 17.484-2.953 23.766-1.969 6.28-4.91 11.261-8.824 14.941-3.914 3.68-8.754 6.258-14.52 7.734-5.765 1.477-12.445 2.215-20.039 2.215h-27.21V42.055h26.929c7.781 0 14.59.82 20.426 2.46 5.836 1.641 10.699 4.36 14.59 8.157 3.89 3.797 6.796 8.8 8.718 15.012 1.922 6.21 2.883 13.886 2.883 23.027zm-18.289-16.508c-1.031-4.312-2.742-7.746-5.133-10.3-2.39-2.555-5.554-4.348-9.492-5.38-3.937-1.03-8.812-1.546-14.625-1.546h-9.21v67.359h9.21c5.906 0 10.828-.55 14.766-1.652 3.937-1.102 7.101-2.954 9.492-5.555 2.39-2.602 4.078-6.07 5.062-10.406.985-4.336 1.477-9.739 1.477-16.207 0-6.563-.516-12-1.547-16.313zM51.219 339.805c0 4.922-.574 9.187-1.723 12.797-1.148 3.609-2.93 6.597-5.344 8.964-2.414 2.368-5.507 4.114-9.28 5.239-3.774 1.125-8.263 1.687-13.466 1.687-1.265 0-2.718-.082-4.36-.246a60.81 60.81 0 0 1-5.097-.738 80.327 80.327 0 0 1-5.238-1.16A49.492 49.492 0 0 1 2 364.906l5.484-14.414c.704.375 1.653.762 2.848 1.16 1.195.399 2.45.762 3.762 1.09a56.72 56.72 0 0 0 3.972.844c1.336.234 2.496.351 3.48.351 2.673 0 4.864-.316 6.575-.949 1.711-.633 3.07-1.699 4.078-3.199 1.008-1.5 1.7-3.492 2.074-5.976.375-2.485.563-5.602.563-9.352V269h16.383v70.805zM151.688 339c0 5.484-.973 10.09-2.918 13.816-1.946 3.727-4.582 6.75-7.91 9.07-3.329 2.321-7.208 3.985-11.637 4.993-4.43 1.008-9.13 1.512-14.098 1.512-5.25 0-9.844-.493-13.781-1.477-3.938-.984-7.383-2.32-10.336-4.008-2.953-1.687-5.473-3.656-7.559-5.906A43.715 43.715 0 0 1 78 349.758l12.938-9.352a42.058 42.058 0 0 0 3.902 5.168 23.723 23.723 0 0 0 4.992 4.254c1.898 1.219 4.113 2.192 6.645 2.918 2.53.727 5.46 1.09 8.789 1.09 2.484 0 4.91-.234 7.277-.703s4.465-1.242 6.293-2.32c1.828-1.079 3.293-2.485 4.394-4.22 1.102-1.734 1.653-3.89 1.653-6.468 0-2.438-.528-4.477-1.582-6.117-1.055-1.64-2.473-3.024-4.254-4.149-1.781-1.125-3.867-2.062-6.258-2.812-2.39-.75-4.945-1.477-7.664-2.18a266.328 266.328 0 0 1-13.852-3.902c-4.265-1.336-7.968-3.035-11.109-5.098-3.14-2.062-5.613-4.687-7.418-7.875-1.805-3.187-2.707-7.265-2.707-12.234 0-4.406.75-8.38 2.25-11.918a24.403 24.403 0 0 1 6.61-9.07c2.906-2.508 6.527-4.43 10.863-5.766 4.336-1.336 9.316-2.004 14.941-2.004 4.219 0 8.074.387 11.567 1.16 3.492.774 6.656 1.899 9.492 3.375a32.403 32.403 0 0 1 7.629 5.485 37.377 37.377 0 0 1 5.906 7.418l-12.727 9.492c-2.578-4.125-5.625-7.22-9.14-9.282-3.516-2.062-7.805-3.093-12.868-3.093-5.484 0-9.832 1.125-13.042 3.375-3.211 2.25-4.817 5.437-4.817 9.562 0 2.063.434 3.785 1.3 5.168.868 1.383 2.204 2.59 4.009 3.621 1.804 1.032 4.078 1.957 6.82 2.778 2.742.82 5.988 1.675 9.738 2.566a193.01 193.01 0 0 1 8.473 2.25 67.888 67.888 0 0 1 7.805 2.777 38.465 38.465 0 0 1 6.785 3.727 22.237 22.237 0 0 1 5.308 5.168c1.477 2.016 2.637 4.371 3.48 7.066.845 2.696 1.267 5.824 1.267 9.387zM164 367.313l31.992-48.797L164.844 270h18.914l21.586 35.648L227.633 270h18.281l-31.5 48.094 31.36 49.219H227.07l-22.289-36.282-22.64 36.281z" fill="#fefefe" fill-rule="evenodd"></path></svg>"`
1514-
)
1511+
`"<svg width="500" height="500" viewbox="0 0 500 500" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M342.717 257.555H346.232C359.025 257.555 367.424 267.516 371.428 287.438C372.99 324.547 374.553 343.102 376.115 343.102C378.947 348.57 382.854 351.305 387.834 351.305C398.088 351.305 406.877 344.469 414.201 330.797C414.982 326.988 415.373 324.84 415.373 324.352C415.373 320.152 410.686 310.387 401.311 295.055C399.748 290.66 398.967 286.559 398.967 282.75C398.967 272.105 406.584 265.66 421.818 263.414C437.639 263.414 448.186 273.18 453.459 292.711V303.258C453.459 322.301 439.787 343.395 412.443 366.539C400.529 374.742 390.373 380.602 381.975 384.117L381.389 388.219C381.389 397.105 393.303 407.848 417.131 420.445C432.365 431.09 439.982 441.441 439.982 451.5C439.982 462.73 433.146 469.176 419.475 470.836H416.545C403.654 470.836 387.248 460.68 367.326 440.367L360.881 436.852C357.561 436.852 352.092 444.469 344.475 459.703C335.588 471.031 326.604 476.695 317.521 476.695H316.35C304.338 476.695 297.307 469.469 295.256 455.016V452.672C295.256 437.535 305.998 418.98 327.482 397.008C339.592 383.824 345.646 372.105 345.646 361.852V360.68C345.646 350.035 338.42 336.559 323.967 320.25C316.154 310.094 312.248 301.5 312.248 294.469V288.609C312.248 276.305 320.061 266.344 335.686 258.727C338.42 257.945 340.764 257.555 342.717 257.555Z" fill="#FF5A00"></path><path d="M257.756 268.102C274.553 268.102 287.248 276.695 295.842 293.883C298.576 300.23 299.943 306.285 299.943 312.047C299.943 329.332 291.74 341.246 275.334 347.789C273.088 348.57 270.549 348.961 267.717 348.961C255.51 348.961 247.111 341.93 242.521 327.867C241.057 315.758 239.689 309.703 238.42 309.703H237.834C234.709 311.559 233.146 315.074 233.146 320.25C233.146 331.188 243.498 348.961 264.201 373.57C274.748 389.391 280.021 405.016 280.021 420.445V421.031C280.021 448.668 267.131 466.637 241.35 474.938C237.639 475.719 234.709 476.109 232.561 476.109H227.287C206.389 476.109 188.42 464.391 173.381 440.953C167.912 428.551 165.178 418.199 165.178 409.898V402.867C165.178 387.438 172.209 375.523 186.271 367.125C191.35 365.172 195.842 364.195 199.748 364.195C214.201 364.195 225.334 372.008 233.146 387.633C233.928 391.246 234.318 394.176 234.318 396.422C234.318 406.578 226.701 415.562 211.467 423.375C209.123 424.938 207.756 426.695 207.365 428.648C207.365 433.141 214.006 436.266 227.287 438.023C245.256 435.973 254.24 428.16 254.24 414.586C254.24 401.988 245.256 383.434 227.287 358.922C217.131 343.004 212.053 328.941 212.053 316.734V315.562C212.053 293.688 223.771 278.258 247.209 269.273C252.971 268.492 256.486 268.102 257.756 268.102Z" fill="#FF5A00"></path><path d="M155.803 268.688H156.389C167.131 268.688 175.725 275.133 182.17 288.023C184.123 292.027 185.1 296.324 185.1 300.914V303.258C185.1 316.734 178.459 326.109 165.178 331.383L158.732 332.555C155.314 332.164 152.385 331.969 149.943 331.969H146.428C145.158 331.969 144.182 333.922 143.498 337.828C148.576 365.953 151.115 382.75 151.115 388.219V396.422C151.115 427.965 138.42 450.816 113.029 464.977C106.291 468.102 99.6504 469.664 93.1074 469.664H87.248C71.8184 469.664 59.709 461.266 50.9199 444.469C48.9668 439 47.9902 434.312 47.9902 430.406V424.547C47.9902 409.02 56.1934 395.738 72.5996 384.703C77.873 382.359 82.1699 381.188 85.4902 381.188H91.3496C97.502 381.188 102.58 384.508 106.584 391.148C107.756 393.004 108.342 395.543 108.342 398.766C108.342 403.355 104.045 412.145 95.4512 425.133C94.6699 427.672 94.2793 429.43 94.2793 430.406V430.992C94.6699 434.117 96.0371 435.68 98.3809 435.68C106.877 435.68 114.299 425.719 120.646 405.797C122.209 397.203 122.99 390.172 122.99 384.703V375.914C122.014 351.598 116.154 336.754 105.412 331.383C101.604 329.918 92.4238 327.965 77.873 325.523C65.7637 319.957 59.709 312.145 59.709 302.086C59.709 292.125 67.3262 285.289 82.5605 281.578C113.908 278.844 135.393 275.133 147.014 270.445C149.846 269.273 152.775 268.688 155.803 268.688Z" fill="#FF5A00"></path><path d="M410.832 31.6172H416.105C426.652 31.6172 436.418 36.3047 445.402 45.6797C453.605 55.6406 457.707 66.5781 457.707 78.4922C457.707 96.4609 446.574 119.117 424.309 146.461C415.324 158.18 410.832 166.969 410.832 172.828V173.414C410.832 174.293 411.809 174.879 413.762 175.172C418.742 175.172 431.633 168.336 452.434 154.664C459.562 150.758 465.617 148.805 470.598 148.805C480.266 148.805 487.102 154.859 491.105 166.969C491.887 169.898 492.277 172.633 492.277 175.172V179.859C492.277 199.781 482.121 215.211 461.809 226.148C455.461 228.492 449.016 229.664 442.473 229.664H441.887C439.152 229.664 427.434 228.492 406.73 226.148L382.707 229.664C373.723 229.664 368.645 223.414 367.473 210.914V209.742C367.473 194.02 381.145 168.434 408.488 132.984C421.77 114.82 428.41 98.4141 428.41 83.7656C428.41 78.5898 427.629 74.293 426.066 70.875C418.449 70.875 412.395 78.6875 407.902 94.3125C399.797 107.984 390.422 114.82 379.777 114.82H376.848C366.301 114.82 358.684 108.18 353.996 94.8984C353.605 90.0156 353.41 87.4766 353.41 87.2812C353.41 67.75 365.91 50.7578 390.91 36.3047C399.406 33.1797 406.047 31.6172 410.832 31.6172Z" fill="#FF5A00"></path><path d="M266.984 32.2031H270.5C295.402 32.2031 315.715 45.0938 331.438 70.875C339.25 86.6953 343.156 104.859 343.156 125.367C343.156 162.867 331.633 191.383 308.586 210.914C295.988 218.727 286.223 222.633 279.289 222.633C258.879 225.758 238.762 230.445 218.938 236.695C216.887 236.695 215.129 236.891 213.664 237.281C201.945 236.207 196.086 230.543 196.086 220.289V219.117C196.086 205.836 206.438 188.258 227.141 166.383C238.078 151.246 243.547 135.816 243.547 120.094C243.547 109.742 241.008 101.539 235.93 95.4844C231.145 98.2188 226.262 99.5859 221.281 99.5859H219.523C207.414 98.3164 201.359 92.2617 201.359 81.4219V80.8359C201.359 64.8203 213.664 50.7578 238.273 38.6484C247.844 34.3516 257.414 32.2031 266.984 32.2031ZM264.055 88.4531C266.398 105.445 267.57 115.992 267.57 120.094V121.266C267.57 128.688 264.836 143.922 259.367 166.969V173.414C260.93 184.742 266.203 190.406 275.188 190.406C302.141 175.758 315.617 155.055 315.617 128.297V123.609C315.617 100.465 307.609 83.082 291.594 71.4609C288.176 69.5078 284.66 68.5312 281.047 68.5312C271.379 68.5312 265.715 75.1719 264.055 88.4531Z" fill="#FF5A00"></path><path d="M149.211 24H149.797C165.91 24 177.629 38.4531 184.953 67.3594C186.516 76.2461 187.297 84.4492 187.297 91.9688C187.297 99.293 184.758 126.051 179.68 172.242V175.172C180.07 193.531 180.266 207.008 180.266 215.602C180.266 224.977 178.312 229.664 174.406 229.664C171.867 229.664 169.523 224.977 167.375 215.602L166.203 215.016C161.223 219.703 156.926 222.047 153.312 222.047C146.672 222.047 142.18 214.43 139.836 199.195C139.445 195.191 139.25 192.066 139.25 189.82C139.25 179.762 143.352 154.176 151.555 113.062C152.336 104.566 152.727 98.1211 152.727 93.7266C152.727 80.0547 150.188 70.875 145.109 66.1875C144.426 65.7969 143.645 65.6016 142.766 65.6016H142.18C138.762 65.6016 135.637 73.6094 132.805 89.625C131.73 97.0469 130.559 121.461 129.289 162.867C127.531 175.367 124.016 181.617 118.742 181.617C111.125 181.617 104.68 157.984 99.4062 110.719C93.0586 83.7656 85.0508 70.2891 75.3828 70.2891C69.6211 70.2891 66.3008 77.3203 65.4219 91.3828V91.9688C65.4219 104.273 70.3047 126.344 80.0703 158.18C82.0234 167.652 83 175.27 83 181.031C83 204.371 72.4531 219.996 51.3594 227.906C48.4297 228.688 45.6953 229.078 43.1562 229.078H41.3984C23.5273 229.078 12.3945 216.383 8 190.992C11.9062 180.934 17.9609 173.707 26.1641 169.312C42.5703 162.379 50.7734 154.371 50.7734 145.289V140.016C50.7734 137.77 47.8438 118.629 41.9844 82.5938V71.4609C41.9844 47.5352 49.4062 33.2773 64.25 28.6875C64.7383 28.2969 66.1055 28.1016 68.3516 28.1016H69.5234C80.0703 28.1016 92.1797 37.6719 105.852 56.8125C108.098 58.8633 110.441 60.6211 112.883 62.0859C115.715 61.6953 120.598 53.8828 127.531 38.6484C133.879 28.8828 141.105 24 149.211 24Z" fill="#FF5A00"></path></svg>"`)
15151512
})
15161513

15171514
it('handles nested HTML blocks of the same type (regression)', () => {
@@ -1856,7 +1853,7 @@ comment -->`)
18561853
)
18571854

18581855
expect(root.innerHTML).toMatchInlineSnapshot(
1859-
`"<details><summary>Solution</summary><pre><code class="language-jsx">import styled from &#x27;styled-components&#x27;;</code></pre></details>"`
1856+
`"<details><summary>Solution</summary><pre><code class="language-jsx lang-jsx">import styled from &#x27;styled-components&#x27;;</code></pre></details>"`
18601857
)
18611858
})
18621859

@@ -1919,7 +1916,7 @@ comment -->`)
19191916
)
19201917

19211918
expect(root.innerHTML).toMatchInlineSnapshot(`
1922-
"<div><pre><code class="language-kotlin">fun main() {
1919+
"<div><pre><code class="language-kotlin lang-kotlin">fun main() {
19231920
print(&quot;Hello world&quot;)
19241921
}</code></pre></div>"
19251922
`)
@@ -2022,7 +2019,7 @@ print("hello world")
20222019
)
20232020

20242021
expect(root.innerHTML).toMatchInlineSnapshot(
2025-
`"<div><p>Hello world example</p><pre><code data-start="2" class="language-python">print(&quot;hello world&quot;)</code></pre></div>"`
2022+
`"<div><p>Hello world example</p><pre><code data-start="2" class="language-python lang-python">print(&quot;hello world&quot;)</code></pre></div>"`
20262023
)
20272024
})
20282025

@@ -2151,7 +2148,7 @@ describe('fenced code blocks', () => {
21512148
render(compiler(['```js', 'foo', '```'].join('\n')))
21522149

21532150
expect(root.innerHTML).toMatchInlineSnapshot(
2154-
`"<pre><code class="language-js">foo</code></pre>"`
2151+
`"<pre><code class="language-js lang-js">foo</code></pre>"`
21552152
)
21562153
})
21572154

@@ -2168,7 +2165,7 @@ Yeah boi
21682165
)
21692166

21702167
expect(root.innerHTML).toMatchInlineSnapshot(`
2171-
"<pre><code class="language-html">&lt;!-- something --&gt;
2168+
"<pre><code class="language-html lang-html">&lt;!-- something --&gt;
21722169
Yeah boi</code></pre>"
21732170
`)
21742171
})

0 commit comments

Comments
 (0)