Text::HikiDoc - Pure Perl implementation of 'HikiDoc' which is a text-to-HTML conversion tool.
use Text::HikiDoc; # $text = '!Title'; # $html = '<h1>Title</h1>'; $obj = Text::HikiDoc->new(); $html = $obj->to_html($text); or $obj = Text::HikiDoc->new($text); $html = $obj->to_html(); # $text = "!Title\n----\n!!SubTitle"; # $html = "<h2>Title</h2>\n<hr />\n<h3>SubTitle</h3>\n"; $obj = Text::HikiDoc->new({ string => $text, level => 2, empty_element_suffix => ' />', br_mode => 'true', table_border => 'false', }); or $obj = Text::HikiDoc->new($text, 2, ' />', 'true', 'false'); $html = $obj->to_html(); # $text = "!Title\n----\n!!SubTitle\nhogehoge{{br}}fugafuga"; # $html = "<h1>Title</h1>\n<hr />\n<h2>SubTitle</h2>\n<p>hogehoge<br />fugafuga</p>\n"; $obj = Text::HikiDoc->new(); $obj->enable_plugin('br'); $html = $obj->to_html($text); $obj->enable_plugin('br','ins'); @plugins = $obj->plugin_list; # br, ins $obj->is_enabled('br'); # 1 $obj->is_enabled('pr'); # 0
'HikiDoc' is a text-to-HTML conversion tool for web writers. The original 'HikiDoc' is Ruby implementation.
This library is pure perl implementation of 'HikiDoc', and has interchangeability with the original.
This method creates a new HikiDoc object. The following parameters are accepted.
Set text data.
Set headings level. Default setting is '1'. If you set '2', heading tags will start '<h2>'.
Set empty element suffix. Default setting is ' />'.
ex. Default horizontal line is '<hr />'. You can change it '<hr>' If you set '>'.
When br_mode is 'true', changing line in paragraph is replaced 'br' tag. Default setting is 'false'.
This is an original enhancing of this library that is not in the original 'HikiDoc'.
When table_border is 'false', 'table' tag is '<table>'. When it is 'true', add 'border="1"' in table tag. Default setting is 'true'.
This method converts string to html
Set text data. If 'string' is specified by both new() and to_html(), to_html is given to priority.
This method enables plugin module. '@args' is list of plugin names.
This method returns array of enabled plugin lists.
This method returns 1 or 0. If enabled plugin "$str", return 1.
Text::HikiDoc can be enhanced by the plug-in. When you use the plug-in, enable_plugin() is used.
{{aa " (__) (oo) /-------\/ / | || * ||----|| ~~ ~~ "}} is replaced with <pre class="ascii-art"> (__) (oo) /-------\/ / | || * ||----|| ~~ ~~ </pre> If Text::HikiDoc::Plugin::texthighlight or Text::HikiDoc::Plugin::vimcolor is enabled, you can write <<< aa (__) (oo) /-------\/ / | || * ||----|| ~~ ~~ >>>
{{br}}
is replaced with
<br />
{{e('hearts')}} {{e('9829')}}
♥ ♥
{{ins 'insert part'}}
<ins>insert part</ins>
H{{sub('2')}}O
H<sub>2</sub>O
2{{sup(3)}}=8
2<sup>3</sup>=8
Syntax color text is added to the pre mark. That uses Text::Highlight .
The following, it is highlighted as the source code of Perl. When writing instead of"<<< Perl" as "<<<", it becomes a usual pre mark.
<<< Perl sub dummy { $string = shift; $string =~ /$PLUGIN_RE/; print "s:$string\tm:$1\ta:$2\n"; $a = $2; $a =~ s/^\s*(.*)\s*$/$1/; if ( $a =~ /($PLUGIN_RE)/ ) { &hoge($a); } return $string; } >>>
NOTE: Method of mounting this plug-in will change in the future.
Syntax color text is added to the pre mark. That uses Text::VimColor .
http://projects.netlab.jp/hikidoc/
The original 'HikiDoc' was written by Kazuhiko <kazuhiko@fdiary.net>
This release was made by Kawabata, Kazumichi (Higemaru) <kawabata@cpan.org> http://haro.jp/
This library 'HikiDoc.pm' is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Copyright (C) 2006- Kawabata, Kazumichi (Higemaru) <kawabata@cpan.org>
To install Text::HikiDoc, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::HikiDoc
CPAN shell
perl -MCPAN -e shell install Text::HikiDoc
For more information on module installation, please visit the detailed CPAN module installation guide.