Skip to content
This repository was archived by the owner on Oct 30, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ perl_version '5.008';
requires 'Digest::MD5' => undef;
requires 'Text::Balanced' => undef;
requires 'Encode' => undef;
requires 'Scalar::Util' => undef;
test_requires 'Test::More' => '0.42';
test_requires 'Test::Exception' => undef;
test_requires 'List::MoreUtils' => undef;
Expand Down
3 changes: 2 additions & 1 deletion lib/Text/Markdown.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use re 'eval';
use Digest::MD5 qw(md5_hex);
use Encode qw();
use Carp qw(croak);
use Scalar::Util qw(blessed);
use base 'Exporter';

our $VERSION = '1.000031'; # 1.0.31
Expand Down Expand Up @@ -186,7 +187,7 @@ sub markdown {
my ( $self, $text, $options ) = @_;

# Detect functional mode, and create an instance for this run
unless (ref $self) {
unless (blessed($self) && $self->isa('Text::Markdown')) {
if ( $self ne __PACKAGE__ ) {
my $ob = __PACKAGE__->new();
# $self is text, $text is options
Expand Down
26 changes: 26 additions & 0 deletions t/50blessed-string.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use strict;
use warnings;
use utf8;
use Test::More;
use Text::Markdown qw(markdown);

plan tests => 1;

{
# emulate class like Text::Xslate::Type::Raw
package #
StringClass;

use overload (
q{""} => sub { ${ $_[0] } },
fallback => 1,
);
sub new {
my ($class, $str) = @_;
bless \$str, $class;
}
}

my $src = StringClass->new('foo');
is(markdown($src), "<p>foo</p>\n");