StructuredText -> HTML module??
peter at engcorp.com
Thu Sep 19 14:51:54 CEST 2002
Thomas Weholt wrote:
>"Peter Hansen" <peter at engcorp.com> wrote:
>>Maybe you could help us by telling us *what* you expected.
>>Otherwise we're likely to waste our time making suggestions
>>that are just as inadequate from your point of view.
> I need to take a piece of structured text as a string into a method and get
> html out in the other end. As described on the page on Zope.org under
> StructuredText. My hacking with PyWiki gave me a list where each element had
> a '<pre>' in front of it etc. I might be using it the wrong way, but ....
> I was under the impression that StructuredText as described on the site
> mentioned earlier was sort of a standard, that the parser etc. would produce
> the same output.
> All I'm actually after is to be able to write stuff like :
Unfortunately, StructuredText is *not* standardized, so you may not
get the results you want with some, or any, of the implementations.
StructuredText is more of a concept than a standard, although there
are certain rules that are defacto standards (well, barely even that).
The presence of lots of <pre> elements in your experiment suggests
strongly to me that you unexpectedly triggered some rule in
the particular implementation you tested (as opposed to suggesting
that it just doesn't work right).
Maybe you could show an example with a few lines of code that
gives that behaviour. StructuredText can be tricky; it might have
been just the presence of a single bit of punctuation which changed
the output from what you expected into that mess with <pre>.
Zope has one that seems to work okay, although I bet PyWiki does too:
>>> import StructuredText
>>> p = 'This is a test.\012\012- This is a test\012\012- as is
this.\012\012What is up?\012\012 testing a paragraph\012 with indentation.'
>>> print p
This is a test.
- This is a test
- as is this.
What is up?
testing a paragraph
['Basic', 'ClassicDocumentClass', 'Document', 'DocumentClass', 'HTML',
'HTMLClass', 'HTMLNG', 'StructuredText', '__builtins__', '__doc__',
'__file__', '__name__', 'html_quote', 'html_with_references', 'letters',
're', 'string', 'sys']
>>> html = StructuredText.HTML(p)
'<html>\012<body>\012<p>This is a test.</p>\012\012<ul>\012<li><p>This
is a test</p></li>\012<li><p>as is
this.</p></li>\012\012</ul>\012<h1>What is up?</h1>\012<p> testing a
paragraph\012 with indentation.</p>\012</body>\012</html>\012'
>>> print html
<p>This is a test.</p>
<li><p>This is a test</p></li>
<li><p>as is this.</p></li>
<h1>What is up?</h1>
<p> testing a paragraph
More information about the Python-list