Creole additions / indented paragraphs

3 views
Skip to first unread message

Raphael Slinckx

unread,
Dec 18, 2008, 5:01:01 AM12/18/08
to creoleparser
Hi !

Do anyone knows if creoleparser could support this 'indented
paragraph' addition in the creole syntax:
http://www.wikicreole.org/wiki/CreoleAdditions#section-CreoleAdditions-IndentedParagraphs

And if it's the case, what would be the general idea for implementing
it ?

Thanks !

shday

unread,
Dec 18, 2008, 1:33:16 PM12/18/08
to creoleparser
Hi,

There are several ways to do this, but the following seems to be the
simplest (not tested):

1. Change elements.Paragraph.re_string() to something like:

def re_string(self):
return r'^ *(:?)(.*)\n'

2. Override the _build method with something like:

def _build(self,mo,element_store):
if mo.group(1):
the_class = 'indented'
else:
the_class = None
return bldr.tag.__getattr__(self.tag)(fragmentize(mo.group(2),
self.child_tags,
element_store),
class_=the_class)


Obviously this wouldn't be a great addition to the library (hard coded
':' and 'indented') but you get the idea.

Supporting nested indenting (as suggested at www.wikicreole.org) would
be quite a bit harder.

Steve


On Dec 18, 5:01 am, Raphael Slinckx <rslin...@gmail.com> wrote:
> Hi !
>
> Do anyone knows if creoleparser could support this 'indented
> paragraph' addition in the creole syntax:http://www.wikicreole.org/wiki/CreoleAdditions#section-CreoleAddition...

Raphael Slinckx

unread,
Dec 19, 2008, 7:32:43 AM12/19/08
to creoleparser
I was interested in the nested part unfortunately :)

I wonder if it's possible at all with the current creoleparser design?

On Dec 18, 7:33 pm, shday <stephen.h....@gmail.com> wrote:
> Hi,
>
> There are several ways to do this, but the following seems to be the
> simplest (not tested):
>
> 1. Change elements.Paragraph.re_string() to something like:
>
> def re_string(self):
>     return r'^ *(:?)(.*)\n'
>
> 2. Override the _build method with something like:
>
> def _build(self,mo,element_store):
>     if mo.group(1):
>         the_class = 'indented'
>     else:
>         the_class = None
>     return bldr.tag.__getattr__(self.tag)(fragmentize(mo.group(2),
>                                                       self.child_tags,
>                                                       element_store),
>                                           class_=the_class)
>
> Obviously this wouldn't be a great addition to the library (hard coded
> ':' and 'indented') but you get the idea.
>
> Supporting nested indenting (as suggested atwww.wikicreole.org) would

shday

unread,
Dec 19, 2008, 2:22:12 PM12/19/08
to creoleparser
>
> I wonder if it's possible at all with the current creoleparser design?
>

Yeah, it's possible. It could use a pattern similar to the list
implementation,
but without as much complexity.

I'll implement it myself when it becomes part of Creole 2.0 ;)

Steve
Reply all
Reply to author
Forward
0 new messages