David Goodger | 2 Feb 2004 04:35
Favicon

Re: html4css1.py/head/title/validator.w3.org

Darek Suchojad wrote:
 > it's my first post here and I think
 > you're doing a great job guys, thanks for that!

You're welcome!

 > However, yesterday I was a bit surprised that html
 > version of this liitle document
 >
 >     *italic*
 >     **bold**
 >
 > won't be validated
 > by http://validator.w3.org, after running
 > rst2html.py mydoc.txt > mydoc.html.
 >
 > The document doesn't have to be **that** small,
 > simply not having any header sufficies, and the problem
 > is - <title> element in <head> won't be generated.

I implemented the solution in a different way, changing
docutils.writers.html4css1.HTMLTranslator.visit_document to:

     def visit_document(self, node):
         self.body.append(self.starttag(node, 'div', CLASS='document'))
         # empty or untitled document?
         if not len(node) or not isinstance(node[0], nodes.title):
             # for XHTML conformance:
             self.head.insert(0, '<title />\n')

(Continue reading)

Darek Suchojad | 2 Feb 2004 11:24
Picon

Re: html4css1.py/head/title/validator.w3.org

W liƛcie z pon, 02-02-2004, godz. 04:35, David Goodger pisze: 

Hi,

> I implemented the solution in a different way, changing
> docutils.writers.html4css1.HTMLTranslator.visit_document to:
> 
>      def visit_document(self, node):
>          self.body.append(self.starttag(node, 'div',
CLASS='document'))
>          # empty or untitled document?
>          if not len(node) or not isinstance(node[0], nodes.title):
>              # for XHTML conformance:
>              self.head.insert(0, '<title />\n')

Cool.

> (Last 4 lines added.)  This way, the fix is all in one place.  Adding
> the empty title in one place and removing it somewhere else seemed
> fragile.

Yeah, I knew that was not the most elegant solution, but I don't
know yet docutils internals as good as you do know.

>  > I'm not that purist, but without that kind of solution,
>  > the output html isn't really xhtml1.0, as doctype claims.
> 
> It's a valid point.  Thanks for keeping us honest :-).

Heh, will do!
(Continue reading)

Roberto Alsina | 3 Feb 2004 01:15
Picon
Favicon
Gravatar

How to get progress information?


Hello,

I am writing an application that uses docutils to format information, and
the process may take a while for very long pieces of data.

Since this is a graphical application, I would like to provide my users
with a progress bar showing how far it's gone and how much is left.

What would be the right way to hook this into docutils?

Thanks in advance,

PS: if you want to know about the app, it's called Notty, the code is at
http://sf.net/projects/notty in CVS, and there is a screenshot at
http://pycs.net/lateral/pictures

--

