Merge pull request dart-lang/markdown#64 from srawlins/hard-line-breaks

Fixing dart-lang/markdown#30 and dart-lang/markdown#60 by adding hard line break
diff --git a/pkgs/markdown/CHANGELOG.md b/pkgs/markdown/CHANGELOG.md
index c996795..1217d79 100644
--- a/pkgs/markdown/CHANGELOG.md
+++ b/pkgs/markdown/CHANGELOG.md
@@ -12,6 +12,7 @@
   SetextHeaderWithIdSyntax extensions.
 * Implement backslash-escaping so that Markdown syntax can be escaped, such as
   `[foo]\(bar) ==> <p>[foo](bar)</p>`.
+* Support for hard line breaks with either `\\\n` or `  \n` (#30, #60).
 * New public method for BlockParser: `peek(int linesAhead)`, meant for use in
   subclasses.
 * New public members for ListSyntax: `blocksInList` and `determineBlockItems()`,
diff --git a/pkgs/markdown/lib/src/inline_parser.dart b/pkgs/markdown/lib/src/inline_parser.dart
index 94847c0..2e8f42f 100644
--- a/pkgs/markdown/lib/src/inline_parser.dart
+++ b/pkgs/markdown/lib/src/inline_parser.dart
@@ -23,7 +23,7 @@
 
     // TODO(amouravski): this regex will glom up any custom syntaxes unless
     // they're at the beginning.
-    new TextSyntax(r'\s*[A-Za-z0-9]+'),
+    new TextSyntax(r'[ \tA-Za-z0-9]*[A-Za-z0-9]'),
 
     // The real syntaxes.
     new AutolinkSyntax(),
@@ -42,6 +42,10 @@
     new TextSyntax(r'&', sub: '&amp;'),
     // Encode "<". (Why not encode ">" too? Gruber is toying with us.)
     new TextSyntax(r'<', sub: '&lt;'),
+    // Escaped newlines become hard line breaks.
+    new TextSyntax(r'\\\n', sub: '<br />\n'),
+    // Two or more spaces at the end of a line become hard line breaks.
+    new TextSyntax(r'  +\n', sub: '<br />\n'),
     // Parse "**strong**" tags.
     new TagSyntax(r'\*\*', tag: 'strong'),
     // Parse "__strong__" tags.
diff --git a/pkgs/markdown/test/original/hard_line_breaks.unit b/pkgs/markdown/test/original/hard_line_breaks.unit
new file mode 100644
index 0000000..232079c
--- /dev/null
+++ b/pkgs/markdown/test/original/hard_line_breaks.unit
@@ -0,0 +1,42 @@
+>>> hard line break in a paragraph, using backslash
+First line.\
+Second line.
+
+<<<
+<p>First line.<br />
+Second line.</p>
+>>> within emphasis, using backslash
+*Emphasised\
+text.*
+
+<<<
+<p><em>Emphasised<br />
+text.</em></p>
+>>> no escape within code, using backslash
+`Some\
+code`.
+
+<<<
+<p><code>Some\
+code</code>.</p>
+>>> hard line break in a paragraph, using trailing spaces
+First line.  
+Second line.
+
+<<<
+<p>First line.<br />
+Second line.</p>
+>>> within emphasis, using trailing spaces
+*Emphasised  
+text.*
+
+<<<
+<p><em>Emphasised<br />
+text.</em></p>
+>>> no escape within code, using trailing spaces
+`Some  
+code`.
+
+<<<
+<p><code>Some  
+code</code>.</p>