[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Slightly OT: Help needed with asynchronuous function call in JavaScr
From: |
David Kastrup |
Subject: |
Re: Slightly OT: Help needed with asynchronuous function call in JavaScript |
Date: |
Wed, 24 Jun 2015 07:41:57 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Urs Liska <address@hidden> writes:
> Hey all,
>
> I'm testing a way to integrate syntax highlighted LilyPond code in a
> GitBook book. I'm quite happy so far with everything (particularly
> because I could finally pick up an idea that might eventually lead to
> colored code examples in the LilyPond manuals).
Not likely: we are not going to run server-side on-demand colorization.
Too expensive.
> But I'm stuck with the problem of getting to the highlighted HTML out of
> the function and back into the book. The problem is obviously related to
> asynchronuous function calling, which I simply don't understand well
> enough (well, I don't really know JavaScript/Node.js).
>
> I'd be glad if someone with the relevant experience could have a look at
> this:
> https://git.ursliska.de/openlilylib/book/commit/e37710bf6523536aaff7b17ba67b9fcc2718f6da
>
> It's somewhat sketchy, not everything expresses my real ideas.
> I assume that when line 87 tries to read the temporary file this hasn't
> been written by the called Python script yet.
I have no clue about JavaScript, but if the Exec call returns a "child",
you should be able to wait for completion of that child with a function
called sys.wait or similar.
It might also be possible to make the output file a "named pipe" before
starting the program, but that's very system-specific and tricky. It
might be easier to tell the program to write its output to standard
output and find a corresponding JavaScript call that calls a program and
collects its output.
--
David Kastrup