Skip to content

"break" nodes not handled and cause a TypeError exception #5

Closed
@staltz

Description

@staltz

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)

Affected packages and versions: nlcst-to-string >=2.0.4 (at least, maybe older too)

Steps to reproduce

If there are trailing whitespaces at the end of a line, it seems to get parsed as type: break in Markdown, which nlcst-to-string doesn't know how to convert to string.

Link to code example: https://codesandbox.io/s/remark-debug-forked-hh0ub?file=/src/index.js

Example AST subtree containing breaks:

[ { type: 'text',
    value: 'Mobile: @6RpN4Ztw3jLwzQtHl8XpnnR58LWZTAjwq2vvfyx7zkc=.ed25519',
    position: 
     { start: { line: 3, column: 1, offset: 53 },
       end: { line: 3, column: 62, offset: 114 },
       indent: [] } },
  { type: 'break',
    position: 
     { start: { line: 3, column: 62, offset: 114 },
       end: { line: 4, column: 1, offset: 117 },
       indent: [ 1 ] } },
  { type: 'text',
    value: 'Desktop: @lOUVT+Phkvai9a/cCS/RKo+S9hnPAQdVixms/7ldpPA=.ed25519',
    position: 
     { start: { line: 4, column: 1, offset: 117 },
       end: { line: 4, column: 63, offset: 179 },
       indent: [] } },
  { type: 'break',
    position: 
     { start: { line: 4, column: 63, offset: 179 },
       end: { line: 5, column: 1, offset: 182 },
       indent: [ 1 ] } },
  { type: 'text',
    value: 'Pub: @5XaVcAJ5DklwuuIkjGz4lwm2rOnMHHovhNg7BFFnyJ8=.ed25519',
    position: 
     { start: { line: 5, column: 1, offset: 182 },
       end: { line: 5, column: 59, offset: 240 },
       indent: [] } } ]

Expected behavior

No crash or exception thrown in the JS engine. The stringification should complete and break nodes should be considered empty string.

Actual behavior

Uncaught JS exception:

[TypeError: Cannot read property 'length' of undefined]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions