[dokuwiki] Re: FCKW wysiwyg plugin published
- From: Myron Turner <turnermm02@xxxxxxx>
- To: dokuwiki@xxxxxxxxxxxxx
- Date: Wed, 09 Jan 2008 10:00:12 -0600
I will try these out. I had also been working on a set of routines to
handle the headers as well as the other formatting features available in
the Format drop down menu. I might also work on implementing the
templates menu, since I see a use for it in what I am planning for my
own site.
I hope to have my latest version posted to my web site by this afternoon
(CST) or tomorrow morning.
Best,
Myron
Spring Pierre wrote:
dear myron,
i added s.th. to your DokuWikiFCK.pm solution ( thanks or that ;) in
order to get rid of any html within headers. taken the fact that
<h1><i>Myron</i> Turner</h1>
was rendered to
====== //Myron// Turner ======
you just need to add the following lines in the rules definition:
*********************************
# overwrite rules for h1 to h5
for( 1..5 ) {
$rules->{"h$_"} = { replace => \&_header };
}
# there is no h6 in dokuwiki syntax!!!
# remove the rule from the super class
$rules->{h6} = { start => '', end => ''};
*********************************
and define the following 3 subroutines:
*********************************
# dokuwiki does not allow any syntax within
# headers, so here we clean those
sub _header {
my($self, $node, $rules ) = @_;
# remove html nodes from content
my $text = $self->_as_text($node);
# get header level
$node->tag =~ /(\d)/;
# get pre and postfix for dokuwiki syntax
# and pre/append those
my $pre_and_post_fix = "=" x (7 - $1);
my $str = $pre_and_post_fix . $text . $pre_and_post_fix;
return $str;
}
# this helper is used for the header subroutine, in
# order to return the text without any html tags.
# ( we can not use the $node->as_text() methode, as the
# WikiConverter parsed it into a <~text text="content">
# tag... )
sub _as_text {
my($self, $node) = @_;
my $text = join '', map { $self->__get_text($_) }
$node->content_list;
return defined $text ? $text : '';
}
# this helper is used for the header subroutine, in
# order to return the text without any html tags.
# ( we can not use the $node->as_text() methode, as the
# WikiConverter parsed it into a <~text text="content">
# tag... )
sub __get_text {
my($self, $node) = @_;
$node->normalize_content();
if( $node->tag eq '~text' ) {
# we return text nodes
return $node->attr('text');
} elsif( $node->tag eq '~comment' ) {
# we keep comments
return '<!--' . $node->attr('text') . '-->';
} else {
# recurse
my $output = $self->_as_text($node)||'';
return $output;
}
}
*********************************
this is my first atempt in coding perl. it's not easy to get into it.
if you see s.th. really ugly, please let me know. i hope you can use
this.
greetings.
pierre.
--
Liip AG // Rte de la Fonderie 7 // CH-1700 Fribourg
Fon 026 4222511 // Key id 0x5BF5F8FA // www.liip.ch
--
_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist
- References:
- [dokuwiki] Re: FCKW wysiwyg plugin published
- From: Gijs van Gemert
- [dokuwiki] Re: FCKW wysiwyg plugin published
- From: Myron Turner
- [dokuwiki] Re: FCKW wysiwyg plugin published
- From: Spring Pierre
Other related posts:
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
- » [dokuwiki] Re: FCKW wysiwyg plugin published
dear myron,i added s.th. to your DokuWikiFCK.pm solution ( thanks or that ;) in order to get rid of any html within headers. taken the fact that
<h1><i>Myron</i> Turner</h1>
was rendered to
====== //Myron// Turner ======
you just need to add the following lines in the rules definition:
*********************************
# overwrite rules for h1 to h5
for( 1..5 ) {
$rules->{"h$_"} = { replace => \&_header };
}
# there is no h6 in dokuwiki syntax!!!
# remove the rule from the super class
$rules->{h6} = { start => '', end => ''};
*********************************
and define the following 3 subroutines:
*********************************
# dokuwiki does not allow any syntax within
# headers, so here we clean those
sub _header {
my($self, $node, $rules ) = @_;
# remove html nodes from content
my $text = $self->_as_text($node);
# get header level
$node->tag =~ /(\d)/;
# get pre and postfix for dokuwiki syntax
# and pre/append those
my $pre_and_post_fix = "=" x (7 - $1);
my $str = $pre_and_post_fix . $text . $pre_and_post_fix;
return $str;
}
# this helper is used for the header subroutine, in
# order to return the text without any html tags.
# ( we can not use the $node->as_text() methode, as the
# WikiConverter parsed it into a <~text text="content">
# tag... )
sub _as_text {
my($self, $node) = @_;
my $text = join '', map { $self->__get_text($_) }
$node->content_list;
return defined $text ? $text : '';
}
# this helper is used for the header subroutine, in
# order to return the text without any html tags.
# ( we can not use the $node->as_text() methode, as the
# WikiConverter parsed it into a <~text text="content">
# tag... )
sub __get_text {
my($self, $node) = @_;
$node->normalize_content();
if( $node->tag eq '~text' ) {
# we return text nodes
return $node->attr('text');
} elsif( $node->tag eq '~comment' ) {
# we keep comments
return '<!--' . $node->attr('text') . '-->';
} else {
# recurse
my $output = $self->_as_text($node)||'';
return $output;
}
}
*********************************
this is my first atempt in coding perl. it's not easy to get into it.
if you see s.th. really ugly, please let me know. i hope you can use
this.
greetings. pierre. -- Liip AG // Rte de la Fonderie 7 // CH-1700 Fribourg Fon 026 4222511 // Key id 0x5BF5F8FA // www.liip.ch
- [dokuwiki] Re: FCKW wysiwyg plugin published
- From: Gijs van Gemert
- [dokuwiki] Re: FCKW wysiwyg plugin published
- From: Myron Turner
- [dokuwiki] Re: FCKW wysiwyg plugin published
- From: Spring Pierre