Browse Source

with_html5_tags() doc and test fixup

Masayoshi Sekimura 6 years ago
parent
commit
8f5f46c3b0
2 changed files with 17 additions and 6 deletions
  1. 11
    4
      lib/Text/Markdown/Discount.pm
  2. 6
    2
      t/13.html5.t

+ 11
- 4
lib/Text/Markdown/Discount.pm View File

@@ -94,10 +94,17 @@ I<markdown> is exported by default.
94 94
 
95 95
 =item C<Text::Markdown::Discount::with_html5_tags()>
96 96
 
97
-Enabling html5 elements handling.
97
+This function enables html5 block-level elements support.
98
+C<< Text::Markdown::Discount::markdown() >> will handle these html5 tags as
99
+block elements: aside, footer, header, hgroup, nav, section, article.
98 100
 
99
-Once calling it, following B<ALL> C<< Text::Markdown::Discount::markdown() >>
100
-calls are affected with html5 enabled in same Perl process and there is no way to disable it.
101
+B<NOTE>: There is no way to disable/re-enable this feature in one process right now.
102
+
103
+  use Text::Markdown::Discount;
104
+  Text::Markdown::Discount::with_html5_tags();
105
+  my $html = markdown('<article>content</article>');
106
+  #
107
+  # In $html, <article> tag won't be wrapped with <p> tag
101 108
 
102 109
 =back
103 110
 
@@ -159,7 +166,7 @@ Masayoshi Sekimura, E<lt>sekimura@cpan.orgE<gt>
159 166
 
160 167
 =head1 COPYRIGHT AND LICENSE
161 168
 
162
-Copyright (C) 2009 by Masayoshi Sekimura
169
+Copyright (C) 2013 by Masayoshi Sekimura
163 170
 
164 171
 This library is free software; you can redistribute it and/or modify
165 172
 it under the same terms as Perl itself, either Perl version 5.10.0 or,

+ 6
- 2
t/13.html5.t View File

@@ -1,7 +1,7 @@
1 1
 use strict;
2 2
 use warnings;
3 3
 use utf8;
4
-use Test::More tests => 2;
4
+use Test::More tests => 3;
5 5
 use Text::Markdown::Discount qw/markdown/;
6 6
 
7 7
 my $html = '<article>abc</article>';
@@ -12,10 +12,14 @@ my $html = '<article>abc</article>';
12 12
 Text::Markdown::Discount::with_html5_tags();
13 13
 
14 14
 {
15
-    my $md = Text::Markdown::Discount->new(html5 => 1);
15
+    my $md = Text::Markdown::Discount->new();
16 16
     is trim(markdown($html)), '<article>abc</article>';
17 17
 }
18 18
 
19
+{
20
+    is trim(Text::Markdown::Discount::markdown($html)), '<article>abc</article>';
21
+}
22
+
19 23
 sub trim {
20 24
     my $text = shift;
21 25
     $text =~ s/\A\s+//ms;

Loading…
Cancel
Save