Python Desktop Server Weblog 26.2.2004

a picture of myself

Münsterland.org

2004-02-26

How to use macros in strict restructured text

PyDS has a new restructured text mode named strict structured text. This comes in handy if you often write stuff that might include # or $ chars or something like this - usually this would trigger the cheetah template processor. With strict structured text this won't happen, as cheetah isn't called. The only thing that is used in this case is docutils alone. But you might have some macros or nuggets for PyDS that you want to call from your postings.

For example, I have a macro to link a wikipedia page. If I want to use this in strict structured text, I need to call a directive pyds-macro. This works as follows:

.. |httg| pyds-macro:: wikipediaLink
   :definition: The Hitchhiker's Guide to the Galaxy
   :language: en

Now I can reference this new definition as |httg| everywhere in the posting where I need the reference to this wikipedia definition.

If you read the source for the macro, you may notice an additional parameter alt - this is created automatically with docutils. So if you need to call macros from strict structured text, your macro should have this attribute defined currently. This problem is fixed in the CVS version (the additional parameter definition is only needed with 0.7.1). Another way is to use nuggets, as they can accept any parameters, even parameters they don't actually use. The needed directive is called pyds-nugget.

This post references topics: python_desktop_server
posted at 12:16:16    #
February 2004
MoTuWeThFrSaSu
       1
2 3 4 5 6 7 8
9101112131415
16171819202122
23242526272829
Jan
2004
 Oct
2004

This is the Python Desktop Server weblog.


(Donations will be used by the author to buy stuff, fullfill selfish wishes or do other silly recreational things. You have been warned.).
The PyDS is
OSI Certified Open Source Software

Python Powered

XML-Image

© 2004-2007, Georg Bauer