[gtk-doc] Support backslash escapes for both MarkDown and our extensions



commit d020b4644c1d7a61782c52f8904f8071085a3ea0
Author: William Jon McCann <william jon mccann gmail com>
Date:   Thu Feb 6 09:12:59 2014 -0500

    Support backslash escapes for both MarkDown and our extensions

 gtkdoc-mkdb.in              |   15 ++++++++++++++-
 tests/gobject/src/gobject.c |    1 +
 2 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/gtkdoc-mkdb.in b/gtkdoc-mkdb.in
index 166bde8..2454d6c 100755
--- a/gtkdoc-mkdb.in
+++ b/gtkdoc-mkdb.in
@@ -344,6 +344,9 @@ my %AnnotationDefinition = (
 my @MD_TEXT_LEVEL_ELEMENTS = ( "literal", "emphasis", "envar", "filename", "firstterm",
                                "function", "manvolnum", "option", "replaceable", "structname",
                                "title", "varname" );
+my @MD_ESCAPABLE_CHARS = ("\\", "`", "*", "_", "{", "}", "[", "]", "(", ")", ">", "#",
+                          "+", "-", ".", "!" );
+my @MD_GTK_ESCAPABLE_CHARS = ("@", "%" );
 
 # Create the root DocBook output directory if it doens't exist.
 if (! -e $SGML_OUTPUT_DIR) {
@@ -5017,6 +5020,16 @@ sub MarkDownParseSpanElementsInner {
         $markup .= "&lt;";
         $offset = 1;
       }
+    } elsif ($closest_marker eq "\\") {
+      my $special_char = substr ($text, 1, 1);
+      if (&in_array (\ MD_ESCAPABLE_CHARS, $special_char) ||
+          &in_array (\ MD_GTK_ESCAPABLE_CHARS, $special_char)) {
+        $markup .= $special_char;
+        $offset = 2;
+      } else {
+        $markup .= "\\";
+        $offset = 1;
+      }
     } elsif ($closest_marker eq "`") {
       if ($text =~ /^(`+)([^`]+?)\1(?!`)/) {
         my $element_text = $2;
@@ -5085,7 +5098,7 @@ sub MarkDownParseSpanElementsInner {
 
 sub MarkDownParseSpanElements {
   my ($text) = @_;
-  my @markers = ( "<", "![", "[", "`", "%", "#", "@" );
+  my @markers = ( "\\", "<", "![", "[", "`", "%", "#", "@" );
 
   $text = &MarkDownParseSpanElementsInner ($text, \ markers);
 
diff --git a/tests/gobject/src/gobject.c b/tests/gobject/src/gobject.c
index a029801..2304791 100644
--- a/tests/gobject/src/gobject.c
+++ b/tests/gobject/src/gobject.c
@@ -19,6 +19,7 @@
  * 02:00:00.
  *
  * <literal>lang_COUNTRY MODIFIER</literal>
+ * <literal>lang_COUNTRY\ MODIFIER</literal>
  *
  * This file contains non-sense code for the sole purpose of testing the docs.
  * We can link to the #GtkdocObject:otest property and the #GtkdocObject::otest


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