Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • BackTrack 5 R2
  • Wine 1.4 / 1.5.5
  • Mozilla Firefox 12...
  • Ubuntu 11.04
  • Angry Birds 1.1.2.1
  • Ubuntu 10.04.4 LTS
  • Linux Kernel 3.4
  • Ubuntu Manual 10.10
  • Adobe Flash Player...
  • Pidgin 2.10.4
  • Home > Linux > Programming > Perl Modules

    HTML::WikiConverter::Dialects 0.68

    Download button

    No screenshots available
    Downloads: 340  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    David J. Iberri | More programs
    Perl Artistic License / FREE
    July 10th, 2007, 04:05 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    HTML::WikiConverter::Dialects description

    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.

    DIALECTS

    Each 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.

    Subclassing

    To 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 rules

    Dialects 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.

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    add dialect | wiki converter | Perl tutorial | tutorial | dialect | wiki



    HTML code for linking to this page:


    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM