-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not use temporary files for adoc generation, closes #54
- Loading branch information
1 parent
1a2319b
commit b67c4cc
Showing
4 changed files
with
49 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Footer text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$num_words = "eight"; | ||
print "There are "; | ||
print $num_words; | ||
print " words altogether in this sentence.\n"; |
b67c4cc
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.
FWIW 'asciidoctor_binary_path' is not obviously being used although defined in L157 above, even though I think L158 should work fine (I cannot see the problem I am experiencing in #33)
Hmmm... Maybe I can. Partially. The white screen is what I get when I receive a clean exit from Asciidoctor. Sometimes I overload the same ids in a document and in the "long document" I checked I also had an Asciidoctor warning (even though I sloppily did not mention it):
Sometimes Asciidoctor (at least partially) misreports errors. These warnings are actually valid.
I don't think it is safe to assume any output on stderr is actually an error (see here) instead it may be diagnostic or even informative. In general I don't think this is a safe assumption on *nix based systems. I know that seems counterintuitive...
Either way I don't think we want
WARNING
to prevent preview generation.b67c4cc
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.
Yes, I see that previously we were not relying on stderr but getting a more direct indication from asciidoctor of an error. I suggest we try to reinstate this.
b67c4cc
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.
Usign spawn() with the default shell: false instead of exec() was causing an unhandled exception (file not found for the default "asciidoctor" path), this prevented the error from being shown in the html. Should be fixed by 43faf6e .
I have tested by setting the wrong binary path, seems to be fine, but please let me know if it worked for your error case.
b67c4cc
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.
OK. I do not know why and will look into this further at another time but the problem is if a stylesheet is set within an asciidoc file the user gets a "white screen" problem with no errors and no document in the DOM. However when debugging the code the information is all there. It appears it is not handled correctly by VS Code.
b67c4cc
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.
All you need to test this is the default stylesheet (asciidoctor.css) and a simple document like:
Removing the stylesheet directive causes the preview to function correctly.
In the previous code this did not occur.
b67c4cc
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.
Regarding stderr. Perhaps that's OK to use if we also pass
-q
, or--quiet
to silence warnings.b67c4cc
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.
b67c4cc
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.
So no blank screen for you with the attached?
Test.zip
b67c4cc
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.
OK, something weird about the direct import of fontawesome here which I'll look into further. I think
-q
is a good idea. At the end of the day this code seems to be fine.b67c4cc
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.
OK. Here comes the bad news.
I think there's (yet another!) buffer limit.
Explanation:
The following issue suggests there's a 200 kB limit:
b67c4cc
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.
This is not a very good explanation above, so I keep meandering.
On about L93-L97 I did:
And then at about L180:
This gives me a debug output of:
That number 65536 feels like some kind of limit.
I don't really understand JS promises/resolve so I am hoping this makes more sense to you than it does to me 😄
b67c4cc
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.
I think I understand the problem but my JS is too weak to fix it.
The promise should only be resolved when the process is finished. So we should have something like:
I think the current implementation stops after the first 64K chunk on
stdout
comes through. Unfortunately in the above code theresolve(this.buildPage(result));
is not working for mysterious reasons.b67c4cc
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.
The good news, I can reproduce the problem with the attached zip adoc.
The bad news, I have moved the write() call after the stdout.on() call which would prevent the issue nodejs/node#4236 .
I will do some more research, If we don't find a workaround I will revert to the exec()/buffer setting for the ruby asciidoc option. If your debug output was from a single run, it's an easy fix, it means stdout.on is called multiple times because the output is too big, and we need to concatenate the results :)
b67c4cc
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.
b67c4cc
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.
I have applied the fix with 503d8c1 but it leaves several questions. I am also very new to nodejs/asynchronous model programming, I am not sure how to deal with the multiple events being delivered with content pieces, and how they "compose" the content with the resolve() call.
Need to read more :(
b67c4cc
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.
After reading again https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options , and noticing the 'close' event example I was able to create a new fix that makes sense:
1ca309c
I assume on.stdout can be called multiple times (because of it's async nature). And we must concatenate the results, if we want to gather the data until the 'close' event is received.
So the issue was not the buffer limit per si (that 64k value is probably the asciiidoctor output buffering), but the fact that it was being chunked with multiple on_data calls, as the data is received.
b67c4cc
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 great -- thanks for caring about all these things. I will test this evening or tomorrow morning.
b67c4cc
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 @joaompinto. Works like a charm now. 👍