Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readable throws an error when it encounters multi line link element #18

Closed
m-spitfire opened this issue Jan 23, 2023 · 2 comments · Fixed by #19
Closed

Readable throws an error when it encounters multi line link element #18

m-spitfire opened this issue Jan 23, 2023 · 2 comments · Fixed by #19

Comments

@m-spitfire
Copy link

m-spitfire commented Jan 23, 2023

File to reproduce (minimal.md):

We want to convert this into an error. In some cases, there may be an
existing error for this scenario. In others, we will need to allocate a
fresh diagnostic code.  [Instructions for allocating a fresh diagnostic
code can be found here.](./diagnostics/diagnostic-codes.md) You may want
to mention in the extended description that the compiler behavior
changed on this point, and include a reference to the tracking issue for
the change.

Running

readable check minimal.md

On master and v2.2 it throws error:

ERROR failed to render '/home/muradb/personal/rustc-dev-guide/minimal.md', aborting: Error: Cannot take length of multi-line node '[object Object]'
Toggle full backtrace of error
Error: Cannot take length of multi-line node '[object Object]'
    at nodeLength (file:///home/muradb/personal/readable/markdown/ast.ts:92:16)
    at ReflowParagraphState.addRawNode (file:///home/muradb/personal/readable/plugins/readable/reflow.ts:84:31)
    at processParent (file:///home/muradb/personal/readable/plugins/readable/reflow.ts:288:41)
    at reflowParagraph (file:///home/muradb/personal/readable/plugins/readable/reflow.ts:321:3)
    at visit (file:///home/muradb/personal/readable/plugins/readable/reflow.ts:335:9)
    at file:///home/muradb/personal/readable/plugins/readable/reflow.ts:338:42
    at Array.forEach (<anonymous>)
    at visit (file:///home/muradb/personal/readable/plugins/readable/reflow.ts:338:23)
    at transformer (file:///home/muradb/personal/readable/plugins/readable/reflow.ts:344:5)
    at wrapped (https://jspm.dev/npm:trough@1.0.5!cjs:21:19)

Upon further having some console.log s in nodeLength function, it's clear that the error occurs because of link element in the example, specifically when it tries to check for if node is literal:

if (isLiteralNode(n)) return n.value.length;

which link element is not, so it just throws error. I am not sure about the whole codebase, but if you tell me what's it supposed to do when it encounters a link element, I can send a pull request.

@bobheadxi
Copy link
Owner

Thanks for reporting this - #19 should fix it :)

@m-spitfire
Copy link
Author

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants