perl - Markdown変換スクリプト

ネタを整理するのに Markdown で書くと便利なのかなと調べていると
CPAN に Text::Markdown というモジュールがあったので

スクリプトにファイル名を渡すか、__END__ 以下に Markdown を書いて使います。

# markdown2html.pl

use strict;
use warnings;

use Text::Markdown 'markdown';

my $file = shift;
my $text = "";

if ($file) {
 open(my $fh, '<', $file) or die($!);
  local $/;
  $text = <$fh>;
 close $fh;
} else {
 local $/;
 $text = <DATA>;
my $html = markdown($text);

#print $text;
print $html;

#markdown sample


[リンク文字列](http://example.com/ "タイトル")

![画像の説明](/path/to/image.jpg "タイトル")

- listA
- listB
- listC


1. listA
2. listB
3. listC



set markdown2html="C:\markdown2html.pl"
set output="C:\%~n1%.htm"

perl %markdown2html% %1 > %output%


個人的には秀丸から perl に渡して処理とかよくやるので、使うかなと思いまして。


Tomas Doran / Text-Markdown - search.cpan.org
Daring Fireball: Markdown
blog::2310 » Markdown文法の全訳
Markdown - Wikipedia

1 件のコメント:

  1. This article is wonderful. By the way, we would like to let you know about our company: Premium Travel Vietnam (PTV) is a professional, leading tour operator based in Da Nang city – central Vietnam. Our office is at 21 Che Lan Vien Str, Ngu Hanh Son Dist, Da Nang city. We have been in the tourism industry for many years and with a comprehensive experience in this field, we are proud to be one of the best travel agents in Da Nang in particular and in Vietnam in general. Everyday,we provide tourists with all tour packages, holiday deals, vacations, private trips to all sightseeings, historical sites in Vietnam such as Ha Long bay, Thang Long Citadel, Ho Dynasty Citadel, Trang An Landscape Complex, Hoi An ancient town, My Son Holyland, Hue ancient capital, Phong Nha National Park. Besides, Vietnam is not only well known on the world map but the people are so friendly, warm hearted and welcoming. Today, there are more and more people coming to visit Vietnam by airplane but also by cruise ship. In order to meet a rising demand of customers coming to sightseeing Vietnam by cruise ship, we, Premium Travel Vietnam, therefore organise Shore Excursion Hoi An city. So, it is a private day trip from either Chan May port or Tien Sa port in Da Nang enables you adventure Hoi An old town in one day. Joining with us in this tour, you got a chance to explore Marble Mountains in Da Nang with many pretty caves and gorgeous Buddist temples. Moreover, we then take you to sightseeing Hoi An town – little VENICE of Vietnam, city of lanterns, cafes, shops, tailors ect in a day time. You will be surprised by the peace, relaxation of Hoi An ancient town that has been preserved very well since 16th century. By the way, you can sample some of Hoi An’s specialties that have been renowned worldwide by many travelers. Let’s come with PTV for this, we will make your trip a special one. Besides, our company also arranges package tours, private tours or day tours to Phong Nha National Park. A new tourist destination of central Vietnam in Quang Binh province. So, let’s come and explore amazing, fantastic caves and impressive nature as well as spectacular stalactities, stalagmites at Phong Nha Park with Phong Nha Pioneer Travel. For more information, details and assistance, kindly contact us at premiumvietnamtravel@gmail.com or whatsapp us at 0084979613777. We are very pleased to serve you and be a reliable partner to you.