-
Notifications
You must be signed in to change notification settings - Fork 186
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
Making custom token for use in a custom plugin #167
Comments
Hey @nrakic90, the first thing I wanted to mention is that the plugin API is largely undocumented and is subject to change in the future. Given that, kudos to you for figuring this out. The big roadblock you'll run into next is due to a fundamental problem with the plugin API: There's no easy way to integrate new text tokens with the rest of the link-parsing state machine. I'm going to try my best to help you out here, but this is going to get complicated. The first thing you need is to generate intermediate let intermediateKeywordStates = stateify('keyword', S_START, KEYWORD_TOKEN, linkify.scanner.tokens.DOMAIN); Then you'll need a loop like this for the intermediate states, since those could have jumps to domains (e.g., See how the In your example, seeing the text token TL;DR, this is doable but not pretty. There are definitely plans on improving this interface to abstract-away all this complexity, but for now that's all the help I can offer. |
Thank you so much for an in-depth explanation, I really appreciate it! I was experimenting with statefy at one point but then gave it up because I didn't have all the pieces of the puzzle apparently. |
Has this gotten any easier. I really would like to use a custom token! |
In the docs it seems like, it should be possible to do This does not seem to work. How is the word character meant in the docs. |
@toger5 I'm working on some additional examples/docs for this in an upcoming release. For now, check out the hashtag plugin for reference Notes:
|
This is super helpful thank you very much for the detailed comment! const acceptingState = createTokenClass("something")
scanner.start
.tt('h')
.tt('e')
.tt('l')
.tt('l')
.tt('o', acceptingState) but that did not seem to work. // (A)
const GreetingState = HState
.tt('i', GreetingState) // don't create a new accepting state, use the existing one
// VS
// (B)
const GreetingState = HState
.tt('i') What I tried is |
Hello.
First I want to say good job on this plugin.
I am making a plugin that will detect custom format, something in the lines of "keyword://test/test1/test2".
I managed to make a plugin based on what I saw in hasthag.js and mention.js . I am having trouble making a token out of "keyword". Can you explain this process a bit? I've attached a "sketch" of my plugin, would you kindly tell me what am I doing wrong? I would be grateful. All the best!
The text was updated successfully, but these errors were encountered: