-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
Introduce an async convert #644
base: main
Are you sure you want to change the base?
Conversation
|
||
# If a VFS is defined, Asciidoctor will use it to resolve the include target. | ||
# Otherwise use the file system or the network to read the file. | ||
def read_include_content inc_path, target_type |
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.
@mojavelinux preprocess_include_directive
method is almost identical, I've just replaced File.open
with the new read_include_content
method.
4e17c44
to
c9a1041
Compare
It's annoying that Node.js doesn't provide this out of the box. I run into the same problem whenever I switch to async operations. |
I'm not sure that overriding/importing large chunks of Asciidoctor core is the right idea here. But I'm also still at a loss for exactly how to handle this. We don't really have a true preprocessor that avoids side effects in Asciidoctor, and the include directive is inherently synchronous. This is topic I think we need to consider in the AsciiDoc Language project, then carry out whatever we decide after the architecture is worked out there. |
Reader
class in Asciidoctor core has a new methodread_include_content
convertAsync
function will fetch the content of all the unconditional includes and populate the VFS.Performance wise it about the same speed for local files but since the event loop is not blocked (or at least less blocked), the performance should be better on a running application.
I think we should be careful about how many asynchronous remote calls we can make at once. We may need to set a limit to avoid resource exhaustion.
Using a cache greatly improve performance if a remote file is present more than once in the document. For reference
open-uri/cached
module used in Asciidoctor Ruby is not available in JavaScript.