Skip to content

Instantly share code, notes, and snippets.

@ktat
Forked from ctyo/Install.pm
Last active November 10, 2017 05:26
Show Gist options
  • Save ktat/4f15ffd29074663e0c08 to your computer and use it in GitHub Desktop.
Save ktat/4f15ffd29074663e0c08 to your computer and use it in GitHub Desktop.
FreeStyleWiki上でMarkdown記法での記入を可能にするプラグイン
############################################################
#
# FreeStyleWiki上でMarkdown記法での記入を可能にします。
#
############################################################
package plugin::markdown::Install;
use strict;
sub install {
my $wiki = shift;
$wiki->add_block_plugin(
"markdown", "plugin::markdown::Markdown", "HTML");
}
1;
############################################################
#
# <p>FreeStyleWiki上でMarkdown記法での記入を可能にします。</p>
# <pre>
# {{markdown
# something markdown text
# anything markdown text
# }}
# </pre>
# <p>なお利用するには <a href="http://search.cpan.org/dist/Text-Markdown-Discount/">Text::Markdown::Discount</a> が必要です。<br />
#
# 2012.07.14 A.Tatsukawa [Website](http://ctyo.info)</p>
# 2016.01.07 ktat
#
############################################################
package plugin::markdown::Markdown;
use strict;
use Text::Markdown::Discount qw/markdown/;
# use Text::Markdown qw/markdown/;
#===========================================================
# コンストラクタ
#===========================================================
sub new {
my $class = shift;
my $self = {};
return bless $self,$class;
}
#===========================================================
# ブロック内を処理
#===========================================================
sub block {
my $self = shift;
my $wiki = shift;
my $wiki_source = shift;
$wiki_source =~s{\n```(.+?)\n```\n}{my $text = $1; $text =~s|^| |gm; "\n$text\n"}ges;
return markdown($wiki_source);
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment