Skip to content
This repository was archived by the owner on Nov 1, 2017. It is now read-only.

Commit b43e109

Browse files
committed
Merge pull request #41 from github/skip-links-not-items-with-links
Updates should not ignore items with links
2 parents b3b4514 + 9bd8e69 commit b43e109

File tree

2 files changed

+65
-4
lines changed

2 files changed

+65
-4
lines changed

app/assets/javascripts/task_list.coffee

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,14 @@ itemPattern = ///
125125
#{escapePattern(complete)}|
126126
#{escapePattern(incomplete)}
127127
)
128-
(?! # is not a link
129-
\s* # with optional whitespace
130-
(?:\(.*?\)|\[.*?\]) # because of destination or reference
128+
\s+ # is followed by whitespace
129+
(?!
130+
\(.*?\) # is not part of a [foo](url) link
131+
)
132+
(?= # and is followed by zero or more links
133+
(?:\[.*?\]\s*(?:\[.*?\]|\(.*?\))\s*)*
134+
(?:[^\[]|$) # and either a non-link or the end of the string
131135
)
132-
(?=\s) # is followed by whitespace
133136
///
134137

135138
# Used to filter out code fences from the source for comparison only.

test/unit/test_updates.coffee

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,3 +506,61 @@ asyncTest "update ignores items that look like Task List items but are links", -
506506
, 20
507507

508508
item2Checkbox.click()
509+
510+
asyncTest "updates items followed by links", ->
511+
expect 3
512+
513+
$('#qunit-fixture').empty()
514+
515+
container = $ '<div>', class: 'js-task-list-container'
516+
517+
list = $ '<ul>', class: 'task-list'
518+
519+
item1 = $ '<li>', class: 'task-list-item'
520+
item1Checkbox = $ '<input>',
521+
type: 'checkbox'
522+
class: 'task-list-item-checkbox'
523+
disabled: true
524+
checked: false
525+
526+
item2 = $ '<li>', class: 'task-list-item'
527+
item2Checkbox = $ '<input>',
528+
type: 'checkbox'
529+
class: 'task-list-item-checkbox'
530+
disabled: true
531+
checked: false
532+
533+
field = $ '<textarea>', class: 'js-task-list-field', text: """
534+
- [ ] [link label](link)
535+
- [ ] [reference label][reference]
536+
"""
537+
538+
changes = """
539+
- [ ] [link label](link)
540+
- [x] [reference label][reference]
541+
"""
542+
543+
item1.append item1Checkbox
544+
list.append item1
545+
item1.expectedIndex = 1
546+
547+
item2.append item2Checkbox
548+
list.append item2
549+
item2.expectedIndex = 2
550+
551+
container.append list
552+
container.append field
553+
554+
$('#qunit-fixture').append(container)
555+
container.taskList()
556+
557+
field.on 'tasklist:changed', (event, index, checked) =>
558+
ok checked
559+
equal index, item2.expectedIndex
560+
equal field.val(), changes
561+
562+
setTimeout ->
563+
start()
564+
, 20
565+
566+
item2Checkbox.click()

0 commit comments

Comments
 (0)