[gtk-doc] Add support for header ids in markdown



commit ef1cdae9a1dd2c588fbd14d01d952ca396d001fe
Author: William Jon McCann <william jon mccann gmail com>
Date:   Tue Feb 4 15:14:01 2014 -0500

    Add support for header ids in markdown
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723417

 gtkdoc-mkdb.in              |   16 ++++++++++++----
 tests/gobject/src/gobject.c |    2 +-
 2 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/gtkdoc-mkdb.in b/gtkdoc-mkdb.in
index 2d9c858..170a164 100755
--- a/gtkdoc-mkdb.in
+++ b/gtkdoc-mkdb.in
@@ -4636,12 +4636,13 @@ sub MarkDownParseBlocks {
                         lines => [],
                         level => 1 };
           next OUTER;
-        } elsif ($line =~ /^[#][ \t]+(.+?)[ \t]*[#]*\s*$/) {
+        } elsif ($line =~ /^[#][ \t]+(.+?)[ \t]*[#]*[ \t]*(?:{#([^}]+)})?[ \t]*$/) {
           $md_block->{"interrupted"} = 0;
           push @md_blocks, $md_block;
 
           $md_block = { type => "heading",
                         text => $1,
+                        id => $2,
                         lines => [],
                         level => 1 };
           next OUTER;
@@ -4671,12 +4672,13 @@ sub MarkDownParseBlocks {
                         lines => [],
                         level => 2 };
           next OUTER;
-        } elsif ($line =~ /^([#]{1,2})[ \t]+(.+?)[ \t]*[#]*\s*$/) {
+        } elsif ($line =~ /^([#]{1,2})[ \t]+(.+?)[ \t]*[#]*[ \t]*(?:{#([^}]+)})?[ \t]*$/) {
           $md_block->{"interrupted"} = 0;
           push @md_blocks, $md_block;
 
           $md_block = { type => "heading",
                         text => $2,
+                        id => $3,
                         lines => [],
                         level => length($1) };
           next OUTER;
@@ -4741,12 +4743,13 @@ sub MarkDownParseBlocks {
 
     # indentation sensitive types
 
-    if ($line =~ /^([#]{1,2})[ \t]+(.+?)[ \t]*[#]*\s*$/) {
+    if ($line =~ /^([#]{1,2})[ \t]+(.+?)[ \t]*[#]*[ \t]*(?:{#([^}]+)})?[ \t]*$/) {
       # atx heading (#)
       push @md_blocks, $md_block;
 
       $md_block = { type => "heading",
                     text => $2,
+                    id => $3,
                     lines => [],
                     level => length($1) };
 
@@ -5156,8 +5159,13 @@ sub MarkDownOutputDocBook {
       }
 
       $text = &MarkDownParseLines ($block->{"lines"}, $symbol, "heading");
-      $output .= "<".$tag."><title>".$title."</title>".$text."</".$tag.">\n";
+      if (defined ($block->{"id"})) {
+        $output .= "<" . $tag . " id=\"" . $block->{"id"} . "\">";
+      } else {
+        $output .= "<" . $tag . ">";
+      }
 
+      $output .= "<title>" . $title . "</title>" . $text . "</" . $tag . ">\n";
     } elsif ($block->{"type"} eq "li") {
       my $tag = "itemizedlist";
 
diff --git a/tests/gobject/src/gobject.c b/tests/gobject/src/gobject.c
index 46d22cf..aa8a7df 100644
--- a/tests/gobject/src/gobject.c
+++ b/tests/gobject/src/gobject.c
@@ -77,7 +77,7 @@
  *
  * </refsect3>
  *
- * # Coda #
+ * # Coda # {#this-is-an-id-tag}
  *
  * 1. This is a ordered list
  *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]