GithubHelp home page GithubHelp logo

Comments (14)

Sicalxy avatar Sicalxy commented on May 20, 2024 4

@krausekai

Same issue occurs when using Japanese characters, without emojis.

For example:

| Name    | Name2   |
| ------- | ------- |
| testing | Column2 |
| 漢字    | Column2 |
| テスト  | Column2 |

A few monospace fonts (Consolas, Courier, Roboto Mono) do not seem to fix the issue. I don't think this could be perfectly aligned, but could be better aligned with space adjustments. How, I am not sure.

I'm not sure how did you change monospace fonts, I got similar problem but I solved it.

han

If you just edit .markdown-source-view in snippet, then you didn't change table's font. You can try to set monospace global wide or specific your table's font:

.cm-s-obsidian .HyperMD-table-row {
  font-family: 'your font';
}

Similar for @zephraph, the biggest problem is font. Try some different fonts (Source Code Pro + Noto Color Emoji). Still not perfect, but better:
emo

from advanced-tables-obsidian.

tgrosinger avatar tgrosinger commented on May 20, 2024 3

And that's not even taking into consideration that some monospace fonts might render emoji differently. Or are emoji even in fonts? Are emoji different widths on different operating systems? I have no idea 🤷‍♂️

from advanced-tables-obsidian.

spencercook avatar spencercook commented on May 20, 2024 1

image

It seems the rendering issue is theme independent. I am using the Minimal theme and it's settings plugin but after disabling it and restoring the default theme the issue remained. I tried specifying Inconsolata at the monospace font in the advanced tables plugin as suggested but that didn't work either.

Thanks for checking this out!

from advanced-tables-obsidian.

krausekai avatar krausekai commented on May 20, 2024 1

Same issue occurs when using Japanese characters, without emojis.

For example:

| Name    | Name2   |
| ------- | ------- |
| testing | Column2 |
| 漢字    | Column2 |
| テスト  | Column2 |

A few monospace fonts (Consolas, Courier, Roboto Mono) do not seem to fix the issue. I don't think this could be perfectly aligned, but could be better aligned with space adjustments. How, I am not sure.

from advanced-tables-obsidian.

2045ga avatar 2045ga commented on May 20, 2024 1

Same issue occurs when using Chinese characters

from advanced-tables-obsidian.

zephraph avatar zephraph commented on May 20, 2024 1

I think we could likely use string-length to fix this.

from advanced-tables-obsidian.

zephraph avatar zephraph commented on May 20, 2024 1

After digging into this a bit more I think the issue is in @tgrosinger/md-advanced-tables, not this repo. My suspicion is that you'd need to update https://github.com/tgrosinger/md-advanced-tables/blob/37dd2c5a81faa3eb35d99683e11f3addac4017bd/src/table-cell.ts to use something like string-length (mentioned above) instead of calling .length. Essentially .length is going to lie to you if you're using it to measure position.

from advanced-tables-obsidian.

tgrosinger avatar tgrosinger commented on May 20, 2024

Can you please provide a screenshot?

This might be similar to #33.

from advanced-tables-obsidian.

tgrosinger avatar tgrosinger commented on May 20, 2024

Hmm, I this one is getting outside my understanding of unicode. I'm not sure if it has to do with the emoji containing multiple code points or if it is because of varying widths of the emoji themselves.

from advanced-tables-obsidian.

zephraph avatar zephraph commented on May 20, 2024

Yep, here's another example:

image

Here's a really good blog post that discusses emoji length issues and how to address them. It won't be perfect, but a step in the right direction.

https://blog.jonnew.com/posts/poo-dot-length-equals-two

from advanced-tables-obsidian.

robertandrews avatar robertandrews commented on May 20, 2024

Same here.

Screenshot 2022-11-27 at 19 21 12

Any thoughts on a fix?

from advanced-tables-obsidian.

robertandrews avatar robertandrews commented on May 20, 2024

After digging into this a bit more I think the issue is in @tgrosinger/md-advanced-tables, not this repo. My suspicion is that you'd need to update https://github.com/tgrosinger/md-advanced-tables/blob/37dd2c5a81faa3eb35d99683e11f3addac4017bd/src/table-cell.ts to use something like string-length (mentioned above) instead of calling .length. Essentially .length is going to lie to you if you're using it to measure position.

Good work, that's encouraging. Crossing fingers for a fix. Don't think it's in my wheelhouse.

from advanced-tables-obsidian.

tgrosinger avatar tgrosinger commented on May 20, 2024

Thank you very much @zephraph for digging into this. Unfortunately, I think it's a little more nuanced, which is why I haven't quite figured out how to solve it.

The md-advanced-tables library actually does put some work into determining the width of a character. Take a look here.

But emoji are particularly tricky. For example:

Emoji

Or this might show it even better:

Emoji-2

It's not 1 or 2 characters wide, it's like 2.2 characters wide. You can't align that using normal spaces... Currently md-advanced-tables is smart enough to call 👍 two characters wide, but it can't do 2.2 spaces of padding.

I'm definitely open to suggestions if anyone knows how to solve this one!

from advanced-tables-obsidian.

KucharczykL avatar KucharczykL commented on May 20, 2024

Not an expert, but it seems that in JavaScript, the Intl.Segmenter allows you to split strings by grapheme clusters, which are what people think of as actual "characters"1. The above-linked library https://github.com/sindresorhus/string-length uses it under the hood so it should fix the issues.

Footnotes

  1. https://tonsky.me/blog/unicode/, section How do I detect extended grapheme clusters then?

from advanced-tables-obsidian.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.