Skip to content
This repository was archived by the owner on Nov 1, 2017. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions app/assets/javascripts/task_list.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,14 @@ itemPattern = ///
#{escapePattern(complete)}|
#{escapePattern(incomplete)}
)
(?! # is not a link
\s* # with optional whitespace
(?:\(.*?\)|\[.*?\]) # because of destination or reference
\s+ # is followed by whitespace
(?!
\(.*?\) # is not part of a [foo](url) link
)
(?= # and is followed by zero or more links
(?:\[.*?\]\s*(?:\[.*?\]|\(.*?\))\s*)*
(?:[^\[]|$) # and either a non-link or the end of the string
)
(?=\s) # is followed by whitespace
///

# Used to filter out code fences from the source for comparison only.
Expand Down
58 changes: 58 additions & 0 deletions test/unit/test_updates.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,61 @@ asyncTest "update ignores items that look like Task List items but are links", -
, 20

item2Checkbox.click()

asyncTest "updates items followed by links", ->
expect 3

$('#qunit-fixture').empty()

container = $ '<div>', class: 'js-task-list-container'

list = $ '<ul>', class: 'task-list'

item1 = $ '<li>', class: 'task-list-item'
item1Checkbox = $ '<input>',
type: 'checkbox'
class: 'task-list-item-checkbox'
disabled: true
checked: false

item2 = $ '<li>', class: 'task-list-item'
item2Checkbox = $ '<input>',
type: 'checkbox'
class: 'task-list-item-checkbox'
disabled: true
checked: false

field = $ '<textarea>', class: 'js-task-list-field', text: """
- [ ] [link label](link)
- [ ] [reference label][reference]
"""

changes = """
- [ ] [link label](link)
- [x] [reference label][reference]
"""

item1.append item1Checkbox
list.append item1
item1.expectedIndex = 1

item2.append item2Checkbox
list.append item2
item2.expectedIndex = 2

container.append list
container.append field

$('#qunit-fixture').append(container)
container.taskList()

field.on 'tasklist:changed', (event, index, checked) =>
ok checked
equal index, item2.expectedIndex
equal field.val(), changes

setTimeout ->
start()
, 20

item2Checkbox.click()