Berend van Berkum | 1 Feb 23:53 2011

Re: Lossless rST (Was Re: subdocs branch)

On Mon, Jan 31, 2011 at 08:11:54AM +0000, Guenter Milde wrote:
> On 2011-01-28, Berend van Berkum wrote:
> > On Fri, Jan 14, 2011 at 09:23:02AM +0000, Guenter Milde wrote:
> >> On 2011-01-13, Berend van Berkum wrote:
> 
> > OK, I've taken up my efforts on that code again. Non-lossy rst2rst was
> > not really a consideration for me before so I'll have to see what that
> > takes.
> 
> A non-lossless "rst" writer could be used to 
> 
> * "normalize" the rst markup
> 
> * replace auto enumeration and auto footnotes with generated numbers
>   (optionally)
> 
> * do the second step (writing) of an anything-to-rst conversion.
> 
> * ...

- add generated content
- add/update content stored elsewhere ('metadata')
- normalize content (references, citations, ids)

I have been missing a writer as well. With it, docutils is an even more 
tempting storage format.

But it takes some more before its there. Testing however is going well and it 
looks promising. Only the formatting of the output is really rough.

(Continue reading)

Berend van Berkum | 2 Feb 01:21 2011

Re: Lossless rST (Was Re: subdocs branch)


Excuse me, I meant to write 'adornments', and 'not really _in_compatible'.
For those who noticed.

cheers, Berend	

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
Paul Tremblay | 2 Feb 07:04 2011
Picon

API question: how to get back just string

A simple question (I think). Can someone show me how to use the front 
end tools (or any other method) that allows me to convert an RST file to 
XML so that I get a string? I also need to use command line arguments.

     from docutils.core import publish_cmdline, default_description
     description = ('Generates Docutils-native XML from standalone '
                    'reStructuredText sources.  ' + default_description)
     publish_cmdline(writer_name='xml', description=description)

Outputs to the terminal. I need to capture the output as a string (or as 
a path) and do further transformations.

         status, output = commands.getstatusoutput('rst2xml.py --arsg 
file.rst')

Would work, but that is a bit of a hack, to say the least.

Thanks

Paul

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
David Goodger | 2 Feb 16:27 2011

Re: API question: how to get back just string

On Wed, Feb 2, 2011 at 01:04, Paul Tremblay <paulhtremblay <at> gmail.com> wrote:
> A simple question (I think). Can someone show me how to use the front
> end tools (or any other method) that allows me to convert an RST file to
> XML so that I get a string? I also need to use command line arguments.
>
>     from docutils.core import publish_cmdline, default_description
>     description = ('Generates Docutils-native XML from standalone '
>                    'reStructuredText sources.  ' + default_description)
>     publish_cmdline(writer_name='xml', description=description)
>
> Outputs to the terminal. I need to capture the output as a string (or as
> a path) and do further transformations.

http://docutils.sourceforge.net/docs/api/publisher.html#publisher-convenience-functions
see publish_string.

As for processing command-line arguments, you'll have to replicate the
code in docutils.core that does that, since your use case is
non-standard. The convenience functions are there for convenience in
common use cases only.

I'm tempted to answer "mu" (un-ask the question, it's meaningless).
Perhaps you should create a new Writer instead (a subclass of the XML
writer)? It would have access to the text output.

>         status, output = commands.getstatusoutput('rst2xml.py --arsg
> file.rst')
>
> Would work, but that is a bit of a hack, to say the least.

(Continue reading)

Paul Tremblay | 2 Feb 16:45 2011
Picon

Re: API question: how to get back just string

Yes, the question is a bit meaningless. Let me re-phrase it: I want to 
capture the output from XML, and am willing to pass on arguments:

   import docutils.???
   return_string = docutils.??.method('trim-footnote-reference-space' = 
True)

I've had a look at the convenience methods, but I don't believe the ones 
that return strings or files allow you to pass arguments to it.

Using commands will only work on unix systems, I believe? You would have 
to have rst2xml.py executable in in the PATH, and I don't know if 
Windows allows this.

Thanks

Paul

On 2/2/11 10:27 AM, David Goodger wrote:
> I'm tempted to answer "mu" (un-ask the question, it's meaningless).
> Perhaps you should create a new Writer instead (a subclass of the XML
> writer)? It would have access to the text output.
>
>

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
(Continue reading)

David Goodger | 2 Feb 17:10 2011

Re: API question: how to get back just string

On Wed, Feb 2, 2011 at 10:45, Paul Tremblay <paulhtremblay <at> gmail.com> wrote:
> Yes, the question is a bit meaningless. Let me re-phrase it: I want to
> capture the output from XML, and am willing to pass on arguments:
>
>  import docutils.???
>  return_string = docutils.??.method('trim-footnote-reference-space' = True)
>
> I've had a look at the convenience methods, but I don't believe the ones
> that return strings or files allow you to pass arguments to it.

