Describe the bug
Expected behavior
Live demo
Thanks for reporting the issue @Paveloom
This seems strange that string.slice failed because of russian language :thinking:
Also i did not show multi lines because it is a pain to work with multiline text in svg, so i just trimmed them for the sake of simplicity
This seems strange that string.slice failed because of russian language π€
@anuraghazra No it trims well:
desc = "Π¨Π°Π±Π»ΠΎΠ½Ρ make-ΡΠ°ΠΉΠ»ΠΎΠ² Π΄Π»Ρ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌ ΠΈ ΠΏΡΠ±Π»ΠΈΠΊΠ°ΡΠΈ.."
// => "Π¨Π°Π±Π»ΠΎΠ½Ρ make-ΡΠ°ΠΉΠ»ΠΎΠ² Π΄Π»Ρ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌ ΠΈ ΠΏΡΠ±Π»ΠΈΠΊΠ°ΡΠΈ.."
desc.slice(0, 50)
// => "Π¨Π°Π±Π»ΠΎΠ½Ρ make-ΡΠ°ΠΉΠ»ΠΎΠ² Π΄Π»Ρ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌ ΠΈ ΠΏΡΠ±Π»"
It's the font problem. For example, characters like "D" are longer, while "i" are shorter. e.g.
BTW, GitHub deals with this by expanding the card.


And cards are aligned, but lines are not.
Since you use SVG, sizes are fixed and can't expand automatically like the stock pin card.
@anuraghazra I have a not-so-good fix:
Plz let me know if this is available. I can submit a PR.
Increase the SVG's height a little
Auto break if the desc is too long.
This of course sounds simple, but isn't. SVG does not have auto text wrapping. I'll have to write a function to detect the text length (and not just text length also have to consider each word's width which is hard to figure out, otherwise we face the issue what you mentioned about "DDDD" longer than "III")
And we cannot simply make the height large it will look bad, we have to auto resize the height depending on how many line breaks there are (it's possible tho)
SVG does not have auto text wrapping.
@anuraghazra
See foreignObject. By adding an <p> in it will fix this.
SVG does not have auto text wrapping.
@anuraghazra
See foreignObject. By adding an<p>in it will fix this.
I know about foreignObject and github also supports it, but there is no guarantee that it will render on all browser as it's not in SVG v1.1 Spec
I'll have to write a function to detect the text length (and not just text length also have to consider each word's width which is hard to figure out, otherwise we face the issue what you mentioned about "DDDD" longer than "III")
@anuraghazra This is going to be tricky as we're handling some "rendered thing", but what we have on the server side are just texts.
By doing this we have to return with a js embedded.
Also, reimplement everything in HTML's way will be a choice.
I feel like I keep providing rubbish. My frontend knowledge is almost zero!π¨
Wait, this is solved with packages!
This should be partially fixed in #206
Although russian language text is now messing up.
This should be partially fixed in #206
Well, that's progress. Thank you for the PR, @HaaLeo and @anuraghazra.
Although russian language text is now messing up.
Yep:
Hopefully this problem will be solved too.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Bump.
Most helpful comment
Well, that's progress. Thank you for the PR, @HaaLeo and @anuraghazra.
Yep:
Hopefully this problem will be solved too.