diff --git a/Markdown.pl b/Markdown.pl index 8cf2418..17ffce5 100755 --- a/Markdown.pl +++ b/Markdown.pl @@ -730,14 +730,21 @@ sub _DoHeaders { # Header 2 # -------- # - $text =~ s{ ^(.+)[ \t]*\n=+[ \t]*\n+ }{ + # Header 3 + # ~~~~~~~~ + # + $text =~ s{ ^(?:=+[ \t]*\n)?(.+)[ \t]*\n=+[ \t]*\n+ }{ "

" . _RunSpanGamut($1) . "

\n\n"; }egmx; - $text =~ s{ ^(.+)[ \t]*\n-+[ \t]*\n+ }{ + $text =~ s{ ^(?:-+[ \t]*\n)?(.+)[ \t]*\n-+[ \t]*\n+ }{ "

" . _RunSpanGamut($1) . "

\n\n"; }egmx; + $text =~ s{ ^(?:~+[ \t]*\n)?(.+)[ \t]*\n~+[ \t]*\n+ }{ + "

" . _RunSpanGamut($1) . "

\n\n"; + }egmx; + # atx-style headers: # # Header 1 diff --git a/basics.text b/basics.text index 87c6ff5..4a0b152 100644 --- a/basics.text +++ b/basics.text @@ -41,8 +41,9 @@ considered blank.) Normal paragraphs should not be indented with spaces or tabs. Markdown offers two styles of headers: *Setext* and *atx*. -Setext-style headers for `

` and `

` are created by -"underlining" with equal signs (`=`) and hyphens (`-`), respectively. +Setext-style headers for `

`, `

` and `

` are created by +"underlining" with equal signs (`=`), hyphens (`-`) and tildes (`~`) +respectively. An optional matching "overline" may precede the header. To create an atx-style header, you put 1-6 hash marks (`#`) at the beginning of the line -- the number of hashes equals the resulting HTML header level. @@ -51,12 +52,16 @@ Blockquotes are indicated using email-style '`>`' angle brackets. Markdown: + ==================== A First Level Header ==================== A Second Level Header --------------------- + A Third Level Header + ~~~~~~~~~~~~~~~~~~~~ + Now is the time for all good men to come to the aid of their country. This is just a regular paragraph. @@ -64,7 +69,7 @@ Markdown: The quick brown fox jumped over the lazy dog's back. - ### Header 3 + ### Header 4 > This is a blockquote. > @@ -79,6 +84,8 @@ Output:

A Second Level Header

+

A Third Level Header

+

Now is the time for all good men to come to the aid of their country. This is just a regular paragraph.

@@ -86,7 +93,7 @@ Output:

The quick brown fox jumped over the lazy dog's back.

-

Header 3

+

Header 3

This is a blockquote.

diff --git a/syntax.text b/syntax.text index 0a5d63d..d23a051 100644 --- a/syntax.text +++ b/syntax.text @@ -212,7 +212,8 @@ work best -- and look better -- when you format them with hard breaks. Markdown supports two styles of headers, [Setext] [1] and [atx] [2]. Setext-style headers are "underlined" using equal signs (for first-level -headers) and dashes (for second-level headers). For example: +headers), dashes (for second-level headers) and tildes (for third-level +headers). For example: This is an H1 ============= @@ -220,7 +221,23 @@ headers) and dashes (for second-level headers). For example: This is an H2 ------------- -Any number of underlining `=`'s or `-`'s will work. + This is an H3 + ~~~~~~~~~~~~~ + +Any number of underlining `=`'s, `-`'s or `~`'s will work. An optional +matching "overline" may precede the header like so: + + ============= + This is an H1 + ============= + + ------------- + This is an H2 + ------------- + + ~~~~~~~~~~~~~ + This is an H3 + ~~~~~~~~~~~~~ Atx-style headers use 1-6 hash characters at the start of the line, corresponding to header levels 1-6. For example: