Make EscapeSyntax respect encodeHtml (#386)

diff --git a/lib/src/inline_parser.dart b/lib/src/inline_parser.dart
index d4c359b..8475a89 100644
--- a/lib/src/inline_parser.dart
+++ b/lib/src/inline_parser.dart
@@ -447,12 +447,16 @@
     // their equivalent HTML entity referenced appears to be missing from the
     // CommonMark spec, but is very present in all of the examples.
     // https://talk.commonmark.org/t/entity-ification-of-quotes-and-brackets-missing-from-spec/3207
-    if (char == $double_quote) {
-      parser.addNode(Text('"'));
-    } else if (char == $lt) {
-      parser.addNode(Text('<'));
-    } else if (char == $gt) {
-      parser.addNode(Text('>'));
+    if (parser._encodeHtml) {
+      if (char == $double_quote) {
+        parser.addNode(Text('"'));
+      } else if (char == $lt) {
+        parser.addNode(Text('<'));
+      } else if (char == $gt) {
+        parser.addNode(Text('>'));
+      } else {
+        parser.addNode(Text(chars[1]));
+      }
     } else {
       parser.addNode(Text(chars[1]));
     }
diff --git a/test/document_test.dart b/test/document_test.dart
index 8c11b7d..4a4cd20 100644
--- a/test/document_test.dart
+++ b/test/document_test.dart
@@ -54,6 +54,21 @@
         var result = HtmlRenderer().render(nodes);
         expect(result, '<p>\n</p><pre>\n A\n B\n</pre>');
       });
+
+      test('encode double quotes, greater than, and less than when escaped',
+          () {
+        var contents = r'\>\"\< Hello';
+        var document = Document(encodeHtml: true);
+        var nodes = document.parseInline(contents);
+        expect(nodes, hasLength(1));
+        expect(
+            nodes.single,
+            const TypeMatcher<Text>().having(
+              (e) => e.text,
+              'text',
+              '&gt;&quot;&lt; Hello',
+            ));
+      });
     });
 
     group('with encodeHtml disabled', () {
@@ -82,6 +97,20 @@
         expect(
             codeBlock.textContent, equals('<p>Hello <em>Markdown</em></p>\n'));
       });
+
+      test('leave double quotes, greater than, and less than when escaped', () {
+        var contents = r'\>\"\< Hello';
+        var document = Document(encodeHtml: false);
+        var nodes = document.parseInline(contents);
+        expect(nodes, hasLength(1));
+        expect(
+            nodes.single,
+            const TypeMatcher<Text>().having(
+              (e) => e.text,
+              'text',
+              '>"< Hello',
+            ));
+      });
     });
   });
 }