git-touch / highlight.dart

Syntax highlighting for Dart and Flutter
https://git-touch.github.io/highlight/
MIT License
234 stars 85 forks source link

Double quotes (") are not escaped #39

Open deengel opened 2 years ago

deengel commented 2 years ago

As far as I understand, double quotes (") should be escaped with &quot; in the generated HTML. <, > and & are correctly escaped.

import 'package:highlight/highlight.dart' show highlight;

main() {
  var source = '''main() {
  print("Hello <> World!");
}
''';

  var result = highlight.parse(source, language: 'dart');
  var html = result.toHtml();
  print(html); // HTML string
}

Actual output is:

<span class="hljs-built_in">print</span>(<span class="hljs-string">"Hello &lt;&gt; World!"</span>);

Expected output is:

<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Hello &lt;&gt; World!&quot;</span>);