File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -361,11 +361,13 @@ def findBadUnicodeAux (s : String) (pos : s.Pos) (c : Char)
361361 if ! isAllowedCharacter c then
362362 -- bad: character not allowed.
363363 findBadUnicodeAux s posₙ cₙ (err.push (.unwantedUnicode c))
364- else if cₙ == UnicodeVariant.emoji && !(emojis.contains c) then
364+ else if cₙ == UnicodeVariant.emoji && !(emojis.contains c) && !(unrestricted.contains c) then
365365 -- bad: unwanted emoji variant selector.
366366 let errₙ := err.push (.unicodeVariant (String.ofList [c, cₙ]) none)
367367 findBadUnicodeAux s posₙ cₙ errₙ
368- else if cₙ == UnicodeVariant.text && !(nonEmojis.contains c) then
368+ else if
369+ cₙ == UnicodeVariant.text && !(nonEmojis.contains c) && !(unrestricted.contains c)
370+ then
369371 -- bad: unwanted text variant selector.
370372 let errₙ := err.push (.unicodeVariant (String.ofList [c, cₙ]) none)
371373 findBadUnicodeAux s posₙ cₙ errₙ
Original file line number Diff line number Diff line change @@ -186,10 +186,19 @@ public def emojis : Array Char := #[
186186/-- Unicode symbols in mathlib that should always be followed by the text variant selector. -/
187187public def nonEmojis : Array Char := #[]
188188
189+ /-- Unicode symbols in mathlib that have no restrictions on whether they are followed by a selector
190+ or which selector they are followed by. -/
191+ public def unrestricted : Array Char := #[
192+ '⚠' -- ⚠️, ⚠. Lake output uses '⚠' and does not include the text selector.
193+ ]
194+
189195/-- If `false`, the character is not allowed in Mathlib.
190196
191197Implemented using an allowlist consisting of:
192198- certain ASCII characters
199+ - certain emojis (`emojis`)
200+ - certain non-emoji variants of emojifiable characters (`nonEmojis`)
201+ - certain characters with no selector restrictions (`unrestricted`)
193202- characters with abbreviations in the VSCode extension (`withVSCodeAbbrev`)
194203- "the rest" (`othersInMathlib`)
195204
@@ -202,6 +211,7 @@ public def isAllowedCharacter (c : Char) : Bool :=
202211 || othersInMathlib.contains c
203212 || emojis.contains c
204213 || nonEmojis.contains c
214+ || unrestricted.contains c
205215 || c == UnicodeVariant.emoji
206216 || c == UnicodeVariant.text
207217
Original file line number Diff line number Diff line change @@ -665,14 +665,21 @@ open Mathlib.Linter.TextBased.UnicodeLinter
665665/- A character either does or doesn't have an abbreviation in the VSCode extension. -/
666666#guard withVSCodeAbbrev.toList ∩ othersInMathlib.toList = ∅
667667
668- /- A character either is or isn't an emoji. -/
668+ /- No character is both an emoji and not an emoji. -/
669669#guard emojis.toList ∩ nonEmojis.toList = ∅
670670
671+ /- No character is both an emoji and unrestricted. -/
672+ #guard emojis.toList ∩ unrestricted.toList = ∅
673+
674+ /- No character is both a non-emoji and unrestricted. -/
675+ #guard nonEmojis.toList ∩ unrestricted.toList = ∅
676+
671677def allLinterDefinedCharacterLists : List (List Char) := [
672678 withVSCodeAbbrev,
673679 othersInMathlib,
674680 emojis,
675- nonEmojis
681+ nonEmojis,
682+ unrestricted
676683].map Array.toList
677684
678685/- Ensure none of the lists contain duplicates -/
You can’t perform that action at this time.
0 commit comments