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

Fix error message from include directive on first line of AsciiDoc table cell #4571

Closed
mblythe86 opened this issue Mar 26, 2024 · 3 comments
Closed
Assignees
Labels
improvement v2.0.23 Issues resolved in the 2.0.23 release
Milestone

Comments

@mblythe86
Copy link
Contributor

mblythe86 commented Mar 26, 2024

Example asciidoc file:

== Testing an include within a table

include::does_not_exist.adoc[]

|===
| *A* | *B*

| some text
a| include::does_not_exist.adoc[]
|===

Expectation

Expected output (simplified HTML):

Testing an include within a table

Unresolved directive in table_include.adoc - include::does_not_exist.adoc[]

A B

some text

Unresolved directive in table_include.adoc - include::does_not_exist.adoc[]

Expected errors:

asciidoctor: ERROR: table_include.adoc: line 3: include file not found: /path/to/does_not_exist.adoc
asciidoctor: ERROR: table_include.adoc: line 8: include file not found: /path/to/does_not_exist.adoc

Reality

Actual output (simplified HTML):

Testing an include within a table

Unresolved directive in table_include.adoc - include::does_not_exist.adoc[]

A B

some text

Unresolved directive in <stdin> - include::does_not_exist.adoc[]

Actual errors:

asciidoctor: ERROR: table_include.adoc: line 3: include file not found: /path/to/does_not_exist.adoc
asciidoctor: ERROR: <stdin>: line 1: include file not found: /path/to/does_not_exist.adoc

Details

This poor error message makes it more difficult to identify the location of the error. Fixing this would enable users to more quickly identify and fix problems in their asciidoc files.

Tested using asciidoctor v2.0.16, but I am confident that the issue persists in v2.0.22 because I've root caused the problem to this line of code. The PreprocessorReader constructor accepts an optional 3rd parameter, cursor, that provides the details of what file is being parsed and the location within that file, and that is not being provided here.

Shortly, I'll submit a simple pull request to fix this issue.

@mojavelinux
Copy link
Member

The reason is a bit more complicated than this. An AsciiDoc table cell is permitted to start directly after a cell separator rather than on the next line. In this situation, an artificial line is created that has no cursor information. As a result, if there's a warning or error that occurs on that line, then it is missing cursor information. Had the include directive been moved to the next line, the line information would have been correct. I need to see if I can create a synthetic cursor for this first line so that any error or warning that occurs on that first line is reported properly.

@mojavelinux
Copy link
Member

mojavelinux commented May 16, 2024

The proposed fixed just happens to work (we got lucky).

mojavelinux pushed a commit to mblythe86/asciidoctor that referenced this issue May 16, 2024
@mojavelinux
Copy link
Member

Btw, we always recommend starting the contents of an AsciiDoc table cell on the following line. It's a convenience that it is allowed to start on the same line as the cell separator, but not recommended.

mojavelinux pushed a commit to mblythe86/asciidoctor that referenced this issue May 16, 2024
@mojavelinux mojavelinux changed the title Fix error message from include macros within tables Fix error message from include directive on first line of AsciiDoc table cell May 16, 2024
@mojavelinux mojavelinux added the v2.0.23 Issues resolved in the 2.0.23 release label May 16, 2024
mojavelinux pushed a commit that referenced this issue May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement v2.0.23 Issues resolved in the 2.0.23 release
Projects
None yet
Development

No branches or pull requests

2 participants