Stefan Merten | 1 May 14:54 2003
Picon

Re: [Docutils-users] Custom behaviour in reST


Hi David and all!

I'm redirecting this to the developers list.

Today David Goodger wrote:
>> I think it's good to keep such things
>> outside the core of Docutils if this is to be able to scale.
> 
> Agreed.  I'm leaning toward adding a single new general-purpose element, 
> "phrase", equivalent to HTML's <span>.  Which is why I originally wrote
> 
>      (Here, the <keyword> etc. tags are just examples off the
>      top of my head.  They're not necessarily a recommended
>      implementation.  "class" attributes on a <span> equivalent
>      [perhaps "phrase"] may be the way to go.)
> 
> In other words, <keyword> etc. were just placeholders.  Here's the 
> example rewritten using the generic "phrase":
> 
>      <literal_block xml:space="preserve" class="python">
>      <phrase class="keyword">print</> <phrase
>       class="string">'This is Python code.'</>
>      <phrase class="keyword">for</> <phrase
>       class="identifier">i</> <phrase class="keyword">in</> <phrase
>       class="expression">range(10)</>:
>          <phrase class="keyword">print</> <phrase
>           class="expression">i</>
>      </literal_block>
> 
(Continue reading)

Patrick K. O'Brien | 1 May 16:49 2003

xml-declaration configuration option for html

I'm uploading html files to a web server that is choking on the
xml-declaration.  What would you think of having the html writer honor
the xml-declaration configuration option the same way the xml writer
does?

I can probably hack it up and commit it to CVS, but I didn't want to
do it if there was a good reason not to.

--

-- 
Patrick K. O'Brien
Orbtech      http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
g.schwant | 1 May 22:37 2003
Picon
Picon

RE: Unsafe processing for the input file

Hello Pierre-Yves,

I have just committed a new release of DocFactory. It has a
"Preferences"-Menu where you can select the option "Backup files". This will force DocFactory
to store a copy of the previous version of a file as "[filename].bak"
whenever a file is saved.

Please note that DocFactory saves a file only in the following cases:

* The user selects "File -> Save" from the menubar (or presses the toolbar's
"Save"-button).

* The user has modified a file with DocFactory and selects "File -> Publish"
from the menubar (or presses the toolbar's "Publish file"-button or presses
F7). 

If a file has NOT been modified, it is NOT saved before publishing. 

A modified file has to be saved before publishing because otherwise the
output file would not contain your last modifications. To understand this you
have to know that DocFactory does not process the input file by itself.
DocFactory is a simple text editor with an interface to Docutils. The whole
publish-process is done by Docutils. When you press F7, DocFactory saves the file ---
if you have changed it ---, calls the "publish_file"-function of
"docutils.core" and the rest is done by Docutils: Docutils reads the input file and
writes the output file. All error messages of Docutils are redirected to
DocFactory's log-window. 

The approach of DocFactory is very similar to programming environments where
the programmer edits her/his source code, saves the changes, runs the
(Continue reading)

David Goodger | 1 May 23:49 2003

Re: [Docutils-users] Custom behaviour in reST

Moved to docutils-develop; subscribe at 
<http://lists.sf.net/lists/listinfo/docutils-develop>.

[David Goodger]
>>    <literal_block xml:space="preserve" class="python">
>>     <phrase class="keyword">print</> <phrase
>>      class="string">'This is Python code.'</>
>>     <phrase class="keyword">for</> <phrase
>>      class="identifier">i</> <phrase class="keyword">in</> <phrase
>>      class="expression">range(10)</>:
>>         <phrase class="keyword">print</> <phrase
>>          class="expression">i</>
>>     </literal_block>

[Magnus Lyckå]
> If I understand you correctly, your thought is that all the drivers
> should be extended to know how to render "keyword", "string", "expression"
> etc. But that means that I need to patch the drivers if I make a new
> format which will introduce some new concept.

No; look again, closely.  There's no more "<keyword>", it's now '<phrase 
class="keyword">'.  The difference is that Writers need only support the 
one element ("phrase") and may ignore the class attributes if they don't 
support them.  Worst case: the output isn't colorful or styled.  In the 
case of HTML, the "class" attributes get passed through to the output, 
so they can interact with the stylesheet.  Other formats have a similar 
capacity.

> My idea is that the "directive" (if that's what it should be) should be
> able to carry explicit instructions on how to render output on specific
(Continue reading)

David Goodger | 2 May 00:02 2003

Re: xml-declaration configuration option for html

Patrick K. O'Brien wrote:
> I'm uploading html files to a web server that is choking on the
> xml-declaration.  What would you think of having the html writer honor
> the xml-declaration configuration option the same way the xml writer
> does?

Go for it!

-- David Goodger

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
David Goodger | 2 May 01:39 2003

Re: Re: [Docutils-users] Custom behaviour in reST

[David Goodger]
 >> In other words, <keyword> etc. were just placeholders.  Here's the
 >> example rewritten using the generic "phrase":
 >>
 >>     <literal_block xml:space="preserve" class="python">
 >>     <phrase class="keyword">print</> <phrase
 >>      class="string">'This is Python code.'</>
 >>     <phrase class="keyword">for</> <phrase
 >>      class="identifier">i</> <phrase class="keyword">in</> <phrase
 >>      class="expression">range(10)</>:
 >>         <phrase class="keyword">print</> <phrase
 >>          class="expression">i</>
 >>     </literal_block>
 >>
 >> It's more verbose but more easily extensible and more appropriate
 >> for the case at hand.

[Stefan Merten]
 > That means: Exchange the new element tags for new values of the
 > ``class`` attribute. I can't see where this is *really* much
 > better...

It's better because an unknown attribute can easily be ignored,
whereas an unknown element will cause an exception (by design).  A new
"class" attribute value can be introduced without any need for
Docutils code change.  In the majority case all that's needed is a
stylesheet change, which is much easier.

 > The underlying problem seems to be, that
 >
(Continue reading)

David Goodger | 2 May 01:40 2003

Re: Re: [Docutils-users] Custom behaviour in reST

[David Goodger]
 >> In other words, <keyword> etc. were just placeholders.  Here's the
 >> example rewritten using the generic "phrase":
 >>
 >>     <literal_block xml:space="preserve" class="python">
 >>     <phrase class="keyword">print</> <phrase
 >>      class="string">'This is Python code.'</>
 >>     <phrase class="keyword">for</> <phrase
 >>      class="identifier">i</> <phrase class="keyword">in</> <phrase
 >>      class="expression">range(10)</>:
 >>         <phrase class="keyword">print</> <phrase
 >>          class="expression">i</>
 >>     </literal_block>
 >>
 >> It's more verbose but more easily extensible and more appropriate
 >> for the case at hand.

[Stefan Merten]
 > That means: Exchange the new element tags for new values of the
 > ``class`` attribute. I can't see where this is *really* much
 > better...

It's better because an unknown attribute can easily be ignored,
whereas an unknown element will cause an exception (by design).  A new
"class" attribute value can be introduced without any need for
Docutils code change.  In the majority case all that's needed is a
stylesheet change, which is much easier.

 > The underlying problem seems to be, that
 >
(Continue reading)

Patrick K. O'Brien | 2 May 02:01 2003

Re: xml-declaration configuration option for html

David Goodger <goodger <at> python.org> writes:

> Patrick K. O'Brien wrote:
> > I'm uploading html files to a web server that is choking on the
> > xml-declaration.  What would you think of having the html writer honor
> > the xml-declaration configuration option the same way the xml writer
> > does?
> 
> Go for it!

I checked it in.  But it's not fully functional yet.

It works as a command-line option (--no-xml-declaration), but I can't
seem to get either the html writer I just checked in or the standard
xml writer to honor the xml-declaration option as part of a config
file.  My config file looks like this:

[options]

compact_lists: 0
source_link: 1
datestamp: %Y-%m-%d %H:%M UTC
generator: 1
xml_declaration: 0

All the other options in this config file work as expected, but the
xml_declaration does not.  I've tried every variation I could think
of, and none of them work with the xml writer or my revised html
writer.  Does anyone see anything obviously wrong, or is this maybe a
problem with the Optik stuff?
(Continue reading)

David Goodger | 2 May 02:53 2003

Re: xml-declaration configuration option for html

Patrick K. O'Brien wrote:
> I checked it in.  But it's not fully functional yet.
> 
> It works as a command-line option (--no-xml-declaration), but I can't
> seem to get either the html writer I just checked in or the standard
> xml writer to honor the xml-declaration option as part of a config
> file.  My config file looks like this:
> 
> [options]
> 
> compact_lists: 0
> source_link: 1
> datestamp: %Y-%m-%d %H:%M UTC
> generator: 1
> xml_declaration: 0

'0' (a string) is not false; '' is.  Change it to

     xml_declaration:

I.e., drop the 0.  Ditto for compact_lists.

It took me a while to figure it out.  While investigating, I rearranged 
the added code a bit.

--

-- 
David Goodger    http://starship.python.net/~goodger

Programmer/sysadmin for hire: http://starship.python.net/~goodger/cv

(Continue reading)

Patrick K. O'Brien | 2 May 03:52 2003

Re: xml-declaration configuration option for html

David Goodger <goodger <at> python.org> writes:

> '0' (a string) is not false; '' is.  Change it to
> 
>      xml_declaration:
> 
> I.e., drop the 0.  Ditto for compact_lists.

Ah!

> It took me a while to figure it out.  While investigating, I
> rearranged the added code a bit.

I saw.  I wasn't sure if you'd agree with my choices, but figured
you'd rearrange things.  Thanks.

--

-- 
Patrick K. O'Brien
Orbtech      http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

Gmane