[Scribus] Summer of Code - Emacs mode?
Gregory Pittman
gpittman
Tue Mar 20 14:28:50 CET 2007
Craig Bradney wrote:
>> ----- Original Message -----
>> Subject: [Scribus] Summer of Code - Emacs mode?
>> From: jrm at kw.igs.net <jrm at kw.igs.net>
>> To: scribus at nashi.altmuehlnet.de
>> Date: 20-03-2007 10:52
>>
>>
>> Hello, people. For what they're worth, here are some thoughts
>> on a Scribus/Emacs project that just might be attractive for
>> Summer of Code.
>>
>>
> Sounds like a reasonable thing to me, although nano is my friend :)
> My concern lies to:
> a) 1.3.3.x still has non conformant characters in the file format
> b) as 1.3.4 is not complete, the 1.3.4 format is not finalised around the
> area of styles and text formatting
>
You can use a python or perl script to spit out an XML tree that is much
easier to read. The last time I checked, the only problem was that
Scribus represents carriage returns (as in word wrap in a text frame)
with 'Ctrl-E', and this is XML noncompliant.
For the pre-1.3.4 versions, what I have done is to do a
search-and-replace on the file first to switch the offending control
characters with some other character (needs to be unique for obvious
reasons), then after the editing switch back. Something else to keep in
mind is that the official documentation of various variables is a bit
behind (since the whole 1.3.3.x series).
Attached files: xwl.pl and xmlparser.py will test to see if a file is
xml-compliant. xmltree.pl will spit out an xml-compliant file into a
tree form. The python file has its copyright notice included -- it's
freely usable, just needs to keep the notice. I'm putting them inline
because in the past nashi.altmuehlnet.de has not been happy with
attached scripts.
Greg
*************************
#!/usr/bin/env python
# xmlparser.py
# This is from Python Cookbook, (c) O'Reilly 2002
# As per the Preface, uses modified Berkeley license
# (SEE BELOW)
from xml.sax.handler import ContentHandler
from xml.sax import make_parser
from glob import glob
import sys
def parsefile(file):
parser = make_parser()
parser.setContentHandler(ContentHandler())
parser.parse(file)
for arg in sys.argv[1:]:
for filename in glob(arg):
try:
parsefile(filename)
print "%s is well-formed" % filename
except Exception, e:
print "%s is NOT well-formed! %s" % (filename, e)
# Copyright (c) 2001, Paul Prescod
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
met:
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Paul Prescod nor the names of its contributors may
# be used to endorse or promote products derived from this software
without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************
#! /usr/bin/env perl
# xwl.pl
use XML::Parser;
my $xmlfile = shift @ARGV;
my $parser = XML::Parser->new( ErrorContext => 2 );
eval { $parser->parsefile( $xmlfile ); };
if( $@ ) {
$@ =~ s/at \/.*?$//s;
print STDERR "\nERROR in '$file':\n$@\n";
} else {
print STDERR "'$file' is well-formed\n";
}
**************************************
#! /usr/bin/env perl
# xmltree.pl
# this is from Perl & XML,
# ET Ray & J McIntosh
# O'Reilly & Associates, 2002
# Example 3-3, p 46
use XML::Parser;
$parser = new XML::Parser( Style => 'Tree' );
my $tree = $parser->parsefile( shift @ARGV );
use Data::Dumper;
print Dumper( $tree );
More information about the scribus
mailing list