-
-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Many packages does not distinguish halfwidth and fullwidth characters #310
Comments
Hey! This rule measures characters. There isn’t a good solution. I recommend turning this rule off instead. See https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-table-pipe-alignment#fix for more info |
Majority of programmers codes with fixed sized font and width of CJK characters in such situation are well defined and documented in here: https://unicode.org/Public/UNIDATA/EastAsianWidth.txt We at least need to create a new option to respect the size of full width character. Something like "fixed width font mode" |
Have you tested your ideas in different code editors? |
I'm Korean. Yes I have been used CJK letters more than 20 years in many editors including vi, nvim, Vim, nano, micro, ed, terminal, emacs, VSCode, atom, zed, notepad.exe, notepad++, Visual Studio, sublime. In these editors, CJK letters will be displayed as fullwidth character (which have double width of halfwidth character) unless you explicitly change your font into something other than fixed width font. |
Just in case you might not familiar with CJK: https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms |
I’m looking at your code example here on GH and they’re both displayed “misaligned” |
I don't think it's a good idea to ignore this issue to satisfy GitHub's misrepresentation of CJK characters. |
I at least want to solve this problem by creating a linter option that respects the size of full-width characters. Since it's an option, it shouldn't affect existing behavior. I strongly believe that this should be the default behavior, not an option to opt-in, and this is what any CJK developer would have done. But if you disagree, I'd be happy to see it fixed as an option. What do you think? |
GH is using the web. CSS. A monospaced font. Many editors use the web/css/monospace. My point is that all tools are going to display it differently. That's what the rule currently does: broken for some, good for some. So I suggest not using this rule. You say that all tools behave one way. I show GH doing it differently. I know editors display emoji differently. Can you provide screenshots for different tools displaying your examples correctly? |
"remark-lint-table-pipe-alignment" have been existed for a long time because it is useful to some users even if it's fine for some non-CJK users and broken for CJK users. And so the new fullwidth-respecting option will be the same. It will be pretty much useful for CJK users. |
Everyone uses emoji. Not just Koreans.
Can you please show different editors? And label which editors you show? |
And many editors try to vertically align a CJK character with 2 latin alphabets, regardless of font configs. Terminal-based editors already do this - every Unicode-aware terminal emulators try to treat a CJK character width as 2 latin chars by default. Ace, a web-based editor (which is used by Rust Playground), tries to vertically align intentionally. They measures font size and manually put twice size of it, like: GitHub's align isn't right because, in my computer, they don't use a monospaced font, but they use two fonts: 'Liberation Mono' and 'Noto Sans Mono CJK KR' (because Liberation Mono doesn't have any CJK chars). Using only 'Noto Sans Mono CJK KR' mitigates the problem: Using popular alternative fonts like Neo둥근모 or D2Coding just fits right:
|
Yes, character width can be different by editors, and by fonts. But the point is, you should Unicode-aware if you do "align" something, and 'treat CJK character width as same as two latin alphabets' is a good practice and sensible one. |
Reference: remarkjs#310
I've created a patch that addresses this issue as follows: 1e659c2 What do you think? (I didn't know how to make it an opt-in option, so I included it in the default behavior for now) |
Reference: remarkjs#310
Reference: remarkjs#310
Every tool (that is reasonably good) does that, your editor too.
Right, so this comes back to my original point. How things show, depends on the final user’s computer, and what that user chooses. Different users will see things differently. It is not known to
That is a strong statements while the topic remains vague. What is “Unicode-aware”? Please explain or link to a specification or algorithm. Why should
We do support configurable functions in And, could there be a good default that works for every user? |
OK. SpecificationAlgorithmIn order of decreasing precedence:
|
That‘s 1 of the 30 questions I asked. What about the others? |
The discussions in this issue tracker are becoming increasingly frustrating. I mentioned that I had already created a patch because I thought you might find it cumbersome to fix this issue: 1e659c2. I believe I have sufficiently demonstrated that full-width and half-width characters are standardized concepts in Unicode and how they should operate. I think I have clearly explained in my response on September 27 how to handle Emojis, ANSI colors, Control characters, and ambiguous characters, as well as which Unicode version to follow. I believe that correctly handling full-width characters is a good default, but I have already stated on March that I agree not to change the default because doing so would break backward compatibility. remark-gfm already has the functionality to customize Please provide me a rough guide on how to add the |
Maybe you should read the explanation someone is kindly providing to you before responding? |
Initial checklist
Affected packages and versions
[email protected]
Link to runnable example
No response
Steps to reproduce
Open below with browser:
Expected behavior
The first one should be fine and the second one should be an error.
Actual behavior
However, the first one gives an error and the second one does not.
Runtime
Node v17, Node v16, Node v14, Node v12, Deno, Electron, Other (please specify in steps to reproduce)
Package manager
npm 8, npm 7, npm 6, yarn 2, yarn 1, pnpm, Other (please specify in steps to reproduce)
OS
Windows, Linux, macOS, Other (please specify in steps to reproduce)
Build and bundle tools
Webpack, Rollup, esbuild, Parcel, Create React App, Gatsby, Next.js, Remix, Docusaurus, Snowpack, Vite, Other (please specify in steps to reproduce)
The text was updated successfully, but these errors were encountered: