Using pygments in rest with rst2html

View: New views
7 Messages — Rating Filter:   Alert me  

Using pygments in rest with rst2html

by Vincent Fretin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

How can I use code-block or sourcecode directive in rest and make the command
rst2html.py mydoc.rst > mydoc.html
works?
I easy_install-ed docutils and Pygments. But I don't understand how I
import the special directives. I didn't find a good answer on the web.
Somebody know how to do it?

Thanks
--
Vincent Fretin
_______________________________________________
Grok-dev mailing list
Grok-dev@...
http://mail.zope.org/mailman/listinfo/grok-dev

Re: Using pygments in rest with rst2html

by Michael Haubenwallner-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Vincent Fretin wrote:
> Hello,
>
> How can I use code-block or sourcecode directive in rest and make the command
> rst2html.py mydoc.rst > mydoc.html
> works?
> I easy_install-ed docutils and Pygments. But I don't understand how I
> import the special directives. I didn't find a good answer on the web.
> Somebody know how to do it?
>

The directives are included in
http://pypi.python.org/pypi/ulif.rest

Hth,
Michael

--
http://blog.d2m.at
http://planetzope.org
_______________________________________________
Grok-dev mailing list
Grok-dev@...
http://mail.zope.org/mailman/listinfo/grok-dev

Re: Using pygments in rest with rst2html

by Vincent Fretin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Aug 3, 2008 at 6:18 PM, Michael Haubenwallner <michael@...> wrote:

> Vincent Fretin wrote:
>>
>> Hello,
>>
>> How can I use code-block or sourcecode directive in rest and make the
>> command
>> rst2html.py mydoc.rst > mydoc.html
>> works?
>> I easy_install-ed docutils and Pygments. But I don't understand how I
>> import the special directives. I didn't find a good answer on the web.
>> Somebody know how to do it?
>>
>
> The directives are included in
> http://pypi.python.org/pypi/ulif.rest

Thanks, I easy_install-ed ulif.rest
I edited bin/rst2html.py to include the three imports:
from ulif.rest import directives_plain
from ulif.rest import roles_plain
from ulif.rest import pygments_directive # for syntax-highlighting support
and I tested it:
$ rst2html.py mydoc.rst > mydoc.html
and it gave me :
File "$[sandbox}/lib/python2.4/site-packages/docutils-0.4-py2.4.egg/docutils/parsers/rst/states.py",
line 110, in ?
    import roman
ImportError: No module named roman

Indeed roman.py module is nowhere, not in the virtualenv's
site-packages, not in site-packages global directory.

Then I easy-installed docutils==0.5 and modified again bin/rst2html.py
and it works. docutils 0.5 have the roman.py module.
$ find lib/python2.4/site-packages/ -name roman.py
lib/python2.4/site-packages/docutils-0.5-py2.4.egg/roman.py

The docutils dependency version should be updated to 0.5, and a new
release of ulif.rest should be made, no?

--
Vincent Fretin
_______________________________________________
Grok-dev mailing list
Grok-dev@...
http://mail.zope.org/mailman/listinfo/grok-dev

Re: Re: Using pygments in rest with rst2html

by Sylvain Viollon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, 3 Aug 2008 19:00:25 +0200
"Vincent Fretin" <vincent.fretin@...> wrote:

  Hello,

>
> Thanks, I easy_install-ed ulif.rest
> I edited bin/rst2html.py to include the three imports:
> from ulif.rest import directives_plain
> from ulif.rest import roles_plain
> from ulif.rest import pygments_directive # for syntax-highlighting
> support and I tested it:
> $ rst2html.py mydoc.rst > mydoc.html
> and it gave me :
> File
> "$[sandbox}/lib/python2.4/site-packages/docutils-0.4-py2.4.egg/docutils/parsers/rst/states.py",
> line 110, in ? import roman
> ImportError: No module named roman
>
> Indeed roman.py module is nowhere, not in the virtualenv's
> site-packages, not in site-packages global directory.
>

  That's a known bug of docutils packaging. Reinstall a second time
like you did and that's fine.

> Then I easy-installed docutils==0.5 and modified again bin/rst2html.py
> and it works. docutils 0.5 have the roman.py module.
> $ find lib/python2.4/site-packages/ -name roman.py
> lib/python2.4/site-packages/docutils-0.5-py2.4.egg/roman.py
>
> The docutils dependency version should be updated to 0.5, and a new
> release of ulif.rest should be made, no?
>

  No, if the version of docutils in ulif.rest is not binded to 0.4,
