Skip to content
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

refactor: call parent class url tokenizer method #218

Merged
merged 1 commit into from
Dec 31, 2021

Conversation

yoshinorin
Copy link
Member

The many lines of the current Tokenizer.url (extends from MarkedTokenizer) method seems just copy from marked's Tokenizer.url method.

It is very costly when update marked dependency.
I think just call super class method is enough.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 42f0ad4 on yoshinorin:refactor/call-super-class into 76ee3bc on hexojs:master.

Comment on lines -181 to -215
const cap = rules.inline.url.exec(src);
if (cap) {
let text, href;
if (cap[2] === '@') {
text = escape(isMangle ? mangle(cap[0]) : cap[0]);
href = 'mailto:' + text;
} else {
// do extended autolink path validation
let prevCapZero;
do {
prevCapZero = cap[0];
cap[0] = rules.inline._backpedal.exec(cap[0])[0];
} while (prevCapZero !== cap[0]);
text = escape(cap[0]);
if (cap[1] === 'www.') {
href = 'http://' + text;
} else {
href = text;
}
}

return {
type: 'link',
raw: cap[0],
text,
href,
tokens: [
{
type: 'text',
raw: text,
text
}
]
};
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems just copy from marked Tokenizer.js url method.

@SukkaW SukkaW merged commit 568e5e9 into hexojs:master Dec 31, 2021
@yoshinorin yoshinorin deleted the refactor/call-super-class branch December 31, 2021 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants