Adding strikethrough

45 views
Skip to first unread message

wolfsch

unread,
Nov 26, 2008, 10:10:46 AM11/26/08
to creoleparser
I am currently working on a local wiki app, usind PythonCE and ppygui
on a Windows Mobile device. Since strikethrough is very important for
me, I added that using your macro example and the improved macro_func
of bruno. It works perfectly.

However, I am not too happy with that solution, since I now have to
use the <<strike>>text<</strike>> syntax to markup text accordingly.
On a small PDA screen this is not a beautiful solution. Any other
ideas ?

Thanks,

Wolfgang

shday

unread,
Nov 26, 2008, 1:06:20 PM11/26/08
to creoleparser
Hi Wolfgang,

You can change (not subclass) the Creole10 class to add new inline
mark-up without to much trouble. Follow the pattern for subscript,
superscript, etc. See lines 120 - 131 here:

http://code.google.com/p/creoleparser/source/browse/trunk/creoleparser/dialects.py?spec=svn69&r=69

Replacing these lines with the following should work (untested):

if use_additions:
self.sub = InlineElement('sub', ',,',[])
self.sup = InlineElement('sup', '^^',[self.sub])
self.u = InlineElement('u', '__',[self.sup, self.sub])
self.tt = InlineElement('tt', '##',[self.u, self.sup,
self.sub])
self.strike = InlineElement('del', '--',[self.tt,self.u,
self.sup, self.sub])
self.em.child_tags.extend([self.strike,self.tt, self.u,
self.sup, self.sub])
self.strong.child_tags.extend([self.strike,self.tt,
self.u, self.sup, self.sub])
link_child_tags.extend([self.strike,self.tt, self.u,
self.sup, self.sub])
inline_elements[0] =
(self.no_wiki,self.bodiedmacro,self.macro)
inline_elements.extend([self.strike,self.tt, self.u,
self.sup, self.sub])
table_cell_children.extend([self.strike,self.tt, self.u,
self.sup, self.sub])

wolfsch

unread,
Nov 27, 2008, 2:39:40 AM11/27/08
to creoleparser
Hi, Steve,

thank you so much for your support ! It works without problems, as far
as I can see today.

Could you imagine to add strikethrough into your Creole additions some
day ?

Wolfgang

On Nov 26, 7:06 pm, shday <stephen.h....@gmail.com> wrote:
> Hi Wolfgang,
>
> You can change (not subclass) the Creole10 class to add new inline
> mark-up without to much trouble. Follow the pattern for subscript,
> superscript, etc. See lines 120 - 131 here:
>
> http://code.google.com/p/creoleparser/source/browse/trunk/creoleparse...
> > Wolfgang- Hide quoted text -
>
> - Show quoted text -

shday

unread,
Nov 27, 2008, 7:59:56 PM11/27/08
to creoleparser
> Could you imagine to add strikethrough into your Creole additions some
> day ?

While I probably won't make stikethrough part of the library anytime
soon, I do plan to make it much easier to add arbitrary markup so
there won't be any need to hack the library code!

Steve

wolfsch

unread,
Jan 8, 2009, 12:17:10 PM1/8/09
to creoleparser
I played around a little with Steve's svn/r128 code and modified the
"simple_token_dict" dictionary to add a strikethrough token. This is
really easy now ! Anyway, I wonder what I could do if I want to share
my application one day.

I am very new to Python, but as far as I understand, I can not
subclass the Creole10 class accordingly, since there is no constructor
parameter to work with or a member that could be adapted later. Is
that right ? If yes, any idea how to handle this ?

Yes, there is still the macro way to go (which I did), but as said
before I work on a PDA and try to be as simple as possible.

Thank you.

Wolfgang

shday

unread,
Jan 8, 2009, 1:06:01 PM1/8/09
to creoleparser
Hi Wolfgang,

It's possible to extend creoleparser through subclassing, but it's not
intuitive and the result may be buggy if you're not careful. There is
an example of suclassing Creole10 here:

http://groups.google.com/group/creoleparser/browse_thread/thread/de502bb7068966a3

This really should be easier but I haven't had time to do the
necessary refactoring (actually, I've worked on it a bit but haven't
gotten anywhere).

There's also an issue created for this sort of thing <http://
code.google.com/p/creoleparser/issues/detail?id=12> but I haven't
heard from duncan.mcgreggor (the issue owner) lately. He seems to
have some good ideas about it.

For your case, I think the best solution for now would be to add a new
parameter (simple_token_dict) to the Creole10 constructor and make
that part of the library. I'll try and get to it soon. Alternatively,
if you want to try it on your own, please submit the patch!

Steve
Reply all
Reply to author
Forward
0 new messages