0

I am working with music notation software called lilypond. It is able to compile text-like notation markup language of it's own, into various formats, among them png file.

Another command which comes with lilypond is it's companion lilypond-book, which will compile any document containing <lilypond> tag, and put in that place code snippet like this one:

<p>
    <a href="10/lily-9f8f7b5d.ly">
    <img align="middle" border="0" src="10/lily-9f8f7b5d.png"
    alt="[image of music]">
    </a>
</p>

So my wish, as a huge fan of VIM is to use it's filtering capabilities and automate this kind of job, so for example when I'm in a document like this one:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>html-with-notation</title>
    </head>
    <body>
        This is some text, before including lilypond notation file

        And here is the melody:
        <lilypondfile>andantino.ly</lilypondfile>/* <-- TAG THAT WILL BE RECOGNIZED BY LILYPOND-BOOK  */

        Enjoy!

    </body>
</html>

..I would like to replace that <lilypond> tag, with the generated output from lilypond-book command. But it's not that simple, because lilypond-book does not write to a stdout but to a file, called stdin.html. (it names it like that automatically, recognizing that the input is comming from there)

So while running this:

:.!lilypond-book -f html - 2>/dev/null
        // ( with errors redirected to `/dev/null` to prevent polluting my buffer with messages being output.)

I don't get back nothing, which of course is expected, as all of the output has gone to a file.

How would I now read back that stdin.html file after all processing is done from the part of lilypond-book, into that current line I am on, in my vim buffer? All in one go, of course, without doing manually :r stdin.html.

Also as a bonus, would it be possible before reading that stdin.html into a buffer, process it with pandoc to convert it into a markdown first, in cases when I am working on markdown files?

branquito
  • 3,864
  • 5
  • 35
  • 60

1 Answers1

1

You could say

:.!lilypond-book -f html - 2>/dev/null && cat stdin.html
OhleC
  • 2,821
  • 16
  • 29
  • I never thought of doing that ;) Is it possible after that to append normal mode commands, to indent properly newly inserted code? – branquito Sep 19 '14 at 22:30
  • At that point I would probably write a vimscript function for the whole process – OhleC Sep 19 '14 at 22:56