groff-commit
[Top][All Lists]
Advanced

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

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


From: Bernd Warken
Subject: [Groff-commit] groff/contrib/lilypond ChangeLog groff_lilypond...
Date: Mon, 11 Feb 2013 00:22:39 +0000

CVSROOT:        /cvsroot/groff
Module name:    groff
Changes by:     Bernd Warken <bwarken>  13/02/11 00:22:39

Modified files:
        contrib/lilypond: ChangeLog groff_lilypond.man groff_lilypond.pl 

Log message:
        groff_lilypond version v0.2.
        There are now 2 modes for generating EPS files: --ly2eps (the new 
default)
        and --pdf2eps (the old version from v0.1).

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

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/groff/groff/contrib/lilypond/ChangeLog,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- ChangeLog   10 Feb 2013 16:07:56 -0000      1.1
+++ ChangeLog   11 Feb 2013 00:22:39 -0000      1.2
@@ -1,8 +1,18 @@
+2013-02-11  Bernd Warken  <address@hidden>
+
+       * contrib/lilypond: Version v0.2 for groff_lilypond
+       * groff_lilypond.pl: Now there are 2 modes for generationg the EPS
+       files: --ly2eps (the default) and --pdf2eps (that's the old mode
+       from version v0.1 with pdf to ps to eps).  With ly2eps mode,
+       lilypond generates the EPS files itself, for each page one EPS
+       file.
+       * groff_lilypond.man: Corresponding updated man-page
+
 2013-02-10  Bernd Warken  <address@hidden>
 
        * contrib/lilypond: New files for adding lilypond parts into groff
        files.  These files will not yet be installed.
-       * groff_lilypond.pl: Program written in Perl, version 0.1
+       * groff_lilypond.pl: Program written in Perl, version v0.1
        * groff_lilypond.man: Corresponding man-page
 
 Copyright 2013

Index: groff_lilypond.man
===================================================================
RCS file: /cvsroot/groff/groff/contrib/lilypond/groff_lilypond.man,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- groff_lilypond.man  10 Feb 2013 01:44:54 -0000      1.1
+++ groff_lilypond.man  11 Feb 2013 00:22:39 -0000      1.2
@@ -110,10 +110,11 @@
 .
 .
 .\" --------------------------------------------------------------------
-.\" SH "SYNOPSIS"
+.SH "SYNOPSIS"
 .\" --------------------------------------------------------------------
 .
 .SY groff_lilypond
+.OP option
 .OP --
 .OP \%filespec
 .YS
@@ -150,7 +151,33 @@
 .
 .
 .\" --------------------------------------------------------------------
-.SH "HOW THE TRANSFORMATION WORKS"
+.SH "OPTION OVERVIEW"
+.\" --------------------------------------------------------------------
+.
+.TP
+.I breaking options
+.RS
+.P
+.SY
+.OP -h\~\fR|\fB\~--help
+.OP -v\~\fR|\fB\~--version
+.YS
+.RE
+.
+.
+.TP
+.I \%groff_lilypond mode options
+.RS
+.P
+.SY
+.OP --pdf2eps
+.OP --ly2eps
+.YS
+.RE
+.
+.
+.\" --------------------------------------------------------------------
+.SH "FINDING THE LILYPOND PARTS IN A ROFF FILE OR STANDARD INPUT"
 .\" --------------------------------------------------------------------
 .
 A
@@ -175,9 +202,84 @@
 parts are sent into temporary files with the file name extension
 .FONT CB .ly R .
 .
+There a 2 modes to transform these files.
+.
+.
+.\" --------------------------------------------------------------------
+.SH "TRANSFORMATION MODE LY2EPS"
+.\" --------------------------------------------------------------------
+.
+This mode is the default.
+.
+It can also be chosen by the option
+.FONT CB --ly2eps R .
+.
+.
+.P
+In this mode, the
+.FONT CB .ly
+files are transformed by the
+.FONT CB lilypond
+program into many files of different formats, including
+.FONT CI eps
+files, using
+.EX
+.FONT CB "lilypond \-\-ps \-dbackend=eps \-dgs\-load\-fonts \-\-output=" I 
file\-name
+.EE
+for each
+.FONT CB .ly
+file.
+.
+The output
+.I file\-name
+must be provided without an extension, its directory is temporary..
+.
+.
+.P
+There are many
+.FONT CI EPS
+files created.
+.
+One having the complete transformed
+.FONT CB ly
+file, named
+.FONT I file\-name CB .eps R .
+.
+.
+.P
+Moreover there are
+.FONT CI EPS
+files for each page, named
+.FONT I file\-name CB \- I digit CB .eps R .
+.
 .
 .P
-These files are transformed by the
+The last step to be done is replacing all
+.FONT CI lilypond
+parts by the collection of the corresponding
+.FONT CI EPS
+page files.
+.
+This is done by
+.FONT CI groff
+commands
+.EX
+.FONT CB ".PSPIC " CI file-name CB \- I digit CB .eps 
+.EE
+.
+.
+.\" --------------------------------------------------------------------
+.SH "TRANSFORMATION MODE PDF2EPS"
+.\" --------------------------------------------------------------------
+.
+This mode can be chosen by the option
+.FONT CB --pdf2eps R .
+.
+.
+.P
+In this mode, the
+.FONT CB .ly
+files are transformed by the
 .FONT CB lilypond
 program into
 .FONT CI pdf
@@ -186,7 +288,7 @@
 .FONT CB "lilypond \-\-pdf \-\-output=" I file-name
 .EE
 for each
-.FONT .ly
+.FONT CB .ly
 file.
 .
 The
@@ -249,12 +351,21 @@
 .EE
 .
 .
