HTML::WikiConverter::Dialects

HTML::WikiConverter::Dialects is a Perl module which contains a tutorial on how to add a dialect.
Download

HTML::WikiConverter::Dialects Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • David J. Iberri
  • Publisher web site:
  • http://search.cpan.org/~diberri/HTML-WikiConverter-MediaWiki-0.55/lib/HTML/WikiConverter/MediaWiki.pm

HTML::WikiConverter::Dialects Tags


HTML::WikiConverter::Dialects Description

HTML::WikiConverter::Dialects is a Perl module which contains a tutorial on how to add a dialect. HTML::WikiConverter::Dialects is a Perl module which contains a tutorial on how to add a dialect.SYNOPSIS # In your dialect module: package HTML::WikiConverter::MySlimWiki; use HTML::WikiConverter -dialect; rule b => { start => '**', end => '**' }; rule i => { start => '//', end => '//' }; rule strong => { alias => 'b' }; rule em => { alias => 'i' }; rule hr => { replace => "n----n" }; # In a nearby piece of code: package main; use Test::More tests => 5; my $wc = new HTML::WikiConverter( dialect => 'MySlimWiki' ); is( $wc->html2wiki( 'text' ), '**text**', b ); is( $wc->html2wiki( 'text' ), '//text//', i ); is( $wc->html2wiki( 'text' ), '**text**', 'strong' ); is( $wc->html2wiki( 'text' ), '//text//', 'em' ); is( $wc->html2wiki( '' ), '----', 'hr' );HTML::WikiConverter (or H::WC, for short) is an HTML to wiki converter. It can convert HTML source into a variety of wiki markups, called wiki "dialects". This manual describes how you to create your own dialect to be plugged into HTML::WikiConverter.DIALECTSEach dialect has a separate dialect module containing rules for converting HTML into wiki markup specific for that dialect. Currently, all dialect modules are in the HTML::WikiConverter:: package space and subclass HTML::WikiConverter. For example, the MediaWiki dialect module is HTML::WikiConverter::MediaWiki, while PhpWiki's is HTML::WikiConverter::PhpWiki. However, dialect modules need not be in the HTML::WikiConverter:: package space; you may just as easily use package MyWikiDialect; and H::WC will Do The Right Thing.From now on, I'll be using the terms "dialect" and "dialect module" interchangeably.SubclassingTo interface with H::WC, dialects need to subclass it. Because you'll probably be wanting the rule() and attribute() functions as well, subclassing and importing these functions is done in a single step: use HTML::WikiConverter -dialect;This will add HTML::WikiConverter to your dialect's @ISA and will import the attribute() and rule() functions into your dialect's package.Conversion rulesDialects guide H::WC's conversion process with a set of rules that define how HTML elements are turned into their wiki counterparts. Each rule corresponds to an HTML tag (including nonstandard tags), and there may be any number of rules. Rules are added with the rule() function that was imported when you subclassed H::WC (see above).The syntax for rule() is as follows: rule $tag => %subrules;where $tag is the name of the HTML tag (e.g., "b", "em", etc.) and %subrules contains subrules that specify how that tag will be converted. Requirements: · Perl


HTML::WikiConverter::Dialects Related Software