@@ -402,6 +402,69 @@ def testTextPatterns_DialogueStyle():
402402 # Single quotes are recognised, double quotes are not
403403 assert allMatches (regEx , "one \u2018 two\u2019 three \u201c four\u201d five" ) == [[("\u2018 two\u2019 " , 4 , 9 )]]
404404
405+ # Check detecting closing single quote, see #2633
406+ assert allMatches (
407+ regEx ,
408+ "\u2018 There\u2019 s an author\u2019 s evening at the book club,\u2019 "
409+ "she said, \u2018 I\u2019 m going there tomorrow.\u2019 " ,
410+ ) == [
411+ [("\u2018 There\u2019 s an author\u2019 s evening at the book club,\u2019 " , 0 , 47 )],
412+ [("\u2018 I\u2019 m going there tomorrow.\u2019 " , 58 , 85 )],
413+ ]
414+
415+ assert allMatches (
416+ regEx ,
417+ "\u2018 There\u2019 s an authors\u2019 evening at the book club,\u2019 "
418+ "she said, \u2018 I\u2019 m going there tomorrow.\u2019 " ,
419+ ) == [
420+ [("\u2018 There\u2019 s an authors\u2019 evening at the book club,\u2019 " , 0 , 47 )],
421+ [("\u2018 I\u2019 m going there tomorrow.\u2019 " , 58 , 85 )],
422+ ]
423+
424+ assert allMatches (
425+ regEx ,
426+ "\u2018 There\u2019 s an \u2019 80s authors\u2019 evening at the book club,\u2019 "
427+ "she said, \u2018 I\u2019 m going there tomorrow.\u2019 " ,
428+ ) == [
429+ [("\u2018 There\u2019 s an \u2019 80s authors\u2019 evening at the book club,\u2019 " , 0 , 52 )],
430+ [("\u2018 I\u2019 m going there tomorrow.\u2019 " , 63 , 90 )],
431+ ]
432+
433+ # Using single quotes for double should yield the same result
434+ CONFIG .fmtDQuoteOpen = nwUnicode .U_LSQUO
435+ CONFIG .fmtDQuoteClose = nwUnicode .U_RSQUO
436+
437+ CONFIG .dialogStyle = 2
438+ regEx = REGEX_PATTERNS .dialogStyle
439+ assert regEx is not None
440+
441+ assert allMatches (
442+ regEx ,
443+ "\u2018 There\u2019 s an author\u2019 s evening at the book club,\u2019 "
444+ "she said, \u2018 I\u2019 m going there tomorrow.\u2019 " ,
445+ ) == [
446+ [("\u2018 There\u2019 s an author\u2019 s evening at the book club,\u2019 " , 0 , 47 )],
447+ [("\u2018 I\u2019 m going there tomorrow.\u2019 " , 58 , 85 )],
448+ ]
449+
450+ assert allMatches (
451+ regEx ,
452+ "\u2018 There\u2019 s an authors\u2019 evening at the book club,\u2019 "
453+ "she said, \u2018 I\u2019 m going there tomorrow.\u2019 " ,
454+ ) == [
455+ [("\u2018 There\u2019 s an authors\u2019 evening at the book club,\u2019 " , 0 , 47 )],
456+ [("\u2018 I\u2019 m going there tomorrow.\u2019 " , 58 , 85 )],
457+ ]
458+
459+ assert allMatches (
460+ regEx ,
461+ "\u2018 There\u2019 s an \u2019 80s authors\u2019 evening at the book club,\u2019 "
462+ "she said, \u2018 I\u2019 m going there tomorrow.\u2019 " ,
463+ ) == [
464+ [("\u2018 There\u2019 s an \u2019 80s authors\u2019 evening at the book club,\u2019 " , 0 , 52 )],
465+ [("\u2018 I\u2019 m going there tomorrow.\u2019 " , 63 , 90 )],
466+ ]
467+
405468
406469@pytest .mark .core
407470def testTextPatterns_DialoguePlain ():
0 commit comments