I've thrown together a Zope interface to the docutils project's ReStructuredText format. It offers: - through-the-web editing - handling of errors (with control over the reporting level) - FTP editing (with access to the config properties and errors) - extraction of the document title from the text itself - configuration of the stylesheet used - source view It's in the docutils sandbox CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/docutils/sandbox/richard/ZReS... You'll need to install docutils too :) Richard
hi, you did it!! I'm going to integrate ReStructuredText into my StructuredDocument-Product now. Thank you for your work. -maik Richard Jones wrote:
I've thrown together a Zope interface to the docutils project's ReStructuredText format. It offers:
- through-the-web editing - handling of errors (with control over the reporting level) - FTP editing (with access to the config properties and errors) - extraction of the document title from the text itself - configuration of the stylesheet used - source view
It's in the docutils sandbox CVS:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/docutils/sandbox/richard/ZReS...
You'll need to install docutils too :)
Richard
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Maik Jablonski __o www.zfl.uni-bielefeld.de _ \<_ Deutsche Zope User Group Bielefeld, Germany (_)/(_) www.dzug.org
On Thu, 15 Aug 2002 4:47 pm, Maik Jablonski wrote:
you did it!! I'm going to integrate ReStructuredText into my StructuredDocument-Product now.
No prob. Someone mentioned that it'd be nice to have this play with CMF, but I'm not sure what, if anything needs to be done for that to happen. I'll package it up for release on zope.org after David G has had another look at the code (and stopped vomiting at it ;) Note that the internal API of docutils is pretty stable, but I'm using it for stuff that David hasn't ... which means that the API will most likely get simpler now that we've found the warty bits. Richard
Hi, Richard Jones wrote:
I've thrown together a Zope interface to the docutils project's ReStructuredText format. [...]
Exciting! I couldn't refuse the temptation to try this out at once. And it works: The add menu of the ZMI displays the new object type 'ReStructuredText Document' and the HTML rendering happens as expected.
You'll need to install docutils too :)
Obviously. I've downloaded a docutils-snapshot.tgz on August 13th. On my RPM-based Linux system the default Python is 2.2, but Zope 2.5.1 still recommends Python 2.1. So I did python2.1 setup.py install in the directory, where I untarred docutils-snapshot.tgz, which created and populated the directory /usr/lib/python2.1/site-packages/docutils. Works like a charme. What I would like to do next is integrating ReST with CMFWiki. This is a wiki clone product for Zope used within the context of the Zope CMF, the Zope content management framework. This Product contains a module called 'CMFWikiPage.py', which currently calls the html_with_references() function exported by the Zope StructuredText module to render classic structured text. The string returned from this function is than further processed to setup the interwiki links and such. I will try to come up with a patch to CMFWikiPage which will than use ReST as an alternative format (and as the default for new Wiki pages). To aid this I would find it very useful, if either the ZReST package or docutils could export a wrapper function implementing a very simple API similar to this found in Zope/StructuredText/StructuredText: def html_with_references(text, level=1, header=1) """ Given a string 'text' containing structured text markup returns this 'text' rendered as HTML """ If such a simple API or something similar is already present either in ZReST or in the docutils package itself, please apologize my ignorance and give me a hint where to look for this. Regards and many thanks, Peter -- Peter Funk, Oldenburger Str.86, D-27777 Ganderkesee, Germany, Fax:+49 4222950260 office: +49 421 20419-0 (ArtCom GmbH, Grazer Str.8, D-28359 Bremen, Germany)
On Thu, 15 Aug 2002 7:06 pm, Peter Funk wrote:
To aid this I would find it very useful, if either the ZReST package or docutils could export a wrapper function implementing a very simple API similar to this found in Zope/StructuredText/StructuredText: def html_with_references(text, level=1, header=1) """ Given a string 'text' containing structured text markup returns this 'text' rendered as HTML """
ReStructuredText takes some time to convert source text into HTML (sometimes several seconds for longish documents). I'd advise going for a more integrated approach that can compile the source text once. If you're really keen to actually go with the html_with_references path - borrow the code from the ZReST.render() method and you'll have your text to HTML conversion. Richard
hi,
If you're really keen to actually go with the html_with_references path - borrow the code from the ZReST.render() method and you'll have your text to HTML conversion.
I've done that, but I got errors for "German Umlaute" [äöü]. Is this a bug of the RestructuredTextParser or of your render-method? Error Type: UnicodeError Error Value: ASCII encoding error: ordinal not in range(128) cheers, maik -- Maik Jablonski __o www.zfl.uni-bielefeld.de _ \<_ Deutsche Zope User Group Bielefeld, Germany (_)/(_) www.dzug.org
This problem occurs when you try to convert non-ascii text to unicode without specifying the used encoding. I have not looked at the ReStructuredText product yet but there should be some mechanism to specify the encoding for a text. -aj ----- Original Message ----- From: "Maik Jablonski" <maik.jablonski@uni-bielefeld.de> To: "Richard Jones" <rjones@ekit-inc.com>; <zope@zope.org> Sent: Thursday, August 15, 2002 13:18 Subject: Re: [Zope] Re: [Docutils-develop] ReStructuredText now in Zope hi,
If you're really keen to actually go with the html_with_references path - borrow the code from the ZReST.render() method and you'll have your text to HTML conversion.
I've done that, but I got errors for "German Umlaute" [äöü]. Is this a bug of the RestructuredTextParser or of your render-method? Error Type: UnicodeError Error Value: ASCII encoding error: ordinal not in range(128) cheers, maik -- Maik Jablonski __o www.zfl.uni-bielefeld.de _ \<_ Deutsche Zope User Group Bielefeld, Germany (_)/(_) www.dzug.org _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Thu, 15 Aug 2002 11:31 pm, Andreas Jung wrote:
This problem occurs when you try to convert non-ascii text to unicode without specifying the used encoding. I have not looked at the ReStructuredText product yet but there should be some mechanism to specify the encoding for a text.
There is - how do I determine the encoding from Zope? Richard
It is not an issue of Zope since you can store texts with different encodings in Zope. I assume for most english speaking or european users ISO-8859-1 the prefered encoding (or ascii). But there is now way to get the encoding of a text by "looking at the text". For situations where you have texts with different encodings it is necessary that the object containing the text has a property that contains the encoding information. Using sys.getdefaultencoding() usually returns "ascii" since only few Zope/Python users change this value. -aj ----- Original Message ----- From: "Richard Jones" <rjones@ekit-inc.com> To: "Andreas Jung" <andreas@andreas-jung.com>; "Maik Jablonski" <maik.jablonski@uni-bielefeld.de>; <zope@zope.org> Sent: Thursday, August 15, 2002 23:33 Subject: Re: [Zope] Re: [Docutils-develop] ReStructuredText now in Zope
On Thu, 15 Aug 2002 11:31 pm, Andreas Jung wrote:
This problem occurs when you try to convert non-ascii text to unicode without specifying the used encoding. I have not looked at the ReStructuredText product yet but there should be some mechanism to specify the encoding for a text.
There is - how do I determine the encoding from Zope?
Richard
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Richard Jones wrote:
On Thu, 15 Aug 2002 11:31 pm, Andreas Jung wrote:
This problem occurs when you try to convert non-ascii text to unicode without specifying the used encoding. I have not looked at the ReStructuredText product yet but there should be some mechanism to specify the encoding for a text.
There is - how do I determine the encoding from Zope?
You can't, just use 'latin-1' as the encoding which si mreo than likely what you have ;-) cheers, Chris
----- Original Message ----- From: "Chris Withers" <chrisw@nipltd.com> To: "Richard Jones" <rjones@ekit-inc.com> Cc: "Andreas Jung" <andreas@andreas-jung.com>; "Maik Jablonski" <maik.jablonski@uni-bielefeld.de>; <zope@zope.org> Sent: Friday, August 16, 2002 11:36 Subject: Re: [Zope] Re: [Docutils-develop] ReStructuredText now in Zope
Richard Jones wrote:
On Thu, 15 Aug 2002 11:31 pm, Andreas Jung wrote:
This problem occurs when you try to convert non-ascii text to unicode without specifying the used encoding. I have not looked at the ReStructuredText product yet but there should be some mechanism to specify the encoding for a text.
There is - how do I determine the encoding from Zope?
You can't, just use 'latin-1' as the encoding which si mreo than likely what you have ;-) ^^^^^^^^^
...until Chris Withers will be slained by the Russians ;-) -aj
Andreas Jung wrote:
----- Original Message -----
You can't, just use 'latin-1' as the encoding which si mreo than likely
what you have ;-) ^^^^^^^^^ ...until Chris Withers will be slained by the Russians ;-)
I don't thin kthere are that many Russians in Australia ;-) Chris
On Sat, 17 Aug 2002 1:00 am, Chris Withers wrote:
Andreas Jung wrote:
----- Original Message -----
You can't, just use 'latin-1' as the encoding which si mreo than likely
what you have ;-) ^^^^^^^^^ ...until Chris Withers will be slained by the Russians ;-)
I don't thin kthere are that many Russians in Australia ;-)
Usually only the ones that are good at sport. Richard
On Fri, 16 Aug 2002 7:36 pm, Chris Withers wrote:
Richard Jones wrote:
On Thu, 15 Aug 2002 11:31 pm, Andreas Jung wrote:
This problem occurs when you try to convert non-ascii text to unicode without specifying the used encoding. I have not looked at the ReStructuredText product yet but there should be some mechanism to specify the encoding for a text.
There is - how do I determine the encoding from Zope?
You can't, just use 'latin-1' as the encoding which si mreo than likely what you have ;-)
I believe I'll make it configurable, defaulting to "latin-1" :) Richard
Richard Jones writes:
On Thu, 15 Aug 2002 11:31 pm, Andreas Jung wrote:
This problem occurs when you try to convert non-ascii text to unicode without specifying the used encoding. I have not looked at the ReStructuredText product yet but there should be some mechanism to specify the encoding for a text.
There is - how do I determine the encoding from Zope? You might be able to derive in from the current "locale". Not easy, though, more a guess.
Dieter
On Sat, 17 Aug 2002 7:48 pm, Dieter Maurer wrote:
Richard Jones writes:
On Thu, 15 Aug 2002 11:31 pm, Andreas Jung wrote:
This problem occurs when you try to convert non-ascii text to unicode without specifying the used encoding. I have not looked at the ReStructuredText product yet but there should be some mechanism to specify the encoding for a text.
There is - how do I determine the encoding from Zope?
You might be able to derive in from the current "locale". Not easy, though, more a guess.
If I understand it correctly, docutils already does that. Richard
Richard, This is great! I've been half-heartedly working on an External Method so I could use reST through Zope, but this is much better. My only issue now is that I use Zope Local File System extensively, for keeping my documentation under CVS. I tried a naive mapping of ZReST to *.rst files, but that didn't work. Any ideas how these can be made to work together? --Dethe
On Fri, 16 Aug 2002 2:34 am, Dethe Elza wrote:
This is great! I've been half-heartedly working on an External Method so I could use reST through Zope, but this is much better.
External Methods yecch :)
My only issue now is that I use Zope Local File System extensively, for keeping my documentation under CVS. I tried a naive mapping of ZReST to *.rst files, but that didn't work. Any ideas how these can be made to work together?
Sorry, I know nothing about the Local File System stuff. Richard
Hi, Richard Jones:
On Fri, 16 Aug 2002 2:34 am, Dethe Elza wrote:
This is great! I've been half-heartedly working on an External Method so I could use reST through Zope, but this is much better.
External Methods yecch :)
My only issue now is that I use Zope Local File System extensively, for keeping my documentation under CVS. I tried a naive mapping of ZReST to *.rst files, but that didn't work. Any ideas how these can be made to work together?
Sorry, I know nothing about the Local File System stuff.
First of all let me thank you all for the great work. I believe this is only one of the many places, where **StructuredText** has been used in Zope. Another important place is the DTML format attribute of DTML variables. For example (looked up from Zope 2.5.1) there is the module ``lib/python/DocumentTemplate/DT_vars.py``, which implements the DTML language construct:: <dtml-var foobar fmt="structured-text"> This is done using the format dispatcher dictionary ``special_formats``, which contains a reference to the following small function:: def structured_text(v, name='(Unknown name)', md={}): global StructuredText if StructuredText is None: from StructuredText.StructuredText import HTML if isinstance(v,StringType): txt = v elif aq_base(v).meta_type in ['DTML Document','DTML Method']: txt = aq_base(v).read_raw() else: txt = str(v) return HTML(txt,level=3,header=0) My idea is to add a new entry called ``restructured-text`` or simply ``rest`` to this dispatcher dictionary. Yesterday I played around with **CMFWiki** and had a very similar situation. There is a simple wrapper function using the same class HTML. So for further integration of ReST as an alternative replacement for `StructuredText` I believe it makes sense to come up with a wrapper class, which implements the API of the class HTML of StructuredText. Questions ========= * What to do with the parameters ``level`` and ``header`` within **ReST**? * Where should we put this class? Would be an extended **ZReST** Zope product the right place? Regards, Peter -- Peter Funk, Oldenburger Str.86, D-27777 Ganderkesee, Germany office: +49 421 20419-0 (ArtCom GmbH, Grazer Str.8, D-28359 Bremen, Germany)
----- Original Message ----- From: "Peter Funk" <pf@artcom-gmbh.de> To: "Richard Jones" <rjones@ekit-inc.com> Cc: "Dethe Elza" <delza@mac.com>; "Zope List" <zope@zope.org>; <docutils-develop@lists.sourceforge.net> Sent: Friday, August 16, 2002 11:34 Subject: [Zope] Re: [Docutils-develop] ReStructuredText now in Zope
I believe this is only one of the many places, where **StructuredText** has been used in Zope. Another important place is the DTML format attribute of DTML variables. For example (looked up from Zope 2.5.1) there is the module ``lib/python/DocumentTemplate/DT_vars.py``, which implements the DTML language construct::
<dtml-var foobar fmt="structured-text">
This is done using the format dispatcher dictionary ``special_formats``, which contains a reference to the following small function::
def structured_text(v, name='(Unknown name)', md={}): global StructuredText if StructuredText is None: from StructuredText.StructuredText import HTML
if isinstance(v,StringType): txt = v
elif aq_base(v).meta_type in ['DTML Document','DTML Method']: txt = aq_base(v).read_raw()
else: txt = str(v)
return HTML(txt,level=3,header=0)
My idea is to add a new entry called ``restructured-text`` or simply ``rest`` to this dispatcher dictionary. Yesterday I played around with **CMFWiki** and had a very similar situation. There is a simple wrapper function using the same class HTML. So for further integration of ReST as an alternative replacement for `StructuredText` I believe it makes sense to come up with a wrapper class, which implements the API of the class HTML of StructuredText.
Questions =========
* What to do with the parameters ``level`` and ``header`` within **ReST**?
level is the default level where the <Hx> tags start (the default value is 3 - don't ask why). header is a flag to either produce a valid HTML document header or not (<HTML>....<HEAD>...<BODY>).
* Where should we put this class? Would be an extended **ZReST** Zope product the right place?
If it is a product then the Products folder would be the right place. This would allow you to do some moneky patching if necessary. -aj
participants (8)
-
Andreas Jung -
Andreas Jung -
Chris Withers -
Dethe Elza -
Dieter Maurer -
Maik Jablonski -
pf@artcom-gmbh.de -
Richard Jones