haskell-prettyprinter / haskell-prettyprinter/prettyprinter
Support for wide characters and emojis
- Dominant language
- Haskell
- Stars
- 309
- Forks
- 43
- Avg merge
- 21h 25m
- Merged PRs (30d)
- 1
Description
Currently `Data.Text.length` is used to identify length of the text in characters. But this is not true for Unicode wide characters and emojis that can occupy 2 cells on the terminal. As well some of the characters might be invisible or lead to vertical tab etc.
Most likely it should be on the rendering side (e.g. HTML may use different ways to align text than spaces) and in this case it worth considering indent/column just a guideline based on other characters in layout. I.e.
```plain
|W|i|d|e|W|
|0 |1 |2 |3 |4|5 - virtual columns during layout
|0 |2 |4 |6 |8|9 - actual terminal columns during render
```
*(dependening on font may be rendered unaligned in browser, but should be fine in terminal)*
It should mostly work fine for [right alignment](https://github.com/simonmichael/hledger/pull/1136/files#diff-33f9542d5ec86df4776f516bda18b678R24-R36) as long as people don't use characters to pad, but use proper `indent`. Though last character might not always be tightly attached to right side.
More examples can be found in https://github.com/simonmichael/hledger/issues/895
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.