I understand what you want. The existing convenience functions don't
do it, so you'll have to roll your own, or script existing tools.

Look at what the convenience functions do, and adapt to your needs.
It's all there, just combine the two functions that do parts of what
you want. Use the source, Luke!

> Using commands will only work on unix systems, I believe? You would have to
> have rst2xml.py executable in in the PATH, and I don't know if Windows
> allows this.

It can be done. Details are up to you.

-- David Goodger

> On 2/2/11 10:27 AM, David Goodger wrote:
>>
>> I'm tempted to answer "mu" (un-ask the question, it's meaningless).
>> Perhaps you should create a new Writer instead (a subclass of the XML
>> writer)? It would have access to the text output.
(Continue reading)

Stefan Merten | 2 Feb 18:40 2011
Picon

Documentation inconsistency: Colons in symbols

Hi!

A discussion with the Sphinx developer Georg Brandl revealed that
there seems to be an inconsistency between documentation.

  Directives are indicated by an explicit markup start (".. ")
  followed by the directive type, two colons, and whitespace (together
  called the "directive marker"). Directive types are case-insensitive
  single words (alphanumerics plus internal hyphens, underscores, and
  periods; no whitespace).

  -- http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#directives

  A role marker consists of a colon, the role name, and another colon.
  A role name is a single word consisting of alphanumerics plus
  internal hyphens, underscores, and periods; no whitespace or other
  characters are allowed.

  -- http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#interpreted-text

However, the code sees this different:

    # Alphanumerics with isolated internal [-._+:] chars (i.e. not 2 together):
    simplename = r'(?:(?!_)\w)+(?:[-._+:](?:(?!_)\w)+)*'

    -- docutils/parsers/rst/states.py:544

which is used for role and directive names. This explicitly allows
colons and pluses as well.

(Continue reading)

Guenter Milde | 2 Feb 22:13 2011
Picon

Re: Documentation inconsistency: Colons in symbols

On 2011-02-02, Stefan Merten wrote:

> A discussion with the Sphinx developer Georg Brandl revealed that
> there seems to be an inconsistency between documentation
and code:

>   ... Directive types are case-insensitive
>   single words (alphanumerics plus internal hyphens, underscores, and
>   periods; no whitespace).
...
>   A role name is a single word consisting of alphanumerics plus
>   internal hyphens, underscores, and periods; no whitespace or other
>   characters are allowed.
...

>     # Alphanumerics with isolated internal [-._+:] chars (i.e. not 2 togeth=
> er):
>     simplename =3D r'(?:(?!_)\w)+(?:[-._+:](?:(?!_)\w)+)*'

>     -- docutils/parsers/rst/states.py:544

> which is used for role and directive names. This explicitly allows
> colons and pluses as well.

> So far in `rst.el` I used the documentation for implementing things.
> Thus in Sphinx where colons are extensively used in role and directive
> names font-locking doesn't work correctly.

> Is the code wrong or the documentation?

(Continue reading)

Guenter Milde | 2 Feb 22:15 2011
Picon

Re: API question: how to get back just string

On 2011-02-02, Paul Tremblay wrote:
> A simple question (I think). Can someone show me how to use the front 
> end tools (or any other method) that allows me to convert an RST file to 
> XML so that I get a string? I also need to use command line arguments.

>      from docutils.core import publish_cmdline, default_description
>      description = ('Generates Docutils-native XML from standalone '
>                     'reStructuredText sources.  ' + default_description)
>      publish_cmdline(writer_name='xml', description=description)

> Outputs to the terminal. I need to capture the output as a string (or as 
> a path) and do further transformations.

>          status, output = commands.getstatusoutput('rst2xml.py --arsg 
> file.rst')

> Would work, but that is a bit of a hack, to say the least.

How about re-directing sys.stdout?

Günter

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Docutils-develop mailing list
(Continue reading)

Paul Tremblay | 3 Feb 03:52 2011
Picon

Re: API question: how to get back just string

On 2/2/11 4:15 PM, Guenter Milde wrote:
> On 2011-02-02, Paul Tremblay wrote:
>> A simple question (I think). Can someone show me how to use the front
>> end tools (or any other method) that allows me to convert an RST file to
>> XML so that I get a string? I also need to use command line arguments.
>>       from docutils.core import publish_cmdline, default_description
>>       description = ('Generates Docutils-native XML from standalone '
>>                      'reStructuredText sources.  ' + default_description)
>>       publish_cmdline(writer_name='xml', description=description)
>> Outputs to the terminal. I need to capture the output as a string (or as
>> a path) and do further transformations.
>
>>           status, output = commands.getstatusoutput('rst2xml.py --arsg
>> file.rst')
>
>> Would work, but that is a bit of a hack, to say the least.
> How about re-directing sys.stdout?
>
Meaning what?

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d

Gmane