-
Notifications
You must be signed in to change notification settings - Fork 45
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
Report all syntax errors in Markdown files #389
Report all syntax errors in Markdown files #389
Conversation
There is a small side effect which is that errors with labels are reported with the entire block location. I think it's not too bad, especially given how precise the error messages usually are, there should be no ambiguity as to where the error comes from. We can eventually try to refine error locations even further but since we have no editor integration at the moment I see little incentive for it. |
Finally, this does not impact I'll work on the mli side of things next but doing it separately should ease the review! |
6da7421
to
afa20e1
Compare
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
afa20e1
to
00dc7d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I think it is fair to leave the fix for the error locations here, untangling it would probably create more work than it is worth, although it would be somewhat simpler to review.
In general I think it is fair to move the parsing out of the lexer, which also makes programming a bit easier in a file that is actual OCaml syntax instead of ocamllex
. And well, it is more parsing than lexing anyway.
The code is fine, I don't have anything big to note. Just a few comments on the points that took me longer to understand with suggestions how to improve them.
test/bin/mdx-test/failure/part-unsupported/test-case.md.expected
Outdated
Show resolved
Hide resolved
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I think it is ready to be merged.
CHANGES: #### Added - Report all parsing errors in Markdown files (realworldocaml/mdx#389, @NathanReb) #### Changed - Preserve indentation in multiline OCaml blocks in .mli files (realworldocaml/mdx#395, @panglesd) #### Fixed - Fixed compatibility with Cmdliner 1.1.0 (realworldocaml/mdx#371, @Leonidas-from-XIV) - Report errors and exit codes of toplevel directives (realworldocaml/mdx#382, @talex5, @Leonidas-from-XIV) - Fix block locations in error reporting (realworldocaml/mdx#389, @NathanReb) - Include the content of the line that features the `part-end` MDX directive in the output, before that line would've been dropped (realworldocaml/mdx#374, realworldocaml/mdx#387, @Leonidas-from-XIV) - Handle EINTR signal on waitpid call by restarting the syscall. (realworldocaml/mdx#409, @tmcgilchrist) - Fix parsing of multiline toplevel phrases in .mli files (realworldocaml/mdx#394, realworldocaml/mdx#397, @Leonidas-from-XIV) #### Removed - Removed warning about missing semicolons added in MDX 1.11.0 and the automatic insertion of semicolons in the corrected files introduced in MDX 2.0.0. (realworldocaml/mdx#398, @Leonidas-from-XIV)
This PR improves the MDX workflow by making sure that all parsing errors are reported at once rather than exiting on the first errors.
Obviously that only impacts errors that we can recover from e.g. mis-used or missing labels, syntax error inside a block but not for errors such as invalid markdown.
We used to do all the work in markdown/cram parser. I changed that to extract raw bits of data from the parser and leave their interpretation to a later pass.
While working on this I discovered that the locations we attach to blocks are incorrect due to inconsistencies in
eol
handling in the lexer code which I took the liberty to fix as part of this PR. I can eventually extract it as a separate PR depending on this one if you'd like but basing it on this work made it significantly simpler.