dart-lang / markdown

A Dart markdown library

Home Page:https://pub.dev/packages/markdown

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Checkbox] seems to be wrong with list

asjqkkkk opened this issue · comments

commented

this is what it should be

  • asd
    • asdasd
    • dasds
  • asd
    • asdsad
  • a

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

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

commented

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

Unfortunately, I am not sure.
cc @srawlins

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.