How to convert structured text into plain text
Hi, I know that <dtml-var xxx fmt="structured-text"> converts structured text into HTML, and I know how to call this from a python script/external method. Now, is there a method somewhere in Zope's classes that return a plain text version of the stx string? With all the special characters and sequences stripped off. Thanks in advance, Nuno
----- Original Message ----- From: "Nuno Maltez" <nuno@xml.pt> To: <zope@zope.org> Sent: Tuesday, February 19, 2002 13:44 Subject: [Zope] How to convert structured text into plain text
Hi,
I know that <dtml-var xxx fmt="structured-text"> converts structured text into HTML, and I know how to call this from a python script/external method.
Now, is there a method somewhere in Zope's classes that return a plain text version of the stx string? With all the special characters and sequences stripped off.
What do you mean with special characters and sequences ? - aj
What do you mean with special characters and sequences ?
Well, consider the following: - create a page that renders the stx into HTML with fmt="..." - "View" the page - Select the text with the mouse and copy it to the clipboard. - now paste the text into a text file (or a DTML document) The output of this is what I'm looking for :) No bolds, italics, links nor the characters needed to implement these. Just the text the user sees in the end totally unformatted. Thanks again, Nuno
I don't know of such a method. Tweaking the sources or writing a different output handler should be a big deal. -aj ----- Original Message ----- From: "Nuno Maltez" <nuno@xml.pt> To: "Andreas Jung" <andreas@zope.com>; <zope@zope.org> Sent: Tuesday, February 19, 2002 14:02 Subject: Re: [Zope] How to convert structured text into plain text
What do you mean with special characters and sequences ?
Well, consider the following:
- create a page that renders the stx into HTML with fmt="..." - "View" the page - Select the text with the mouse and copy it to the clipboard. - now paste the text into a text file (or a DTML document)
The output of this is what I'm looking for :) No bolds, italics, links nor the characters needed to implement these.
Just the text the user sees in the end totally unformatted.
Thanks again, Nuno
_______________________________________________ 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 )
Wouldn't <dtml-var xxx> be enough? Off course it'll still have STXisms like * or **, link specs etc. Otherwise, what I can think of is to write an external method that takes in HTML and returns plain text. To this pass the rendered STX. something like this -> from htmllib import HTMLParser from formatter import AbstractFormatter, AbstractWriter parser = HTMLParser(AbstractFormatter(AbstractWriter())) parser.feed(stx_in_html) parser.close() Well, this prints out the text - need to modify it to capture it and return it as a string -vsb On Tue, Feb 19, 2002 at 06:44:56PM +0000, Nuno Maltez wrote:
Hi,
I know that <dtml-var xxx fmt="structured-text"> converts structured text into HTML, and I know how to call this from a python script/external method.
Now, is there a method somewhere in Zope's classes that return a plain text version of the stx string? With all the special characters and sequences stripped off.
Thanks in advance, Nuno
_______________________________________________ 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 )
Oops - that would be DumbWriter instead of AbstractWriter in any case, please try comp.lang.python too - I think there were some examples before. On Tue, Feb 19, 2002 at 02:18:00PM -0500, vsbabu@vsbabu.org wrote:
Wouldn't <dtml-var xxx> be enough? Off course it'll still have STXisms like * or **, link specs etc.
Otherwise, what I can think of is to write an external method that takes in HTML and returns plain text. To this pass the rendered STX.
something like this ->
from htmllib import HTMLParser from formatter import AbstractFormatter, AbstractWriter parser = HTMLParser(AbstractFormatter(AbstractWriter())) parser.feed(stx_in_html) parser.close()
Well, this prints out the text - need to modify it to capture it and return it as a string
-vsb
On Tue, Feb 19, 2002 at 06:44:56PM +0000, Nuno Maltez wrote:
Hi,
I know that <dtml-var xxx fmt="structured-text"> converts structured text into HTML, and I know how to call this from a python script/external method.
Now, is there a method somewhere in Zope's classes that return a plain text version of the stx string? With all the special characters and sequences stripped off.
Thanks in advance, Nuno
_______________________________________________ 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 )
_______________________________________________ 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 )
Nuno Maltez writes:
I know that <dtml-var xxx fmt="structured-text"> converts structured text into HTML, and I know how to call this from a python script/external method.
Now, is there a method somewhere in Zope's classes that return a plain text version of the stx string? With all the special characters and sequences stripped off. My "CatalogSupport"
<http://www.dieter.handshake.de/pyprojects/zope> contains an HTML parser that strips all tags. This might be a starting point for you... Read the caveats, please! Dieter
participants (4)
-
Andreas Jung -
Dieter Maurer -
Nuno Maltez -
vsbabu@vsbabu.org