Coder Social home page Coder Social logo

Comments (28)

mikelambert avatar mikelambert commented on August 29, 2024 2

Feel free to create a dummy facebook event (or even a FB post on your wall) and see what happens?

It seems like it fails to parse that link properly, instead linking to https://zh.wikipedia.org/wiki/ .

from linkify-it.

tommedema avatar tommedema commented on August 29, 2024 1

I'm sorry I'm not a Chinese speaker. Perhaps someone else can help out here. There are also other Chinese punctuation characters, like

from linkify-it.

tommedema avatar tommedema commented on August 29, 2024 1

More examples of how difficult these Chinese posts are to parse: link

What's your idea on this?

from linkify-it.

fengmk2 avatar fengmk2 commented on August 29, 2024 1

I will try to resolve this problem.

from linkify-it.

puzrin avatar puzrin commented on August 29, 2024

Could you post a permalink to demo http://markdown-it.github.io/linkify-it/ ? You can type there all examples at once, with results.

from linkify-it.

puzrin avatar puzrin commented on August 29, 2024

Example

Problem is in (, used in your example. There are NO space before it. I'm not familiar with asian punctuation. Are such ( always word terminators? Is is possible to have it in links, like in wiki?

from linkify-it.

tommedema avatar tommedema commented on August 29, 2024

See http://markdown-it.github.io/linkify-it/#t1=http%3A%2F%2Ft.cn%2FRv4VRqQ%EF%BC%88%E5%88%86%E4%BA%AB%E8%87%AA%20%40%E7%88%B1%E5%A5%87%E8%89%BA%EF%BC%89%0A%0Ahttp%3A%2F%2Fhttp%3A%2F%2Ft.cn%2FR2t287H

I added another issue where a user mistakenly added http:// twice.

These are both (technically speaking) user behavior issues, but the first one especially is quite common.

Formally speaking ( is not a word terminator, however because it takes so much white space, many chinese people don't put a space in front of it (it's an act of being lazy, but it's quite common).

Perhaps I should do some string manipulation before I pass it to linkify-it?

from linkify-it.

puzrin avatar puzrin commented on August 29, 2024

Example with double http:// is technically correct. That's like http://localhost - any local domain allowed. Imho such typo do not need fixes.

Example with ( is more serious. It uses chineese unicode scopes, and can be distinguished from english scopes. But i need recommendations about grammar to be sure.

from linkify-it.

puzrin avatar puzrin commented on August 29, 2024

Let's leave it open until someone can formalize info for asian languages group (probably japan language has the same issues). I'm ready to fix as soon as possible, but would like to avoid kludges with inccomplete workarounds.

from linkify-it.

puzrin avatar puzrin commented on August 29, 2024

Seems you given wrong link, it shows default text.

from linkify-it.

tommedema avatar tommedema commented on August 29, 2024

Sorry, I've fixed the link now.

from linkify-it.

puzrin avatar puzrin commented on August 29, 2024

Thanks for examples. Posted a question at commonmark forum http://talk.commonmark.org/t/linkifier-lets-discuss-and-test/1045/9?u=vitaly

As far as i see in last example, spaces are not used at all. It's possible to to track locale change (non-english -> english), but that's not safe.

from linkify-it.

tommedema avatar tommedema commented on August 29, 2024

That's correct, spaces are not used. The Chinese use different punctuation marks or even don't use them because URLs are in English script and therefore the disctinction is easily visible to the eye, but more difficult for machines.

from linkify-it.

puzrin avatar puzrin commented on August 29, 2024

What about links with chineese chars? I can find link start somehow by [ any non english ]http://, but can't use this rule to search link end.

PS. Anyway, it worth to start collecting test samples for china language separately. Something like this

from linkify-it.

tommedema avatar tommedema commented on August 29, 2024

You're absolutely right. I think the first rule makes sense, but URLs can probably have chinese characters. Perhaps the first rule by itself would help though, and somekind of smart processing for certain delimiters that are unlikely to appear within an URL, e.g.:

str.replace(/[\uff08\uff09\uff0c\uff01\u3002\uff1f\u3010\u3011\uff3b\uff3d\u3001\u300a\u300b\u2605]/g, ' ') //( ) , ! 。 ? 【 】 [ ] 、 《 》 ★

from linkify-it.

LeonLiuY avatar LeonLiuY commented on August 29, 2024

Found this URL doesn't match:

http://markdown-it.github.io/linkify-it/#t1=http%3A%2F%2F172.26.142.48%2Fviewerjs%2F%23..%2F0529%2Fslides.pdf

BTW, I found a website comparing different regexps for URL:
https://mathiasbynens.be/demo/url-regex

from linkify-it.

tommedema avatar tommedema commented on August 29, 2024

By the way, Facebook does this properly, but I'm not sure if they use a proprietary solution.

from linkify-it.

puzrin avatar puzrin commented on August 29, 2024

@fengmk2 implementation can be not easy, but for the first step it would be enougth to have collection of fixtures with good coverage of Chinese edge cases.

See https://github.com/markdown-it/linkify-it/tree/master/test/fixtures

from linkify-it.

mikelambert avatar mikelambert commented on August 29, 2024

Here is my example page linkifying incorrectly:
http://www.dancedeets.com/events/896736620379772/2016-r16-taiwan-x-wbc

In this case, it's a vertical bar, though to be precise it's and not | (I hope github shows the difference properly). The page author uses it as a delimiter, but linkify sees it as part of the domain name (presumably it sees it as just another word character).

from linkify-it.

puzrin avatar puzrin commented on August 29, 2024

@mikelambert Nothing to fix. Fuzzy mode is not safe, it's an author's mistale to use linkify-it in wrong way.

from linkify-it.

mikelambert avatar mikelambert commented on August 29, 2024

I'm the website author using linkify-it to add links to raw text from a variety of sources which I didn't write myself (facebook events and other websites). And the individual source authors are not using linkify-it, and of course not writing their text with linkify-it in mind.

I recognize that fuzzy is not safe, and not perfect. However, it seems unfortunate that a vertical bar (what some authors are using as visual punctuation) is treated as part of a domain name. It seemed like the fuzziness could be smarter, even if it's still fuzzy.

So to clarify, is this a "it's not a bug, just user error" bug, or a "it's not a bug I care about fixing, but patches are welcome" bug?

from linkify-it.

puzrin avatar puzrin commented on August 29, 2024

@mikelambert I mean, problems with | in that examples is because linkifier applied after layout compose, instead of before compose. But linkifier goal is to find links in natural texts, not everywhere (that's impossible).

My personal opinion is, that linkifier is used not as expected. So, this example is not good enougth as a reason for changes. May be i don't understand something, but this is my opinion for now. If i had to do such site, i would parse links first, then compose header.

Also, i understand that people can have another opinions and may wish to just quick fix something via hacks. For this case, linkifier allows to override regexps without need to fork project.

from linkify-it.

mikelambert avatar mikelambert commented on August 29, 2024

What do you mean by "layout compose" ? I assume you are referring to writing up the text and adding the | to lay things out?

https://www.facebook.com/events/896736620379772/ is the source text I am working with. (Notice that Facebook gets the linkification correct.) I receive the raw text from the FB API, and then am trying to linkify it for use on my own website.

I understand that linkifier-it might be the wrong tool (since this is not natural text), and I am using it incorrectly (since it is applied after the author's layout composition). But unfortunately, I am not the author of the text, and so I am not able to linkify before adding the | characters.

Thanks for your time!

from linkify-it.

puzrin avatar puzrin commented on August 29, 2024

Then, if you have source in known format (|-separated), i would split it first, then apply linkifier, then join back. May be, with some additional conditions (line should be short and have chineese letters inside). Or would try to get html if possible (not familiar with FB api)

The reason to add | support could be, if you say "humans write such way" or "that's de-facto standard", with a lot of examples.

from linkify-it.

puzrin avatar puzrin commented on August 29, 2024

In other words, if you have auto-generated text - consider parse/detect it's structure prior to apply linkifier. Or if you know some new uncovered de-facto patterns of human writing - create new issue with proofs (live examples), and i'll try to fix it if possible.

from linkify-it.

mikelambert avatar mikelambert commented on August 29, 2024

Thank you, that's a creative solution to this problem. I'll go with that for now.

I'll create a separate issue with the few examples I have, and you can decide if it's justified "de-facto pattern of human writin" or not there. :)

from linkify-it.

geyang avatar geyang commented on August 29, 2024

@mikelambert I'm wondering what does facebook linkify do with this following link?

link: https://zh.wikipedia.org/wiki/(

you can see what this link take you to here: https://zh.wikipedia.org/wiki/(

from linkify-it.

Jeff-Tian avatar Jeff-Tian commented on August 29, 2024

I am looking forward to the fix! It could be more enjoyable every time I paste links in the GitHub README with Chinese characters following it can SMARTLY display them correctly.

from linkify-it.

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.