On Sat, 30 Dec 2006, Jeremy C. Reed wrote:

> If not, I will code this for my own use. I will attempt to add an option 
> to Markdown so it doesn't take it literal.
> 
> Or maybe use two "" (two double-quotes) to begin and end the <pre><code> 
> block. Or start line with "" (two doubel-quotes).

This is what I am using now:

--- Markdown.pm.orig    2007-01-03 04:15:01.000000000 +0900
+++ /usr/pkg/lib/perl5/vendor_perl/5.8.0/Markdown.pm    2007-01-03 
05:26:53.000000000 +0900
@@ -438,6 +438,8 @@
 
        $text = _DoCodeBlocks($text);
 
+       $text = _DoCustomCodeBlocks($text);
+
        $text = _DoBlockQuotes($text);
 
        # We already ran _HashHTMLBlocks() before, in Markdown(), but that
@@ -947,6 +949,43 @@
 }
 
 
+sub _DoCustomCodeBlocks {
+#
+#      Process Markdown `<pre><code>` blocks.
+#      NOTE: the difference between this and _DoCodeBlocks
+#              is that Markdown formatting is still parsed and is not literal.
+
+       my $text = shift;
+
+       $text =~ s{
+                 (                                                             
# Wrap whole match in $1
+                       (
+                         ^\"\"[ \t]?                   # '>' at the start of a 
line
+                           .+\n                                        # rest 
of the first line
+                         (.+\n)*                                       # 
subsequent consecutive lines
+                         \n*                                           # blanks
+                       )+
+                 )
+               }{
+                       my $ccb = $1;
+                       $ccb =~ s/^\"\"[ \t]?//gm;      # trim one level of 
quoting
+#                      $ccb =~ s/^[ \t]+$//mg;                 # trim 
whitespace-only lines
+                       $ccb = _Detab($ccb);
+                       $ccb =~ s/\A\n+//; # trim leading newlines
+                       $ccb =~ s/\s+\z//; # trim trailing whitespace
+
+                       $ccb = _RunSpanGamut($ccb);             # recurse
+
+#                      $ccb =~ s/^/  /g;
+
+                       "\n\n<pre><code>$ccb\n</code></pre>\n\n";
+               }egmx;
+
+
+       return $text;
+}
+
+
 sub _DoCodeSpans {
 #
 #      *       Backtick quotes are used for <code></code> spans.

_______________________________________________
Markdown-Discuss mailing list
[email protected]
http://six.pairlist.net/mailman/listinfo/markdown-discuss

Reply via email to