there is no major changes between this two version which will broke the
extension.


  Cheers,

  Sylvain,



--
Sylvain Viollon -- Infrae
t +31 10 243 7051 -- http://infrae.com
Hoevestraat 10 3033GC Rotterdam -- The Netherlands
_______________________________________________
Grok-dev mailing list
Grok-dev@...
http://mail.zope.org/mailman/listinfo/grok-dev

Re: Re: Using pygments in rest with rst2html

by Vincent Fretin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Aug 4, 2008 at 10:29 AM, Sylvain Viollon <sylvain@...> wrote:
> On Sun, 3 Aug 2008 19:00:25 +0200
> "Vincent Fretin" <vincent.fretin@...> wrote:
>> The docutils dependency version should be updated to 0.5, and a new
>> release of ulif.rest should be made, no?
>>
>
>  No, if the version of docutils in ulif.rest is not binded to 0.4,
> there is no major changes between this two version which will broke the
> extension.
Actually, you have docutils==0.4 in setup.py
--
Vincent Fretin
_______________________________________________
Grok-dev mailing list
Grok-dev@...
http://mail.zope.org/mailman/listinfo/grok-dev

Re: Using pygments in rest with rst2html

by Martijn Faassen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey,

Vincent Fretin wrote:

> On Mon, Aug 4, 2008 at 10:29 AM, Sylvain Viollon <sylvain@...> wrote:
>> On Sun, 3 Aug 2008 19:00:25 +0200
>> "Vincent Fretin" <vincent.fretin@...> wrote:
>>> The docutils dependency version should be updated to 0.5, and a new
>>> release of ulif.rest should be made, no?
>>>
>>  No, if the version of docutils in ulif.rest is not binded to 0.4,
>> there is no major changes between this two version which will broke the
>> extension.
> Actually, you have docutils==0.4 in setup.py

Uli, what do you think should happen? Normally we don't really
easy_install ulif.rest, so this might not be an issue when ulif.rest is
installed in a buildout. Still, if an upgrade to 0.5 can make things
easy_install properly as well, we might want to do this.

Regards,

Martijn

_______________________________________________
Grok-dev mailing list
Grok-dev@...
http://mail.zope.org/mailman/listinfo/grok-dev

Re: Re: Using pygments in rest with rst2html

by Uli Fouquet :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Vincent,

Vincent Fretin wrote:

> Thanks, I easy_install-ed ulif.rest
> I edited bin/rst2html.py to include the three imports:
> from ulif.rest import directives_plain
> from ulif.rest import roles_plain
> from ulif.rest import pygments_directive # for syntax-highlighting support

Import of ``pygments_directive`` should be sufficient, if you only want
syntax highlighting in general.

> and I tested it:
> $ rst2html.py mydoc.rst > mydoc.html
> and it gave me :
> File "$[sandbox}/lib/python2.4/site-packages/docutils-0.4-py2.4.egg/docutils/parsers/rst/states.py",
> line 110, in ?
>     import roman
> ImportError: No module named roman
>
> Indeed roman.py module is nowhere, not in the virtualenv's
> site-packages, not in site-packages global directory.
Yup. As Sylvain already explained (thanks!) this is a known bug of the
docutils 0.4 packaging. He already told, how to fix that in
installations.

> Then I easy-installed docutils==0.5 and modified again bin/rst2html.py
> and it works. docutils 0.5 have the roman.py module.
> $ find lib/python2.4/site-packages/ -name roman.py
> lib/python2.4/site-packages/docutils-0.5-py2.4.egg/roman.py
>
> The docutils dependency version should be updated to 0.5, and a new
> release of ulif.rest should be made, no?

You've been lucky :-) I assume you haven't used other special directives
like `versionadded` or the like. Mainly thanks to Lea Wiemann there was
a major (and smart) rewrite of the directive registering API with the
0.5 version of docutils and most stuff of current ``ulif.rest`` should
break with docutils 0.5.

Therefore it is unfortunately not as simple as just bumping the
dependency number :-/

I'd like to adapt ``ulif.rest`` to docutils 0.5 after this year's GSOC,
because the new API is really an improvement IMHO.

Kind regards,

--
Uli



_______________________________________________
Grok-dev mailing list
Grok-dev@...
http://mail.zope.org/mailman/listinfo/grok-dev

signature.asc (198 bytes) Download Attachment
LightInTheBox - Buy quality products at wholesale price