-.P
-That new
-.FONT CI groff
-structure is sent to standard output.
+.\" --------------------------------------------------------------------
+.SH "NEW ROFF STRUCTURE"
+.\" --------------------------------------------------------------------
+.
+The new
+.BR groff (@MAN7EXT@)
+structure generated by
+.FONT CB groff_lilypond
+is sent to standard output.
 .
-It can either be saved in a file or piped to groff for a display.
+It can either be saved in a file or piped to
+.BR groff (@MAN1EXT@)
+or
+.BR groffer (@MAN1EXT@)
+for a display.
 .
 .
 .\" --------------------------------------------------------------------

Index: groff_lilypond.pl
===================================================================
RCS file: /cvsroot/groff/groff/contrib/lilypond/groff_lilypond.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- groff_lilypond.pl   10 Feb 2013 01:44:54 -0000      1.1
+++ groff_lilypond.pl   11 Feb 2013 00:22:39 -0000      1.2
@@ -8,7 +8,7 @@
 # Copyright (C) 2013 Free Software Foundation, Inc.
 # Written by Bernd Warken <address@hidden>.
 
-# Last update: 09 Feb 2013
+# Last update: 11 Feb 2013
 
 # This file is part of `groff'.
 
@@ -30,73 +30,84 @@
 use strict;
 use warnings;
 
-sub version {
-    print "groff_lilypond version 0.1 is part of groff\n";
-}
+my $version = 'v0.2';
 
-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
-}
+# for temporary directories see @tempdirs
 
+my $eps_mode = 'ly2eps';
 foreach (@ARGV) {
-    if (/(-v|--version)/) {
+    if (/^(-v|--version).*$/) {
        &version;
        goto QUIT;
-    } elsif (/(-h)|--help/) {
+    } elsif (/^(-h|--help).*$/) {
        &usage;
        goto QUIT;
+    } elsif (/^--pdf2eps.*$/) {
+       $eps_mode = 'pdf2eps';
+       shift;
+    } elsif (/^--ly2eps.*$/) {
+       $eps_mode = 'ly2eps';
+       shift;
     }
 }
 
+my $dir_time;
+{
+    $dir_time = localtime(time());
+    $dir_time =~  tr/: /_/;
+
+    use Time::HiRes qw[];
+    (my $second, my $micro_second) = Time::HiRes::gettimeofday();
+
+    $dir_time = $dir_time . '_' . $micro_second;
+}
 
 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;
+    use File::Path qw[];
+
+    use Cwd qw[];
+    my $cwd = Cwd::getcwd();
+    $cwd =~ s(/*$)(/tmp);
+
+    my $home = $ENV{'HOME'};
+    $home =~ s(/*$)(/tmp);
+
+    my @tempdirs = ('/tmp',  $home, $cwd);
+    foreach (@tempdirs) {
+       if (-e $_) {   # exists
+           if (-d) {  # is directory
+               next unless (-w $_);   # not writable
+           }
+       } else {       #  does not exist
+           File::Path::make_path $_, {mask=>oct('0700')} or next;
+       }
+       # directory $_ exists and is writable
+       my $dir = $_;
+       $dir =~ s(/+)(/)g;
+       $dir =~ s(/*$)(/groff);
+       if (-e $dir) {     # exists
+           next unless (-d $dir); # if no dir
+           next unless (-w $dir); # if not writable
                } else {
-                   $tempdir = $sub;
-               }
+           File::Path::make_path $dir, {mask=>oct('0700')} or next;
            }
+
+       $dir =~ s(/*$)(/$dir_time);
+       File::Path::make_path $dir, {mask=>oct('0700')} or next;
+       not -e $dir or not -d $dir or not -w $dir and next;
+
+       $tempdir = $dir; # tmp/groff/time
            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_prefix = $tempdir . 'ly' . '_';
+my $ly_number = 0;
 my $file_numbered;
-my $file_ly;
 
+my $file_ly;
 my $lilypond_mode = 0;
 
 foreach (<>) {
@@ -104,8 +115,8 @@
     if (/^\.\s*lilypond\s+start/) {
        die "Line `.lilypond stop' expected." if ($lilypond_mode);
        $lilypond_mode = 1;
-       $file_number++;
-       $file_numbered = $file_prefix . $file_number;
+       $ly_number++;
+       $file_numbered = $file_prefix . $ly_number;
        $file_ly =  $file_numbered . '.ly';
        open FILE_LY, ">", $file_ly or
            die "cannot open .ly file: $!";
@@ -115,15 +126,27 @@
        $lilypond_mode = 0;
        close FILE_LY;
 
-       system "lilypond", "--pdf", "--output=$file_numbered", $file_ly and
-           die 'Program lilypond does not work.';
+       if ($eps_mode =~ /^pdf2eps$/) {
+           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.';
+           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";
+       } elsif ($eps_mode =~ /^ly2eps$/) {
+           system 'lilypond', '--ps', '-dbackend=eps',
+           '-dgs-load-fonts', "--output=$file_numbered", $file_ly
+               and die 'Program lilypond does not work.';
+           # extensions are added automatically
+           foreach (glob $file_numbered . '-*' . '.eps') {
+               print '.PSPIC ' . $_ . "\n";
+           }
 
+       } else {
+           die "Wrong eps mode: $eps_mode";
+       }
        next;
     } elsif ($lilypond_mode) {
        print FILE_LY $_ . "\n";
@@ -134,4 +157,24 @@
 
 unlink glob $file_prefix . "*.[a-df-z]*";
 
+sub version {
+    print "groff_lilypond version $version is part of groff\n";
+}
+
+sub usage {
+    print <<EOF
+groff_lilypond [options] [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'.
+Options are
+--pdf2eps
+--ly2eps
+for influencing the way how the EPS files for roff display are generated.
+EOF
+}
+
+
 QUIT:



reply via email to

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