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

[Checkbox] seems to be wrong with list #505

Closed asjqkkkk closed 1 year ago

asjqkkkk commented 1 year ago

this is what it should be

there is the source data

- [x] asd
    - asdasd
    - dasds
- [x] asd
    - asdsad
- [x] a

it's my test code

import 'package:flutter_test/flutter_test.dart';
import 'package:markdown/markdown.dart' as m;

void main() {
  void printElement(m.Node node) {
    if (node is m.Element) {
      print('--- Element:  ${node.tag}   attributes:${node.attributes} ---');
      node.children?.forEach((e) {
        printElement(e);
      });
    } else {
      print('--- text:  ${node.textContent} ---');
    }
  }

  test('test for checkbox', () {
    final testString = '''- [x] asd
    - asdasd
    - dasds
- [x] asd
    - asdsad
- [x] a''';
    final m.Document document = m.Document(
        extensionSet: m.ExtensionSet.gitHubFlavored, encodeHtml: false);
    final lines = testString.replaceAll('\r\n', '\n').split('\n');
    final nodes = document.parseLines(lines);
    nodes.forEach((e) {
      printElement(e);
    });
  });
}

there are the prints of the test code:

--- Element:  ul   attributes:{class: contains-task-list} ---
--- Element:  li   attributes:{} ---
--- text:  asd ---
--- Element:  ul   attributes:{} ---
--- Element:  li   attributes:{} ---
--- text:  asdasd ---
--- Element:  li   attributes:{} ---
--- text:  dasds ---
--- Element:  li   attributes:{} ---
--- text:  asd ---
--- Element:  ul   attributes:{} ---
--- Element:  li   attributes:{} ---
--- text:  asdsad ---
--- Element:  li   attributes:{class: task-list-item} ---
--- Element:  input   attributes:{type: checkbox, checked: true} ---
--- text:  a ---

only the last one is right

chenzhiguang commented 1 year ago

Thank you! We have fixed this issue in 7.0.0-dev (Not released yet)

asjqkkkk commented 1 year ago

@chenzhiguang Hello, when will 7.0.0-dev be released?

chenzhiguang commented 1 year ago

Unfortunately, I am not sure. cc @srawlins

srawlins commented 1 year ago

It will probably be a while. At least a month I'd guess. Need to review some more incoming PRs. Very exciting to have a big release like this.