creole link handling

7 views
Skip to first unread message

Flo

unread,
Apr 12, 2010, 3:09:19 AM4/12/10
to creoleparser
hi,

I have a question about link parsing in creoleparser.

The specification for Creole 1.0 (http://
webcache.googleusercontent.com/search?
q=cache:Jpl0oAlTLW4J:www.wikicreole.org/wiki/Creole1.0+http://
wikicreole.org/wiki/Creole1.0&cd=1&hl=en&ct=clnk&client=iceweasel-a)
says about links:

Creole:
[[link]]

Recommended XHTML:
<a href="http://www.examplewiki.com/link">link</a>


my creolepaser output looks like:
<a href="link">link</a>

so if I embed [[link]] in a page (MainPage for example) link redirects
you to MainPage/link instead of /link.
Is there a way to modify this behavior, so that the link href looks
like /link?


yours, flo

shday

unread,
Apr 12, 2010, 1:26:27 PM4/12/10
to creoleparser
Hi flo,

You need to create a custom "dialect" for this, as follows:

>>> from creoleparser.dialects import create_dialect, creole11_base
>>> from creoleparser.core import Parser
>>> my_dialect = create_dialect(creole11_base,wiki_links_base_url='/')
>>> parser = Parser(dialect=my_dialect)
>>> parser('[[link]]')
'<p><a href="/link">link</a></p>\n'

In addition to 'wiki_links_base_url', there are a bunch of other
parameters you may find useful:

http://creoleparser.googlecode.com/svn/docs/modules/dialects.html#creoleparser.dialects.create_dialect

For a general overview of customization:

http://creoleparser.googlecode.com/svn/docs/usage.html

Hope this helps!

Steve

Flo

unread,
Apr 13, 2010, 4:10:13 PM4/13/10
to creoleparser

On Apr 12, 7:26 pm, shday <stephen.h....@gmail.com> wrote:
>
> '<p><a href="/link">link</a></p>\n'
>
> In addition to 'wiki_links_base_url', there are a bunch of other
> parameters you may find useful:
>

> http://creoleparser.googlecode.com/svn/docs/modules/dialects.html#cre...


>
> For a general overview of customization:
>
> http://creoleparser.googlecode.com/svn/docs/usage.html
>
> Hope this helps!
>

Thanks, your post helped a lot, exactly what I was looking for

Flo


Reply all
Reply to author
Forward
0 new messages