Supporting blog-like newlines instead of explicit '\\'-style line breaks

5 views
Skip to first unread message

Raphael Slinckx

unread,
Nov 25, 2008, 5:26:46 AM11/25/08
to creoleparser
Hi !

I started using the creoleparser for a project of mine. I was
wondering wether it's possible to handle line-breaks more like a blog
editor would do, instead of having to specifically write the '\\' at
the end of line.

The discussion about creole for newlines handling is here:
http://www.wikicreole.org/wiki/Creole1.0#section-Creole1.0-LineBreaks
and here:
http://www.wikicreole.org/wiki/Talk.ChangeLinebreakMarkupProposal

What I did as a first attempt is the following:

class MyDialect(Creole10)
def __init__(self, *args, **kwargs):
super(MyDialect, self).__init__(self, *args, **kwargs)

# Auto-convert newlines to <br> tags
br = self.br
br.regexp = re.compile(esc_neg_look + "(\n|\\\\\\\\)",
re.DOTALL)

In other words add the \n as valid linebreak separator for the self.br
element defined in Creole10.

It seems to be working for all my tests, however i don't know if it
could have any side-effects i'm not aware of. Anyway, I thought I
might just share the tip, and if anyone sees a major problem with this
please let me know !

(This might also be an option for Creole10 dialect,
use_blog_like_newlines=False)
Raf

shday

unread,
Nov 25, 2008, 9:16:40 AM11/25/08
to creoleparser
Hi Raf,

That looks simple enough. If you have time, add a feature request to
the issue tracker:

http://code.google.com/p/creoleparser/issues/entry

It could be implemented as a new option for Creole10 as you suggest.

Thanks,

Steve

Raphael Slinckx

unread,
Nov 26, 2008, 5:42:53 AM11/26/08
to creoleparser
I've posted this suggestion to the issue tracker (issue 17) as well as
a fix for a bug that this suggestion triggers more easily than the
vanilla code regarding line breaks:

try the following with vanilla creoleparser:

'http://www.google.com\\foo'

It will render wrong:
'http://www.google.com<<<123425345>>>foo'

(issue 18)

Cheers!
Reply all
Reply to author
Forward
0 new messages