dart-lang / markdown

A Dart markdown library
https://pub.dev/packages/markdown
BSD 3-Clause "New" or "Revised" License
443 stars 201 forks source link

Single quote turning into ' in fenced code block #497

Closed derekxu16 closed 1 year ago

derekxu16 commented 1 year ago

I believe that only &, <, and > should turn into HTML entities when they're within fenced code blocks; ' should not.

The following is a way to reproduce this problem:

import 'dart:developer';
import 'package:markdown/markdown.dart' show Document;

void main(List<String> args) async {
  final document = Document();
  final nodes = document.parseLines(['```', "'abc'", '```']);
  debugger();
  print(nodes);
}

Inspecting the nodes array in this example reveals the problem.

Screen Shot 2022-11-29 at 11 16 57 AM
srawlins commented 1 year ago

CC @chenzhiguang I believe this is intentional, according to CommonMark spec. I'm not certain though.

chenzhiguang commented 1 year ago

I can't find any information on this in the spec, but I could see the CommonMark live demo does not encode ': https://spec.commonmark.org/dingus/?text=```%0A%27abc%27%0A```

I will fix it later soon.