Re: Patch proposal: DocBook support for lilypond-book
I have created a patch now. Attached. Thanks, Bert Han-Wen Nienhuys írta: Bertalan Fodor schreef: Anyone interested? Should I create a patch? Against which version? Any suggestions? Can you also add a relevant section to the manual? Thanks! --- lilypond-book.itely 2006-10-24 09:52:29.082028400 +0200 +++ lilypond-book-docbook.itely 2006-10-24 09:52:11.065942200 +0200 @@ -28,13 +28,14 @@ substituted for the music. The line width and font size definitions for the music are adjusted to match the layout of your document. -This procedure may be applied to [EMAIL PROTECTED], HTML or Texinfo documents. +This procedure may be applied to [EMAIL PROTECTED], HTML, Texinfo or DocBook documents. @menu * An example of a musicological document:: * Integrating LaTeX and music:: * Integrating Texinfo and music:: * Integrating HTML and music:: +* Integrating DocBook and music:: * Music fragment options:: * Invoking lilypond-book:: * Filename extensions:: @@ -50,11 +51,12 @@ @cindex [EMAIL PROTECTED], music in @cindex HTML, music in @cindex Texinfo, music in [EMAIL PROTECTED] DocBook, music in Some texts contain music examples. These texts are musicological treatises, songbooks, or manuals like this. Such texts can be made by hand, simply by importing a PostScript figure into the word processor. However, there is an automated procedure to reduce the amount of work -involved in HTML, [EMAIL PROTECTED], and Texinfo documents. +involved in HTML, [EMAIL PROTECTED], Texinfo and DocBook documents. A script called @code{lilypond-book} will extract the music fragments, format them, and put back the resulting notation. Here we show a small @@ -155,6 +157,7 @@ @cindex texinfo @funindex texi @cindex html [EMAIL PROTECTED] docbook @cindex documents, adding music to @@ -470,6 +473,59 @@ @cindex preview image @cindex thumbnail [EMAIL PROTECTED] Integrating DocBook and music [EMAIL PROTECTED] Integrating DocBook and music + +For inserting LilyPond snippets it is good to keep the conformity of our DocBook document, thus allowing us to use DocBook +editors, validation etc. So we don't use custom tags, only specify a convention based on the standard DocBook elements. + [EMAIL PROTECTED] Common conventions + +For inserting all type of snippets we use the @code{mediaobject} and @code{inlinemediaobject} element, so our snippets can be +formatted inline or not inline. +The snippet formatting options are always provided in the @code{role} property of the innermost element (see in next sections). Tags are +chosen to allow DocBook editors format the content gracefully. +The DocBook files to be processed with @command{lilypond-book} should have the extension @file{.lyxml}. + [EMAIL PROTECTED] Including a LilyPond file + +This is the most simple case. We must use the @file{.ly} extension for the included file, and insert it as a standard @code{imageobject}, +with the following structure: + [EMAIL PROTECTED] +mediaobject + imageobject +imagedata fileref=music1.ly role=printfilename / + /imageobject +/mediaobject [EMAIL PROTECTED] example + +Note that you can use mediaobject or inlinemediaobject as the outermost element as you wish. + [EMAIL PROTECTED] Including LilyPond code + +Including LilyPond code is possible by using a @code{programlisting}, where the language is set to @code{lilypond} with the following structure: + [EMAIL PROTECTED] +inlinemediaobject + textobject +programlisting language=lilypond role=fragment verbatim staffsize=16 ragged-right relative=2 +\context Staff \with { + \remove Time_signature_engraver + \remove Clef_engraver} + { c4( fis) } +/programlisting + /textobject +/inlinemediaobject [EMAIL PROTECTED] example + +As you can see, the outermost element is a @code{mediaobject} or @code{inlinemediaobject}, and there is a @code{textobject} containing the @code{programlisting} inside. + [EMAIL PROTECTED] Processing the DocBook document + +Running @command{lilypond-book} on our @file{.lyxml} file will create a valid DocBook document to be further processed with @file{.xml} extension. +If you use @uref{http://@/dblatex@/.sourceforge@/.net@/,dblatex}, it will create a PDF file from this document automatically. +For HTML (HTML Help, JavaHelp etc.) generation you can use the official DocBook XSL stylesheets, however, it is possible that you have to make some customization for it. @node Music fragment options @section Music fragment options @@ -623,8 +679,8 @@ @section Invoking @command{lilypond-book} @command{lilypond-book} produces a file with one of the following -extensions: @file{.tex}, @file{.texi}, or @file{.html}, depending on the -output format. Both @file{.tex} and @file{.texi} files need further +extensions: @file{.tex}, @file{.texi}, @file{.html} or @file{.xml}, depending on the +output format. All of @file{.tex}, @file{.texi} and @{.xml} files need further processing. @command{lilypond-book}
Re: Patch proposal: DocBook support for lilypond-book
Should I create a patch? Against which version? Any suggestions? Can you also add a relevant section to the manual? Thanks! I've updated the lilypond-book.itely. Attached. Sorry I have not created a patch, I don't have access now to any computer with diff utils. lilypond-book-docbook.itely Description: Binary data ___ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Patch proposal: DocBook support for lilypond-book
Bertalan Fodor schreef: Anyone interested? Should I create a patch? Against which version? Any suggestions? Can you also add a relevant section to the manual? Thanks! -- Han-Wen Nienhuys - [EMAIL PROTECTED] - http://www.xs4all.nl/~hanwen LilyPond Software Design -- Code for Music Notation http://www.lilypond-design.com ___ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Patch proposal: DocBook support for lilypond-book
Attached. Bert Han-Wen Nienhuys írta: Bertalan Fodor schreef: Hello, I've created an enhancement for lilypond-book allowing us to use it with DocBook documents. Specification and examples can be read at http://www.organum.hu/fileadmin/lilypondtool/lily-docbook.pdf The enhanced script is at http://www.organum.hu/fileadmin/lilypondtool/lilypond-book.py I created the docbook document with XmlMind xml editor. The pdf rendering has been made with dblatex under cygwin (thanks Jan we have a tetex there :-) ) Anyone interested? Should I create a patch? Against which version? Any suggestions? yes please, against 2.9 CVS --- lilypond-book.py2006-10-18 10:39:17.233367000 +0200 +++ lilypond-book-docbook.py2006-10-18 10:51:04.409618000 +0200 @@ -67,7 +67,7 @@ backend = 'ps' help_summary = _ ( -'''Process LilyPond snippets in hybrid HTML, LaTeX, or texinfo document. +'''Process LilyPond snippets in hybrid HTML, LaTeX, texinfo or DocBook document. Example usage: @@ -132,7 +132,7 @@ help=_ (pipe snippets through FILTER [convert-ly -n -]), default=None) p.add_option ('-f', '--format', - help=_('''use output format FORMAT (texi [default], texi-html, latex, html)'''), + help=_('''use output format FORMAT (texi [default], texi-html, latex, html, docbook)'''), action='store') p.add_option (-I, '--include', help=_('add DIR to include path'), @@ -191,6 +191,7 @@ # AFTER = 'after' BEFORE = 'before' +DOCBOOK = 'docbook' EXAMPLEINDENT = 'exampleindent' FILTER = 'filter' FRAGMENT = 'fragment' @@ -239,6 +240,43 @@ # (?x) -- Ignore whitespace in patterns. no_match = 'a\ba' snippet_res = { + ## +DOCBOOK: { +'include': + no_match, + +'lilypond': + r'''(?smx) + (?Pmatch + (?Pinline(inline)?)mediaobject\s*textobject.*?\s*programlisting\s+language=lilypond.*?(role=(?Poptions.*?))?(?Pcode.*?)/programlisting\s*\s*/textobject\s*\s*/(inline)?mediaobject)''', + +'lilypond_block': + r'''(?smx) + (?Pmatch + (?Pinline(inline)?)mediaobject\s*textobject.*?\s*programlisting\s+language=lilypond.*?(role=(?Poptions.*?))?(?Pcode.*?)/programlisting\s*\s*/textobject\s*\s*/(inline)?mediaobject)''', + +'lilypond_file': + r'''(?smx) + (?Pmatch + (?Pinline(inline)?)mediaobject\s*imageobject.*?\s*imagedata\s+fileref=(?Pfilename.*?\.ly)\s*(role=(?Poptions.*?))?\s*(/|\s*/imagedata)\s*/imageobject\s*/(inline)?mediaobject)''', + +'multiline_comment': + r'''(?smx) + (?Pmatch + \s*([EMAIL PROTECTED]) + (?Pcode!--\s.*?!--) + \s)''', + +'singleline_comment': + no_match, + +'verb': + no_match, + +'verbatim': + no_match, + +}, ## HTML: { 'include': @@ -436,6 +474,10 @@ format_res = { +DOCBOOK: { + 'intertext': r',?\s*intertext=\.*?\', +'option_sep': '\s*', +}, HTML: { 'intertext': r',?\s*intertext=\.*?\', 'option_sep': '\s*', @@ -506,6 +548,21 @@ output = { ## +DOCBOOK: { +FILTER: r'''mediaobjecttextobjectprogramlisting language=lilypond role=%(options)s%(code)s/programlisting/textobject/mediaobject''', + +OUTPUT: r''' +imageobject role=latex + imagedata fileref=%(base)s.pdf format=PDF/ + /imageobject + imageobject role=html + imagedata fileref=%(base)s.png format=PNG//imageobject''', + +VERBATIM: r'''programlisting%(verb)s/programlisting''', + +PRINTFILENAME: 'textobjectsimparaulink url=%(base)s.lyfilename%(filename)s/filename/ulink/simpara/textobject' +}, +## HTML: { FILTER: r'''lilypond %(options)s %(code)s @@ -1104,6 +1161,22 @@ images = tuple (images) return images +def output_docbook (self): +str = '' +base = self.basename () +for image in self.get_images (): +(base, ext) = os.path.splitext (image) +str += output[DOCBOOK][OUTPUT] % vars () + str += self.output_print_filename (DOCBOOK) +if (self.substring('inline') == 'inline'): +str = 'inlinemediaobject' + str + '/inlinemediaobject' +else: +str = 'mediaobject' + str + '/mediaobject' +if VERBATIM in self.option_dict: +verb = verbatim_html (self.substring ('code')) +str = output[DOCBOOK][VERBATIM] % vars () + str +return str + def output_html (self): str = '' base = self.basename () @@ -1371,7 +1444,8 @@ if global_options.format in (HTML, TEXINFO): cmd += ' --formats=png ' - +if global_options.format in (DOCBOOK): +cmd += ' --formats=png,pdf '
Patch proposal: DocBook support for lilypond-book
Hello, I've created an enhancement for lilypond-book allowing us to use it with DocBook documents. Specification and examples can be read at http://www.organum.hu/fileadmin/lilypondtool/lily-docbook.pdf The enhanced script is at http://www.organum.hu/fileadmin/lilypondtool/lilypond-book.py I created the docbook document with XmlMind xml editor. The pdf rendering has been made with dblatex under cygwin (thanks Jan we have a tetex there :-) ) Anyone interested? Should I create a patch? Against which version? Any suggestions? Thanks, Bert ___ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Patch proposal: DocBook support for lilypond-book
Bertalan Fodor schreef: Hello, I've created an enhancement for lilypond-book allowing us to use it with DocBook documents. Specification and examples can be read at http://www.organum.hu/fileadmin/lilypondtool/lily-docbook.pdf The enhanced script is at http://www.organum.hu/fileadmin/lilypondtool/lilypond-book.py I created the docbook document with XmlMind xml editor. The pdf rendering has been made with dblatex under cygwin (thanks Jan we have a tetex there :-) ) Anyone interested? Should I create a patch? Against which version? Any suggestions? yes please, against 2.9 CVS -- Han-Wen Nienhuys - [EMAIL PROTECTED] - http://www.xs4all.nl/~hanwen LilyPond Software Design -- Code for Music Notation http://www.lilypond-design.com ___ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel