diff options
author | Stefan Sauer <ensonic@users.sf.net> | 2015-05-12 15:52:12 +0200 |
---|---|---|
committer | Stefan Sauer <ensonic@users.sf.net> | 2015-05-12 15:55:04 +0200 |
commit | 0ea674a534ba1fd6be2285c25c8a30351efa4b80 (patch) | |
tree | 6492aec4de015e039eb94005747083ffb8ff45da /gtkdoc-mkdb.in | |
parent | 110fc072016b274ac6ef38709bf9a7b2d884bf3e (diff) | |
download | gtk-doc-0ea674a534ba1fd6be2285c25c8a30351efa4b80.tar.gz |
mkdb: improve mixed markup/down handling
The state machinery for multiline text-level blocks was wrong and caused extra para blocks.
Fixes #749142
Diffstat (limited to 'gtkdoc-mkdb.in')
-rwxr-xr-x | gtkdoc-mkdb.in | 92 |
1 files changed, 57 insertions, 35 deletions
diff --git a/gtkdoc-mkdb.in b/gtkdoc-mkdb.in index bf7ef7c..dc1ba67 100755 --- a/gtkdoc-mkdb.in +++ b/gtkdoc-mkdb.in @@ -4811,6 +4811,7 @@ sub MarkDownParseBlocks { } } $md_block->{"text"} .= "\n" . $line; + @TRACE@("add to markup"); next OUTER; } } @@ -5005,41 +5006,60 @@ sub MarkDownParseBlocks { # markup, including <?xml version="1.0"?> my $tag = $1; my $is_self_closing = defined($2); - # FIXME: why do we need to skip https? here, if we generalize this to all - # uri schemes we get parsing errors - if (! $MD_TEXT_LEVEL_ELEMENTS{$tag} && $tag !~ /^https?/ && !defined($md_block->{"start"})) { - push @md_blocks, $md_block; - - if ($is_self_closing) { - @TRACE@("self-closing docbook '$tag'"); - $md_block = { type => "self-closing tag", - text => $deindented_line }; - $is_self_closing = 0; - next OUTER; - } - - @TRACE@("new markup '$tag'"); - $md_block = { type => "markup", - text => $deindented_line, - start => "<" . $tag . ">", - end => "</" . $tag . ">", - closed => 0, - depth => 0 }; - if ($deindented_line =~ /<\/$tag>/) { - $md_block->{"closed"} = 1; - } - next OUTER; + + # skip link markdown + # TODO(ensonic): consider adding more uri schemes (ftp, ...) + if ($tag =~ /^https?/) { + @TRACE@("skipping link '$tag'"); } else { - @TRACE@("text level docbook '$tag'"); - if (!defined($md_block->{"start"}) && $MD_TEXT_LEVEL_ELEMENTS{$tag}) { - $md_block->{"start"} = "<" . $tag . ">"; - $md_block->{"end"} = "</" . $tag . ">"; - $md_block->{"closed"} = 0; - @TRACE@("scanning for end of '$tag'"); - } - if (defined($md_block->{"start"}) && $deindented_line =~ /$md_block->{"end"}/) { - $md_block->{"closed"} = 1; - @TRACE@("found end of '$tag'"); + # for TEXT_LEVEL_ELEMENTS, we want to keep them as-is in the paragraph + # instead of creation a markdown block. + my $scanning_for_end_of_text_level_tag = ( + $md_block->{"type"} eq "paragraph" && + defined($md_block->{"start"}) && + !$md_block->{"closed"}); + @TRACE@("markup found '$tag', scanning $scanning_for_end_of_text_level_tag ?"); + if (!$MD_TEXT_LEVEL_ELEMENTS{$tag} && !$scanning_for_end_of_text_level_tag) { + push @md_blocks, $md_block; + + if ($is_self_closing) { + @TRACE@("self-closing docbook '$tag'"); + $md_block = { type => "self-closing tag", + text => $deindented_line }; + $is_self_closing = 0; + next OUTER; + } + + @TRACE@("new markup '$tag'"); + $md_block = { type => "markup", + text => $deindented_line, + start => "<" . $tag . ">", + end => "</" . $tag . ">", + closed => 0, + depth => 0 }; + if ($deindented_line =~ /<\/$tag>/) { + $md_block->{"closed"} = 1; + } + next OUTER; + } else { + if ($MD_TEXT_LEVEL_ELEMENTS{$tag}) { + @TRACE@("text level docbook '$tag' in '".$md_block->{"type"}."' state"); + # TODO(ensonic): handle nesting + if (!$scanning_for_end_of_text_level_tag) { + if ($deindented_line !~ /<\/$tag>/) { + @TRACE@("new text level markup '$tag'"); + $md_block->{"start"} = "<" . $tag . ">"; + $md_block->{"end"} = "</" . $tag . ">"; + $md_block->{"closed"} = 0; + @TRACE@("scanning for end of '$tag'"); + } + } else { + if ($deindented_line =~ /$md_block->{"end"}/) { + $md_block->{"closed"} = 1; + @TRACE@("found end of '$tag'"); + } + } + } } } } elsif ($line =~ /^([ ]*)[*+-][ ](.*)/) { @@ -5064,7 +5084,6 @@ sub MarkDownParseBlocks { } # list item - if ($line =~ /^([ ]{0,4})\d+[.][ ]+(.*)/) { push @md_blocks, $md_block; my $lines = $2; @@ -5089,13 +5108,16 @@ sub MarkDownParseBlocks { $md_block = { type => "paragraph", interrupted => 0, text => $line }; + @TRACE@("new paragraph due to interrupted"); } else { $md_block->{"text"} .= "\n" . $line; + @TRACE@("add to paragraph"); } } else { push @md_blocks, $md_block; $md_block = { type => "paragraph", text => $line }; + @TRACE@("new paragraph due to different block type"); } } |