YarnSpinnerTool / YarnSpinner

Yarn Spinner is a tool for building interactive dialogue in games!
https://yarnspinner.dev
MIT License
2.3k stars 201 forks source link

Proposal: Simplify spec's whitespace handling #360

Open sanbox-irl opened 1 year ago

sanbox-irl commented 1 year ago

The yarn spinner spec currently defines whitespace as follows:

Whitespace is any non-visible character with a width greater than 0. Common whitespace encountered include the space and the tab.

This allows for valid, meaningful non-zero width characters, especially bare accent markers, to be considered "white space". The arabic letter mark 061C, for example, is whitespace according to this definition but not according to anyone else.

Instead, since Yarn already requires its input to be valid utf8, I suggest we punt to UTF8's own definitions of whitespace, found here: https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt.

This is precisely what C#'s (https://learn.microsoft.com/en-us/dotnet/api/system.char.iswhitespace?view=net-7.0#remarks) white space already does, so we're in good company.

Therefore, I would suggest that the line be chnaged to:

Whitespace is, generally, any non-visible character with a width greater than 0. Common whitespace encountered include the space and the tab. Specifically, whitespace is specified in the [Unicode Character Database](https://www.unicode.org/reports/tr44/) [PropList.txt](https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt).
McJones commented 1 year ago

I am totally in favour of this, the Unicode consortium has already done the hard work and we should take advantage of this.

sanbox-irl commented 1 year ago

I'll make a PR tonight then