:sequence :

:punctuation :
  :re : '(?<quote>''|"|\))\s*(?<punct>[.,!?]+)'
  :default :
    - '\k<punct>\k<quote>'
  :ru :
    - '\k<quote>\k<punct>'

:quotes :

# That's a 6.3" man, he sees sunsets at 10°20'30" E.
#             ⇑
:inch :
  :pattern : '"'
  :re : '(?:\p{Space}[\.,\p{Digit}]+)(")(?=\p{Space}|\Z)'
  :default :
    - '″'
# That's a 6.3" man, he sees sunsets at 10°20'30" E.
#                                               ⇑
:seconds :
  :pattern : '"'
  :re : '(?:\p{Space}[°''’′\p{Digit}]+)(")(?=\p{Space}|\p{Alpha}|\Z)'
  :default :
    - '″'

# That's a 6.3" man, he sees sunsets at 10°20'30" E.
#                                            ⇑
:minutes :
  :pattern : ''''
  :re : '(\p{Space}[°\p{Digit}]+)('')(?=\p{Space}|\p{Alnum}|\Z)'
  :default :
    - '′'

# That's a 6.3" man, he sees sunsets at 10°20'30" E.
#     ⇑
:apostrophe_pre :
  :pattern : ''''
  :re : '(?<=\p{Alpha})('')(?=\p{Alpha})'
  :default :
    - '♻'
# And God said 'Foos' game is over'.
#                  ⇑
:apostrophe_squeez :
  :pattern : ''''
  :re : '(?<=s)('')(?=\s)'
  :default :
    - '♻'
# And God said "∇×(∇×F) = ∇(∇·F) − ∇2F" and there was light.
#              ⇑
:left :
  :original : '''"'
  :re : '(?<=\p{Space}|\A)(?<m>"|'')(?=\p{Graph}|\Z)'
  :compliant : 'right'
  # Nested quotation marks are chosen if it’s an even occurence
  :default :
    - '“'
    - '‘'

# - '〈'

  :ru :
    - '«'
    - '„'
  :us :
    - '‘'
    - '“'
# And God said "∇×(∇×F) = ∇(∇·F) − ∇2F" and there was light.
#                                     ⇑
:right :
  :slave : true
  :original : '''"'
  :re : '(?<=\p{L}|\p{M}|\p{P})(?<m>"|'')(?=\p{Space}|\p{P}|\Z)'
  :compliant : 'left'
  # Nested quotation marks are chosen if it’s an odd occurence
  :default :
    - '”'
    - '’'

# - '〉'

  :ru :
    - '»'
    - '“'
  :us :
    - '’'
    - '”'
# That's a 6.3" man, he sees sunsets at 10°20'30" E.
#     ⇑
:apostrophe_post :
  :pattern : '♻'
  :re : '♻'
  :default :
    - '’'

:quotes_single :
  :re : '\s+''\s+(.+?)\s+''\s+'
  :default :
    - ' ‘\1’ '
  :ru :
    - ' «\1» '
:quotes_double :
  :re : '\s+"\s+(.+?)\s+"\s+'
  :default :
    - ' “\1” '
  :ru :
    - ' «\1» '

:alone_single :
  :re : '('')'
  :alert: true
  :default :
    - '’'

:alone_double :
  :re : '(")'
  :alert: true
  :default :
    - '”'

:punctuation :

:bloody_quote_en :
  :re : '(“)(?:\s+)'
  :default :
    - '\1'
  :ru :
    - '\1 '
:bloody_quote_ru :
  :re : '(?:\s+)(“)'
  :default :
    - ' \1'
  :ru :
    - '\1'
:opening_orphan :
  :re : '([(¿¡§#№‘„«]|\p{Sc})(?:\s+)'
  :default :
    - '\1'
:closing_orphan :
  :re : '(?:\s+)([.,:;!?)”’»])'
  :default :
    - '\1'
:closing_clamped :
  :re : '([.,:;!?)])(?=\p{Lu})'
  :default :
    - '\1 '
:fixup :
  :re : '([!?.]+)(?:\s*)(\.+)'
  :default :
    - '\1\2'
:ellipsis :
  :re : '\.{3,}'
  :default :
    - '…'
:mdash :
  :re : '\p{Space}*(?<dash>\s-\s|--|–|—)\s*'
  :default :
    - '—'
  :ru :
    - ' — '
  :us :
    - ' – '

# MUST be the last section, since it’ kinda cleanup :orphans :

:dangling_right :
  :re : '(?<=\s|\A)(\p{L})\s+'
  :default :
    - '\1 '
:dangling_left :
  :re : '\s+(p{Punct})(?=\s|\Z)'
  :default :
    - ' \1'
:extra_spaces :
  :re : ' +'
  :default :
    - ' '