Text-MediawikiFormat

 view release on metacpan or  search on metacpan

lib/Text/MediawikiFormat.pm  view on Meta::CPAN

	return;
}

sub _html_comment {
	my ( $parser, $text ) = @_;

	_append_processed_line $parser, $text, 'nowiki';
}

sub _html_text {
	my ( $parser, $dtext, $skipped_text, $is_cdata ) = @_;
	my $tagstack = $parser->{tag_stack};
	my ( $newtext, $newstate );

	warnings::warnif("Got skipped_text: `$skipped_text'")
		if $skipped_text;

	if (@$tagstack) {
		if ( grep /\Q$tagstack->[-1]\E/, qw{nowiki pre} ) {
			$newstate = 'nowiki';
		}
		elsif ( $is_cdata && $HTML::Tagset::isCDATA_Parent{ $tagstack->[-1] } ) {

			# If the user hadn't specifically allowed a tag which contains
			# CDATA, then it won't be on the tag stack.
			$newtext = $dtext;
		}
	}

	unless ( defined $newtext ) {
		$newtext = CGI::escapeHTML $dtext unless defined $newtext;

lib/Text/MediawikiFormat.pm  view on Meta::CPAN

	_append_processed_line $parser, $newtext, $newstate;
}

sub _find_blocks_in_html {
	my ( $text, $tags, $opts ) = @_;

	my $parser = HTML::Parser->new(
		start_h                 => [ \&_html_tag,     'self, "S", tagname, text, attr' ],
		end_h                   => [ \&_html_tag,     'self, "E", tagname, text' ],
		comment_h               => [ \&_html_comment, 'self, text' ],
		text_h                  => [ \&_html_text,    'self, dtext, skipped_text, is_cdata' ],
		marked_sections         => 1,
		boolean_attribute_value => '__TEXT_MEDIAWIKIFORMAT_BOOL__',
	);
	$parser->{opts}            = $opts;
	$parser->{tags}            = $tags;
	$parser->{processed_lines} = [];
	$parser->{tag_stack}       = [];

	my @blocks;
	my @lines = split /\r?\n/, $text;



( run in 0.656 second using v1.01-cache-2.11-cpan-454fe037f31 )