Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:bobtfish/text-multimarkdown
Browse files Browse the repository at this point in the history
* 'master' of git@github.com:bobtfish/text-multimarkdown:
  Added TODO item for removing _FixFootnoteParagraphs
  Fix for issue #7 - updated the calls to Text::Markdown to match the new API
  • Loading branch information
bobtfish committed Oct 5, 2009
2 parents 599dff8 + ca94237 commit 8f92b0d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 69 deletions.
6 changes: 4 additions & 2 deletions Todo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Todo pre 1.0.23:
. Tests for $footnote =~ s/^glossary:\s*//i
. Tests for $footnote_closing_tag
. Tests for $footnote_closing_tag
. Add an option to Text::Markdown to have original brand markdown style
emphasis within words support.
. Re-merge Movable Type and Bloxom compatibility to the scripts, and add
Expand Down Expand Up @@ -36,7 +36,9 @@ Todo pre 1.0.26:
. Make a Text::Markdown::Extra with the Markdown extra features?

Todo pre 1.1:
. Build a parse tree when parsing (which can be returned), rather than just
. Either remove Text::MultiMarkdown::_FixFootnoteParagraphs or add tests to
exercise it. Currently, removing it doesn't affect any test.
. Build a parse tree when parsing (which can be returned), rather than just
using strings. This would make the output format much more flexible, and
would remove a load of nasty hacks which escape, then un-escape things
again whist processing..
26 changes: 8 additions & 18 deletions lib/Text/MultiMarkdown.pm
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ The title of the generated bibliography, defaults to 'Bibliography'.
Controls indent width in the generated markup, defaults to 4
=item markdown_in_html_blocks
Controls if Markdown is processed when inside HTML blocks. Defaults to 0.
=item disable_tables
If true, this disables the MultiMarkdown table handling.
Expand Down Expand Up @@ -219,9 +215,6 @@ sub new {
# NOTE: You can use \WikiWord to prevent a WikiWord from being treated as a link
$p{use_wikilinks} = $p{use_wikilinks} ? 1 : 0;

# Is markdown processed in HTML blocks? See t/15inlinehtmldonotturnoffmarkdown.t
$p{markdown_in_html_blocks} = $p{markdown_in_html_blocks} ? 1 : 0;

$p{heading_ids} = defined $p{heading_ids} ? $p{heading_ids} : 1;
$p{img_ids} = defined $p{img_ids} ? $p{img_ids} : 1;

Expand Down Expand Up @@ -297,14 +290,14 @@ sub _Markdown {
$text = $self->_ParseMetaData($text) if ($self->{use_metadata} || $self->{strip_metadata});

# Turn block-level HTML blocks into hash entries
$text = $self->_HashHTMLBlocks($text) unless $self->{markdown_in_html_blocks};
$text = $self->_HashHTMLBlocks($text, {interpret_markdown_on_attribute => 1});

$text = $self->_StripLinkDefinitions($text);

# MMD only
$text = $self->_StripMarkdownReferences($text);

$text = $self->_RunBlockGamut($text);
$text = $self->_RunBlockGamut($text, {wrap_in_p_tags => 1});

# MMD Only
$text = $self->_DoMarkdownCitations($text) unless $self->{disable_bibliography};
Expand All @@ -315,7 +308,7 @@ sub _Markdown {
# MMD Only
# This must follow _UnescapeSpecialChars
$text = $self->_UnescapeWikiWords($text);
$text = $self->_FixFootnoteParagraphs($text) unless $self->{disable_footnotes};
$text = $self->_FixFootnoteParagraphs($text) unless $self->{disable_footnotes}; # TODO: remove. Doesn't make any difference to test suite pass/failure
$text .= $self->_PrintFootnotes() unless $self->{disable_footnotes};
$text .= $self->_PrintMarkdownBibliography() unless $self->{disable_bibliography};

Expand Down Expand Up @@ -658,7 +651,7 @@ sub _DoFootnotes {

# First, run routines that get skipped in footnotes
foreach my $label (sort keys %{ $self->{_footnotes} }) {
my $footnote = $self->_RunBlockGamut($self->{_footnotes}{$label});
my $footnote = $self->_RunBlockGamut($self->{_footnotes}{$label}, {wrap_in_p_tags => 1});
$footnote = $self->_UnescapeSpecialChars($footnote);
$footnote = $self->_DoMarkdownCitations($footnote);
$self->{_footnotes}{$label} = $footnote;
Expand Down Expand Up @@ -688,10 +681,11 @@ sub _DoFootnotes {
return $text;
}

# TODO: remove. Doesn't make any difference to test suite pass/failure
sub _FixFootnoteParagraphs {
my ($self, $text) = @_;

$text =~ s/^\<p\>\<\/footnote\>/<\/footnote>/gm;
$text =~ s(^<p></footnote>)(</footnote>)gm;

return $text;
}
Expand All @@ -705,7 +699,7 @@ sub _PrintFootnotes {
$footnote_counter++;
my $footnote = $self->{_footnotes}{$id};

$footnote =~ s/(\<\/(p(re)?|ol|ul)\>)$//;
$footnote =~ s/(<\/(p(re)?|ol|ul)>)$//;
my $footnote_closing_tag = $1;
$footnote_closing_tag = '' if !defined $footnote_closing_tag;

Expand Down Expand Up @@ -1131,11 +1125,7 @@ sub _StripMarkdownReferences {

$reference =~ s/^[ ]{0,$self->{tab_width}}//gm;

$reference = $self->_RunBlockGamut($reference);

# strip leading and trailing <p> tags (they will be added later)
$reference =~ s/^\<p\>//s;
$reference =~ s/\<\/p\>\s*$//s;
$reference = $self->_RunBlockGamut($reference, {wrap_in_p_tags => 0});

$self->{_references}{$id} = $reference;
}
Expand Down
49 changes: 0 additions & 49 deletions t/15inlinehtmldoenoturnoffmarkdown.t

This file was deleted.

0 comments on commit 8f92b0d

Please sign in to comment.