diff --git a/MANIFEST b/MANIFEST
index 4ad3c57..a285336 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -59,6 +59,7 @@ t/36multimarkdown_featurebleed.t
t/37anchormultilinebugs.t
t/38listshorizontalrule.t
t/39listsindentededgecase.t
+t/40trustliststart.t
t/code-hr.t
t/docs-maruku-unittest/abbreviations.html
t/docs-maruku-unittest/abbreviations.text
diff --git a/lib/Text/Markdown.pm b/lib/Text/Markdown.pm
index 79a13e1..6901339 100644
--- a/lib/Text/Markdown.pm
+++ b/lib/Text/Markdown.pm
@@ -67,7 +67,7 @@ The options for the processor are:
=over
-=item empty element suffix
+=item empty_element_suffix
This option can be used to generate normal HTML output. By default, it is ' />', which is xHTML, change to '>' for normal HTML.
@@ -79,6 +79,21 @@ Controls indent width in the generated markup, defaults to 4
Controls if Markdown is processed when inside HTML blocks. Defaults to 0.
+=item trust_list_start_value
+
+If true, ordered lists will use the first number as the starting point for
+numbering. This will let you pick up where you left off by writing:
+
+ 1. foo
+ 2. bar
+
+ some paragraph
+
+ 3. baz
+ 6. quux
+
+(Note that in the above, quux will be numbered 4.)
+
=back
=head1 METHODS
@@ -133,6 +148,8 @@ sub new {
# Is markdown processed in HTML blocks? See t/15inlinehtmldonotturnoffmarkdown.t
$p{markdown_in_html_blocks} = $p{markdown_in_html_blocks} ? 1 : 0;
+
+ $p{trust_list_start_value} = $p{trust_list_start_value} ? 1 : 0;
my $self = { params => \%p };
bless $self, ref($class) || $class;
@@ -927,14 +944,16 @@ sub _DoLists {
$whole_list
}{
my $list = $1;
- my $list_type = ($3 =~ m/$marker_ul/) ? "ul" : "ol";
+ my $marker = $3;
+ my $list_type = ($marker =~ m/$marker_ul/) ? "ul" : "ol";
# Turn double returns into triple returns, so that we can make a
# paragraph for the last item in a list, if necessary:
$list =~ s/\n{2,}/\n\n\n/g;
my $result = ( $list_type eq 'ul' ) ?
$self->_ProcessListItemsUL($list, $marker_ul)
: $self->_ProcessListItemsOL($list, $marker_ol);
- $result = "<$list_type>\n" . $result . "</$list_type>\n";
+
+ $result = $self->_MakeList($list_type, $result, $marker);
$result;
}egmx;
}
@@ -944,14 +963,15 @@ sub _DoLists {
$whole_list
}{
my $list = $1;
- my $list_type = ($3 =~ m/$marker_ul/) ? "ul" : "ol";
+ my $marker = $3;
+ my $list_type = ($marker =~ m/$marker_ul/) ? "ul" : "ol";
# Turn double returns into triple returns, so that we can make a
# paragraph for the last item in a list, if necessary:
$list =~ s/\n{2,}/\n\n\n/g;
my $result = ( $list_type eq 'ul' ) ?
$self->_ProcessListItemsUL($list, $marker_ul)
: $self->_ProcessListItemsOL($list, $marker_ol);
- $result = "<$list_type>\n" . $result . "</$list_type>\n";
+ $result = $self->_MakeList($list_type, $result, $marker);
$result;
}egmx;
}
@@ -960,6 +980,17 @@ sub _DoLists {
return $text;
}
+sub _MakeList {
+ my ($self, $list_type, $content, $marker) = @_;
+
+ if ($list_type eq 'ol' and $self->{trust_list_start_value}) {
+ my ($num) = $marker =~ /^(\d+)[.]/;
+ return "<ol start='$num'>\n" . $content . "</ol>\n";
+ }
+
+ return "<$list_type>\n" . $content . "</$list_type>\n";
+}
+
sub _ProcessListItemsOL {
#
# Process the contents of a single ordered list, splitting it
diff --git a/t/40trustliststart.t b/t/40trustliststart.t
new file mode 100644
index 0000000..289e8d2
--- /dev/null
+++ b/t/40trustliststart.t
@@ -0,0 +1,33 @@
+use strict;
+use warnings;
+use Test::More tests => 2;
+
+use_ok( 'Text::Markdown' );
+
+my $m = Text::Markdown->new(trust_list_start_value => 1);
+my $html1 = $m->markdown(<<"EOF");
+1. this
+2. is a list
+
+Paragraph.
+
+3. and we
+4. pick up
+
+EOF
+
+my $want = <<'EOF';
+<ol start='1'>
+<li>this</li>
+<li>is a list</li>
+</ol>
+
+<p>Paragraph.</p>
+
+<ol start='3'>
+<li>and we</li>
+<li>pick up</li>
+</ol>
+EOF
+
+is($html1, $want, "we can use numbering from start marker");