[Zope-dev] Structured Text Plus

Michel Pelletier michel@digicool.com
Mon, 11 Jun 2001 23:36:46 -0700 (PDT)


On Tue, 12 Jun 2001, Ian Clatworthy wrote:

> Andreas Jung wrote:
> >
> > ----- Original Message -----
> > From: "Ian Clatworthy" <ianc@mincom.com>
> > To: <zope-dev@zope.org>
> > Sent: Sunday, June 10, 2001 9:52 PM
> > Subject: [Zope-dev] Structured Text Plus
> >
> > > I've put together the design for an extended version of
> > > Structured Text which I'd like some feedback on before
> > > I go too much further. At this stage, the design is
> > > explained via a series of user-level How-To's, e.g.
> > > Writing Documents Using Structured Text Plus.
> >
> > Could you please summarize the benefits compared to
> > STXNG ?
>
> As I understand things from reading the STXNG Wiki stuff,
> it's largely an internal rewrite which adds 2 or 3 new
> features, namely images and tables.

This is only a small feature compared to what STXNG really adds to
structured text.  STXNG turns structured text into cross-format Document
Object Model (DOM) in two stages and then into a final format.  The first
stage turns it into a simple DOM that reflects the paragraph structure,
but not the "markup" (italics, bold, links, etc.).

The second stage uses the first stage DOM to create an even more elaborate
DOM based on markup or "colorized text" found in the first DOM's
paragraphs.

The second stage DOM can then be fed to a final "outputter" stage that
renders the DOM in any format you want, currently we support HTML,
DocBook, and MML (Framemaker or something like that) and it would be easy
to add any other XML format or PDF.  Here's an example that will work for
you:

>>> print text
Title

  o *one*

  o **two**

  o 'three'

#
# Create the basic DOM structure

>>> Basic(text)
StructuredTextDocument([
StructuredTextParagraph(Title, [
 StructuredTextParagraph(  o *one*, [
 ])
 StructuredTextParagraph(  o **two**, [
 ])
 StructuredTextParagraph(  o 'three', [
 ])
]),
])

#
# Create the "Colorized" DOM structure

>>> Document(Basic(text))
StructuredTextDocument([
StructuredTextSection(StructuredTextSectionTitle(Title, [
]), [
 StructuredTextBullet(StructuredTextEmphasis('one'), [
 ])
 StructuredTextBullet(StructuredTextStrong('two'), [
 ])
 StructuredTextBullet(StructuredTextLiteral('three'), [
 ])
]),
])

#
# Generate HTML from the DOM

>>> print HTML(Document(Basic(text)))
<html>
<head>
<title>Title</title>
</head>
<body>
<h0>Title</h0>

<ul>
<li><em>one</em></li>
<li><strong>two</strong></li>
<li><code>three</code></li>

</ul>
</body>
</html>

#
# Generate DocBook from the DOM

>>> print DocBookChapter(Document(Basic(text)))
<chapter>
<title>Title</title>
<itemizedlist>
<listitem><para><emphasis>one</emphasis> </para></listitem>
<listitem><para><emphasis>two</emphasis></para></listitem>
<listitem><para><literal>three</literal></para></listitem>
</itemizedlist>
</chapter>

>>>

You should really work from STXNG because we designed it to be extended,
just like you want to do.  You can subclass and customize the "colorizer"
in the second stage to recognize your own customized markup and do what
you will with it.  Amos and I did this to support images in the book.
You can also customize outputers as I explained.

> > You are targeting also the single-source approach
> > for documents with STPlus - what are the benefits
> > compared to working solution like Docbook ?
>
> Upwards compatibility with STX, i.e. something more
> readable than XML.

Amen to that!

-Michel