-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Labels
bugSomething isn't workingSomething isn't working
Description
This test will fail.
func testMarkdownCheckbox_withChecked_withMultibyte() {
let markdown = """
- [x] テスト
- [x] テスト2
"""
let node = Node(markdown: markdown)!
XCTAssertEqual(node.elements.count, 1)
guard case .list(let items, _)? = node.elements.first else { fatalError() }
// get second checkbox after multibyte characters
guard case .paragraph(let paragraph)? = items[1].first else { fatalError() }
guard case .checkbox(let checked, let range) = paragraph[1] else { fatalError() }
XCTAssertEqual(markdown.substring(with: range), "[x]")
}
The location of the checkbox should be converted into multibyte count here.
I'm not sure the best way to get the whole content of the original markdown, but this might work.
var location = Int(cmark_node_get_checkbox_location(node))
if let string = String(bytes: original_markdown.utf8.prefix(location), encoding:.utf8) {
location = string.count
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working