groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff-commit] groff/contrib/lilypond groff_lilypond.man groff...


From: Bernd Warken
Subject: [Groff-commit] groff/contrib/lilypond groff_lilypond.man groff...
Date: Sun, 10 Feb 2013 01:44:54 +0000

CVSROOT:        /cvsroot/groff
Module name:    groff
Changes by:     Bernd Warken <bwarken>  13/02/10 01:44:54

Added files:
        contrib/lilypond: groff_lilypond.man groff_lilypond.pl 

Log message:
        Add new files for groff/contrib/lilypond.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/groff/contrib/lilypond/groff_lilypond.man?cvsroot=groff&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/groff/contrib/lilypond/groff_lilypond.pl?cvsroot=groff&rev=1.1

Patches:
Index: groff_lilypond.man
===================================================================
RCS file: groff_lilypond.man
diff -N groff_lilypond.man
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ groff_lilypond.man  10 Feb 2013 01:44:54 -0000      1.1
@@ -0,0 +1,313 @@
+.TH groff_lilypond @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
+.SH NAME
+groff\-lilypond \[em] integrate \f[CI]lilypond\f[] parts into \f[CI]groff\f[]
+.
+.\" The .SH was moved to this place in order to appease `apropos'.
+.
+.\" --------------------------------------------------------------------
+.\" Legalese
+.\" --------------------------------------------------------------------
+.
+.de authors
+This file was written by Bernd Warken
+.MT address@hidden
+.ME .
+..
+.
+.
+.de copying
+Copyright \(co 2013
+.RS
+.ft CI
+Free Software Foundation, Inc.
+.ft R
+.RE
+.
+.P
+This file is part of
+.ft CI
+groff\\f[R], a free software project.
+.
+.P
+You can redistribute it and/or modify it under the terms of the
+.nh
+.ft CI
+GNU General Public License
+.ft R
+.hy
+as published by the
+.nh
+.ft CI
+Free Software Foundation (FSF)\\f[R],
+.hy
+either version 3 of the License, or (at your option) any later version.
+.
+.P
+You should have received a copy of the
+.nh
+.ft CI
+GNU General Public License
+.ft R
+.hy
+along with
+.ft CI
+groff\\f[R],
+see the files
+.nh
+.ft CB
+COPYING
+.ft R
+and
+.ft CB
+LICENSE
+.ft R
+.hy
+in the top directory of the
+.ft CI
+groff
+.ft R
+source package.
+.
+.P
+You can also visit
+.UR http://\\:www.gnu.org/\\:licenses
+.UE .
+..
+.
+.
+.\" --------------------------------------------------------------------
+.\" Setup
+.\" --------------------------------------------------------------------
+.
+.ds1 Ellipsis "\&.\|.\|.\&\"
+.
+.
+.\" --------------------------------------------------------------------
+.\" Macro definitions
+.\" --------------------------------------------------------------------
+.
+.\" --------------------------------------------------------------------
+.\" .FONT (<font name> <text> [<font name> <text> ...])
+.\"
+.\" Print in different fonts: R, I, B, CR, CI, CB
+.\"
+.de1 FONT
+.  if (\\n[.$] = 0) \{\
+.      nop \&\f[P]\&
+.      return
+.  \}
+.  ds result \&
+.  while (\\n[.$] >= 2) \{\
+.      as result \,\f[\\$1]\\$2
+.      if !"\\$1"P" .as result \f[P]
+.      shift 2
+.  \}
+.  if (\\n[.$] = 1) .as result \,\f[\\$1]
+.  nh
+.  nop \\*[result]\&
+.  hy
+..
+.
+.
+.\" --------------------------------------------------------------------
+.\" SH "SYNOPSIS"
+.\" --------------------------------------------------------------------
+.
+.SY groff_lilypond
+.OP --
+.OP \%filespec
+.YS
+.
+.SY groff_lilypond
+.BR -h | --help
+.YS
+.
+.SY groff_lilypond
+.BR -v | --version
+.YS
+.
+.
+.\" --------------------------------------------------------------------
+.SH DESCRIPTION
+.\" --------------------------------------------------------------------
+.
+.FONT CB groff_lilypond
+transforms sheet music in the
+.FONT CI lilypond
+language in a
+.FONT CI groff
+file such that
+.FONT CB groff
+can display them.
+.
+.
+.P
+Without arguments,
+.FONT CB groff_lilypond
+reads from standard input.
+.
+A single file can be given as an argument.
+.
+.
+.\" --------------------------------------------------------------------
+.SH "HOW THE TRANSFORMATION WORKS"
+.\" --------------------------------------------------------------------
+.
+A
+.FONT CI lilypond
+part within a structure written in the
+.FONT CI groff
+language is the whole part between the marks
+.FONT CB ".lilypond start"
+and
+.FONT CB ".lilypond end" R .
+.
+A
+.FONT CI groff
+file can have several of these
+.FONT CI lilypond
+parts.
+.
+.
+.P
+These
+.FONT CI lilypond
+parts are sent into temporary files with the file name extension
+.FONT CB .ly R .
+.
+.
+.P
+These files are transformed by the
+.FONT CB lilypond
+program into
+.FONT CI pdf
+files, using
+.EX
+.FONT CB "lilypond \-\-pdf \-\-output=" I file-name
+.EE
+for each
+.FONT .ly
+file.
+.
+The
+.I file-name
+must be provided without the extension
+.FONT CB .pdf R .
+.
+By this process, a file
+.FONT CI file-name CB .pdf
+is generated.
+.
+.
+.P
+The next step is to transform these
+.FONT CI pdf
+files into a
+.FONT CI ps
+file.
+.
+This is done by the
+.FONT CB pdf2ps
+program using
+.EX
+.FONT CB "pdf2ps " CI file-name CB ".pdf " CI file-name CB ".ps"
+.EE
+.
+.
+The next step creates an
+.FONT CI EPS
+file from the
+.FONT CI ps
+file.
+.
+This is done by the
+.FONT CB ps2eps
+program using
+.EX
+.FONT CB "ps2eps " CI file-name CB ".ps"
+.EE
+.
+.
+.P
+By that, a file
+.FONT CI file-name CB .eps
+is created for each
+.FONT CI lilypond
+part in the
+.FONT CI groff
+file or standard input.
+.
+.
+.P
+The last step to be done is replacing all
+.FONT CI lilypond
+parts by the
+.FONT CI groff
+command
+.EX
+.FONT CB ".PSPIC " CI file-name CB .eps 
+.EE
+.
+.
+.P
+That new
+.FONT CI groff
+structure is sent to standard output.
+.
+It can either be saved in a file or piped to groff for a display.
+.
+.
+.\" --------------------------------------------------------------------
+.SH "TEMPORARY FILES"
+.\" --------------------------------------------------------------------
+.
+By the transformation process, there are many temporary files
+generated.
+.
+All of them except the
+.FONT CI EPS
+files are deleted when the
+.FONT CB groff_lilypond
+process is finished.
+.
+.
+.P
+These
+.FONT CI EPS
+files are stored in a temporary directory.
+.
+But they cannot be deleted by the transformation process because they
+are needed for the display which can take a long time.
+.
+.
+.\" --------------------------------------------------------------------
+.SH "DISPLAY"
+.\" --------------------------------------------------------------------
+.
+The display maps each
+.FONT CI lilypond
+part on a complete page, preceded and followed by a page break.
+.
+I do not know how to change this or what very long music sheets will
+do.
+.
+.
+.\" --------------------------------------------------------------------
+.SH "AUTHOR"
+.\" --------------------------------------------------------------------
+.author
+.
+.
+.\" --------------------------------------------------------------------
+.SH "COPYING"
+.\" --------------------------------------------------------------------
+.copyleft
+.
+.
+.\" --------------------------------------------------------------------
+.\" Emacs settings
+.\" --------------------------------------------------------------------
+.
+.\" Local Variables:
+.\" mode: nroff
+.\" End:

Index: groff_lilypond.pl
===================================================================
RCS file: groff_lilypond.pl
diff -N groff_lilypond.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ groff_lilypond.pl   10 Feb 2013 01:44:54 -0000      1.1
@@ -0,0 +1,137 @@
+#! /usr/bin/env perl
+
+# groff_lilypond - integrate lilypond into groff files
+
+# Source file position: <groff-source>/contrib/lilypond/groff_lilypond.pl
+# Installed position: <prefix>/bin/groff_lilypond
+
+# Copyright (C) 2013 Free Software Foundation, Inc.
+# Written by Bernd Warken <address@hidden>.
+
+# Last update: 09 Feb 2013
+
+# This file is part of `groff'.
+
+# `groff' is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# `groff' is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+########################################################################
+
+use strict;
+use warnings;
+
+sub version {
+    print "groff_lilypond version 0.1 is part of groff\n";
+}
+
+sub usage {
+    print <<EOF
+groff_lilypond [filename]
+groff_lilypond -h|--help
+groff_lilypond -v|--version
+Read a roff file or standard input and transform `lilypond' parts
+(everything between `.lilypond start' and `.lilypond end')
+into temporary EPS-files that can be read by groff using `.PSPIC'.
+See groff_lilypond(1)
+EOF
+}
+
+foreach (@ARGV) {
+    if (/(-v|--version)/) {
+       &version;
+       goto QUIT;
+    } elsif (/(-h)|--help/) {
+       &usage;
+       goto QUIT;
+    }
+}
+
+
+my $tempdir;
+{
+    my @tempdirs = ('/tmp', $ENV{'HOME'} . '/tmp');
+    foreach (reverse @tempdirs) {
+       if (-w) {
+           s<$></>;
+           s</+></>g;
+           my $sub = $_;
+           my $groff_tempdir = $sub . 'groff';
+           if (-e $groff_tempdir) {
+               if (-w $groff_tempdir) {
+                   $tempdir = $groff_tempdir;
+               } else {
+                   $tempdir = $sub;
+               }
+           } else {
+               if (mkdir $groff_tempdir, oct("0700")) {
+                   $tempdir = $groff_tempdir;
+               } else {
+                   $tempdir = $sub;
+               }
+           }
+           last;
+       }
+    }
+}
+$tempdir =~ s(/*$)(/);
+
+my $file_time;
+{
+    use Time::HiRes qw[];
+    (my $second, my $micro_second) = Time::HiRes::gettimeofday();
+    $file_time = $second . $micro_second;
+}
+
+my $file_prefix = $tempdir . 'lilypond' . '_' . $file_time . '_';
+my $file_number = 0;
+my $file_numbered;
+my $file_ly;
+
+my $lilypond_mode = 0;
+
+foreach (<>) {
+    chomp;
+    if (/^\.\s*lilypond\s+start/) {
+       die "Line `.lilypond stop' expected." if ($lilypond_mode);
+       $lilypond_mode = 1;
+       $file_number++;
+       $file_numbered = $file_prefix . $file_number;
+       $file_ly =  $file_numbered . '.ly';
+       open FILE_LY, ">", $file_ly or
+           die "cannot open .ly file: $!";
+       next;
+    } elsif (/^\.\s*lilypond\s+stop/) {
+       die "Line `.lilypond start' expected." unless ($lilypond_mode);
+       $lilypond_mode = 0;
+       close FILE_LY;
+
+       system "lilypond", "--pdf", "--output=$file_numbered", $file_ly and
+           die 'Program lilypond does not work.';
+       # .pdf is added automatically
+       system 'pdf2ps', $file_numbered . '.pdf', $file_numbered . '.ps' and
+           die 'Program pdf2ps does not work.';
+       system 'ps2eps', $file_numbered . '.ps' and
+           die 'Program ps2eps does not work.';
+       print '.PSPIC ' . $file_numbered  . '.eps' . "\n";
+
+       next;
+    } elsif ($lilypond_mode) {
+       print FILE_LY $_ . "\n";
+    } else {
+       print $_ . "\n";
+    }
+}
+
+unlink glob $file_prefix . "*.[a-df-z]*";
+
+QUIT:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]