-- 
 ("\''/").__..-''"`-. .         Roberto Alsina
 `9_ 9  )   `-. (    ).`-._.`)  ralsina <at> kde.org
 (_Y_.)' ._   ) `._`.  " -.-'   KDE Developer (MFCH)
  _..`-'_..-_/ /-'_.'
(l)-'' ((i).' ((!.'             Buenos Aires - Argentina
Imminentizing the eschaton since 1971.

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
(Continue reading)

David Goodger | 3 Feb 2004 05:31
Favicon

Re: How to get progress information?

Roberto Alsina wrote:
 > I am writing an application that uses docutils to format
 > information, and the process may take a while for very long pieces
 > of data.
 >
 > Since this is a graphical application, I would like to provide my
 > users with a progress bar showing how far it's gone and how much is
 > left.
 >
 > What would be the right way to hook this into docutils?

Hmmm, that's a tough one.  Docutils is batch-processing code; hooks
for progress feedback was never considered.  Without measuring
processing runs, I wouldn't know how to predict progress.  For the
parser, there's docutils.statemachine.StateMachine.attach_observer
etc. (observer pattern); observers are notified whenever the input
line number changes.  There's no equivalent for transforms or writers
though.

docutils.core.Publisher.publish contains the 3 main calls:

             document = self.reader.read(self.source, self.parser,
                                         self.settings)
             self.apply_transforms(document)
             output = self.writer.write(document, self.destination)

A very coarse set of hooks could be added in there.  I suppose finer
hooks could be added within the Reader, Transformer, and Writer
classes.  I'm open to suggestions!  (And patches of course.)

(Continue reading)

Felix Wiemann | 8 Feb 2004 02:03
Picon

Re: How to get progress information?

Roberto Alsina wrote:

> I am writing an application that uses docutils to format information,
> and the process may take a while for very long pieces of data.
> 
> Since this is a graphical application, I would like to provide my
> users with a progress bar showing how far it's gone and how much is
> left.

readers/__init__.py says:

| self.input = self.source.read()

I do not know how docutils does the parsing, but if it is done
sequentially, one could replace self.input by an object which tracks the
accesses (and calls a hook).  David, might this work?

--

-- 
http://www.ososo.de/

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
David Goodger | 8 Feb 2004 15:35
Favicon

Re: How to get progress information?

Felix Wiemann wrote:
 > readers/__init__.py says:
 >
 > | self.input = self.source.read()
 >
 > I do not know how docutils does the parsing, but if it is done
 > sequentially, one could replace self.input by an object which tracks
 > the accesses (and calls a hook).  David, might this work?

The entire input is read into memory before processing.  As I wrote in
my on-list reply to Roberto (which see),

     For the parser, there's
     docutils.statemachine.StateMachine.attach_observer etc. (observer
     pattern); observers are notified whenever the input line number
     changes.

--

-- 
David Goodger                               http://python.net/~goodger
For hire: http://python.net/~goodger/cv

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
Shawn Harrison | 10 Feb 2004 19:08

Docutils non-cmdline

Hi,
 
I just joined this list. I'm building a web application using mod_python in Apache, and would like to dynamically parse and serve reStructuredText files to web browsers.
 
I don't see an easy way to import docutils as a module and then parse a text within python. Before I spend a lot of time reading docutils sources, could you give me some guidance as to how I might go about doing this?
 
Thanks much,
Shawn Harrison
McEahern, Mark | 10 Feb 2004 19:13
Picon
Picon

RE: Docutils non-cmdline

[Shawn Harrison [mailto:harrison <at> tbc.net]]
> I just joined this list. I'm building a web application using 
> mod_python in Apache, and would like to dynamically parse and 
> serve reStructuredText files to web browsers. 
> 
> I don't see an easy way to import docutils as a module and 
> then parse a text within python. Before I spend a lot of time 
> reading docutils sources, could you give me some guidance as 
> to how I might go about doing this?

I'd suggest looking at how tools\buildhtml.py works and stealing the
implementation from there.

// m

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
Shawn Harrison | 10 Feb 2004 19:30

Re: Docutils non-cmdline

Okay, thanks. This seems to be something others might use, so if I crack the
nut should I post the results here?

Shawn

----- Original Message ----- 
From: "McEahern, Mark" <Mark.McEahern <at> dfi.state.wi.us>
To: "'Shawn Harrison'" <harrison <at> tbc.net>;
<docutils-users <at> lists.sourceforge.net>
Sent: Tuesday, February 10, 2004 12:13 PM
Subject: RE: [Docutils-users] Docutils non-cmdline

> [Shawn Harrison [mailto:harrison <at> tbc.net]]
> > I just joined this list. I'm building a web application using
> > mod_python in Apache, and would like to dynamically parse and
> > serve reStructuredText files to web browsers.
> >
> > I don't see an easy way to import docutils as a module and
> > then parse a text within python. Before I spend a lot of time
> > reading docutils sources, could you give me some guidance as
> > to how I might go about doing this?
>
> I'd suggest looking at how tools\buildhtml.py works and stealing the
> implementation from there.
>
> // m

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
David Goodger | 13 Feb 2004 00:15
Favicon

Re: Docutils non-cmdline

Shawn Harrison wrote:
> I don't see an easy way to import docutils as a module and then
> parse a text within python.

You probably want to use docutils.core.publish_string().  Start with
the docstring, then look at tools/pep2html.py for an example.

--

-- 
David Goodger                               http://python.net/~goodger
For hire: http://python.net/~goodger/cv

-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click

Gmane