2008-09-30 06:32:32 +00:00
|
|
|
#!/usr/bin/env perl
|
2015-03-27 03:01:01 +02:00
|
|
|
use strict;
|
2015-08-18 10:48:03 +02:00
|
|
|
use v5.10;
|
2015-03-27 03:01:01 +02:00
|
|
|
|
2008-09-30 06:32:32 +00:00
|
|
|
# ====================[ creoleaddition.pl ]====================
|
2008-02-22 10:59:07 +00:00
|
|
|
|
2008-09-30 06:32:32 +00:00
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
|
|
creoleaddition - An Oddmuse module for augmenting the Creole Markup module with
|
|
|
|
|
so-called, unofficial "Creole Additions" markup.
|
|
|
|
|
|
|
|
|
|
=head1 INSTALLATION
|
|
|
|
|
|
|
|
|
|
creoleaddition is simply installable; simply:
|
|
|
|
|
|
|
|
|
|
=over
|
|
|
|
|
|
|
|
|
|
=item First install the Creole Markup module; see
|
|
|
|
|
L<http://www.oddmuse.org/cgi-bin/oddmuse/Creole_Markup_Extension>.
|
|
|
|
|
|
|
|
|
|
=item Move this file into the B<wiki/modules/> directory for your Oddmuse Wiki.
|
|
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
|
|
=cut
|
2014-08-21 22:23:23 +02:00
|
|
|
AddModuleDescription('creoleaddition.pl', 'Creole Addition Markup Extension');
|
2008-09-30 06:32:32 +00:00
|
|
|
|
2015-04-10 13:31:28 +03:00
|
|
|
our ($bol, @MyRules, %RuleOrder);
|
2008-09-30 06:32:32 +00:00
|
|
|
# ....................{ CONFIGURATION }....................
|
|
|
|
|
|
|
|
|
|
=head1 CONFIGURATION
|
|
|
|
|
|
|
|
|
|
creoleaddition is easily configurable; set these variables in the
|
|
|
|
|
B<wiki/config.pl> file for your Oddmuse Wiki.
|
|
|
|
|
|
|
|
|
|
=cut
|
2008-02-22 10:59:07 +00:00
|
|
|
# Since these rules are not official now, users can turn off some of
|
2008-04-05 17:52:34 +00:00
|
|
|
# them.
|
2015-04-10 13:31:28 +03:00
|
|
|
our ($CreoleAdditionSupSub,
|
|
|
|
|
$CreoleAdditionDefList,
|
|
|
|
|
$CreoleAdditionIndentedParagraphs,
|
|
|
|
|
$CreoleAdditionQuote,
|
|
|
|
|
$CreoleAdditionMonospace,
|
|
|
|
|
$CreoleAdditionSmallCaps, $CreoleAdditionIsInSmallCaps);
|
2008-09-30 06:32:32 +00:00
|
|
|
|
|
|
|
|
=head2 $CreoleAdditionSupSub
|
|
|
|
|
|
|
|
|
|
A boolean that, if true, enables this extension's handling of
|
|
|
|
|
^^supscript^^ and ,,subscript,,-style markup. (By default, this boolean is
|
|
|
|
|
true.)
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
$CreoleAdditionSupSub = 1;
|
|
|
|
|
|
|
|
|
|
=head2 $CreoleAdditionDefList
|
|
|
|
|
|
|
|
|
|
A boolean that, if true, enables this extension's handling of
|
|
|
|
|
"; definition : lists"-style markup. (By default, this boolean is true.)
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
$CreoleAdditionDefList = 1;
|
|
|
|
|
|
2009-03-02 17:54:20 +00:00
|
|
|
=head2 $CreoleAdditionIndentedParagraphs
|
|
|
|
|
|
|
|
|
|
A boolean that, if true, enables this extension's handling of
|
|
|
|
|
": indented pagraphs"-style markup. (By default, this boolean is true.)
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
$CreoleAdditionIndentedParagraphs = 1;
|
|
|
|
|
|
2008-09-30 06:32:32 +00:00
|
|
|
=head2 $CreoleAdditionQuote
|
2008-02-22 10:59:07 +00:00
|
|
|
|
2008-09-30 06:32:32 +00:00
|
|
|
A boolean that, if true, enables this extension's handling of
|
|
|
|
|
"""block quote""" and ''inline quote''-style markup. (By default, this
|
|
|
|
|
boolean is true.)
|
2008-02-22 10:59:07 +00:00
|
|
|
|
2008-09-30 06:32:32 +00:00
|
|
|
=cut
|
|
|
|
|
$CreoleAdditionQuote = 1;
|
2008-02-22 10:59:07 +00:00
|
|
|
|
2008-09-30 06:32:32 +00:00
|
|
|
=head2 $CreoleAdditionMonospace
|
|
|
|
|
|
|
|
|
|
A boolean that, if true, enables this extension's handling of
|
|
|
|
|
##monospaced text##-style markup. (By default, this boolean is true.)
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
$CreoleAdditionMonospace = 1;
|
|
|
|
|
|
|
|
|
|
=head2 $CreoleAdditionSmallCaps
|
|
|
|
|
|
|
|
|
|
A boolean that, if true, enables this extension's handling of
|
|
|
|
|
%%small caps%%-style markup. (By default, this boolean is true.)
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
$CreoleAdditionSmallCaps = 1;
|
|
|
|
|
|
|
|
|
|
# ....................{ MARKUP }....................
|
2008-10-04 03:30:50 +00:00
|
|
|
push(@MyRules, \&CreoleAdditionRule);
|
2008-11-15 21:24:32 +00:00
|
|
|
SetHtmlEnvironmentContainer('blockquote');
|
2008-02-22 10:59:07 +00:00
|
|
|
|
2008-09-30 06:32:32 +00:00
|
|
|
# Blockquote line-breaks conflict with Creole-style line-breaks.
|
2008-10-04 03:30:50 +00:00
|
|
|
$RuleOrder{\&CreoleAdditionRule} = -11;
|
2008-09-30 06:32:32 +00:00
|
|
|
|
2008-10-04 03:30:50 +00:00
|
|
|
sub CreoleAdditionRule {
|
2009-03-02 17:54:20 +00:00
|
|
|
# indented paragraphs
|
|
|
|
|
if ($CreoleAdditionIndentedParagraphs && $bol && m/\G((\s*\n)*(\:+)[ \t]*)/cg) {
|
|
|
|
|
return CloseHtmlEnvironment()
|
|
|
|
|
. AddHtmlEnvironment('p', 'class="indent level' . length($3)
|
|
|
|
|
. '" style="margin-left: ' . 2*length($3) . 'em"');
|
|
|
|
|
}
|
|
|
|
|
# definition list
|
|
|
|
|
# ; dt
|
|
|
|
|
# : dd
|
|
|
|
|
elsif ($CreoleAdditionDefList && $bol && m/\G\s*\;[ \t]*(?=(.+(\n)(\s)*\:))/cg
|
2009-02-11 18:14:17 +00:00
|
|
|
or InElement('dd') && m/\G\s*\n(\s)*\;[ \t]*(?=(.+\n(\s)*\:))/cg) {
|
|
|
|
|
return CloseHtmlEnvironmentUntil('dd') . OpenHtmlEnvironment('dl', 1)
|
2015-04-17 01:39:47 +03:00
|
|
|
. AddHtmlEnvironment('dt'); }# `:' needs special treatment, later
|
2009-02-11 18:14:17 +00:00
|
|
|
elsif (InElement('dt') and m/\G\s*\n(\s)*\:[ \t]*(?=(.+(\n)(\s)*\:)*)/cg) {
|
2015-04-17 01:39:47 +03:00
|
|
|
return CloseHtmlEnvironment() . AddHtmlEnvironment('dd');}
|
2009-02-11 18:14:17 +00:00
|
|
|
elsif (InElement('dd') and m/\G\s*\n(\s)*\:[ \t]*(?=(.+(\n)(\s)*\:)*)/cg) {
|
|
|
|
|
return CloseHtmlEnvironment() . AddHtmlEnvironment('dd');}
|
2008-09-30 07:56:18 +00:00
|
|
|
# """block quotes"""
|
2008-10-06 06:11:20 +00:00
|
|
|
elsif ($CreoleAdditionQuote and $bol and m/\G\"\"\"(\n|$)/cg) {
|
2008-09-30 07:56:18 +00:00
|
|
|
return InElement('blockquote')
|
2008-11-06 10:11:02 +00:00
|
|
|
? CloseHtmlEnvironment('blockquote').AddHtmlEnvironment('p')
|
|
|
|
|
: CloseHtmlEnvironments()
|
|
|
|
|
.AddHtmlEnvironment('blockquote').AddHtmlEnvironment('p');
|
2008-10-01 07:54:44 +00:00
|
|
|
}
|
|
|
|
|
# ''inline quotes''
|
2008-11-06 10:11:02 +00:00
|
|
|
elsif ($CreoleAdditionQuote and m/\G\'\'/cgs) { return AddOrCloseHtmlEnvironment('q'); }
|
2008-02-22 18:29:26 +00:00
|
|
|
# ^^sup^^
|
2008-11-06 10:11:02 +00:00
|
|
|
elsif ($CreoleAdditionSupSub and m/\G\^\^/cg) { return AddOrCloseHtmlEnvironment('sup'); }
|
2008-09-30 06:32:32 +00:00
|
|
|
# ,,sub,,
|
2008-11-06 10:11:02 +00:00
|
|
|
elsif ($CreoleAdditionSupSub and m/\G\,\,/cg) { return AddOrCloseHtmlEnvironment('sub'); }
|
2008-09-30 06:32:32 +00:00
|
|
|
# ##monospace code##
|
2008-11-06 10:11:02 +00:00
|
|
|
elsif ($CreoleAdditionMonospace and m/\G\#\#/cg) { return AddOrCloseHtmlEnvironment('code'); }
|
2008-09-30 06:32:32 +00:00
|
|
|
# %%small caps%%
|
2008-10-01 07:54:44 +00:00
|
|
|
elsif ($CreoleAdditionSmallCaps and m/\G\%\%/cg) {
|
2008-11-06 10:11:02 +00:00
|
|
|
return AddOrCloseHtmlEnvironment('span', 'style="font-variant: small-caps"');
|
2008-09-30 06:32:32 +00:00
|
|
|
}
|
|
|
|
|
|
2015-02-27 12:10:18 +02:00
|
|
|
return;
|
2008-02-22 10:59:07 +00:00
|
|
|
}
|
2008-09-30 06:32:32 +00:00
|
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE
|
|
|
|
|
|
|
|
|
|
The information below applies to everything in this distribution,
|
|
|
|
|
except where noted.
|
|
|
|
|
|
|
|
|
|
Copyleft 2008 by B.w.Curry <http://www.raiazome.com>.
|
|
|
|
|
Copyright 2008 by Weakish Jiang <weakish@gmail.com>.
|
2009-03-02 17:54:20 +00:00
|
|
|
Copyright 2009 Alex Schroeder <alex@gnu.com>
|
2008-09-30 06:32:32 +00:00
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see L<http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
=cut
|