mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Correct logic so hashtags are properly ignored in links
This commit is contained in:
@@ -17,10 +17,10 @@ export function inlineRegexRule(md, options) {
|
||||
const start = options.start.charCodeAt(0);
|
||||
const maxLength = (options.maxLength || 500) + 1;
|
||||
|
||||
return function(state) {
|
||||
return function(state, silent) {
|
||||
const pos = state.pos;
|
||||
|
||||
if (state.src.charCodeAt(pos) !== start) {
|
||||
if (state.src.charCodeAt(pos) !== start || silent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -34,18 +34,19 @@ export function inlineRegexRule(md, options) {
|
||||
|
||||
// skip if in a link
|
||||
if (options.skipInLink && state.tokens) {
|
||||
let last = state.tokens[state.tokens.length-1];
|
||||
if (last) {
|
||||
if (last.type === 'link_open') {
|
||||
let i;
|
||||
for(i=state.tokens.length-1;i>=0;i--) {
|
||||
let token = state.tokens[i];
|
||||
let type = token.type;
|
||||
if (type === 'link_open' || (type === 'html_inline' && token.content.substr(0,2) === "<a")) {
|
||||
return false;
|
||||
}
|
||||
if (last.type === 'html_inline' && last.content.substr(0,2) === "<a") {
|
||||
return false;
|
||||
if (type.block || type === 'link_close' || (type === 'html_inline' && token.content.substr(0,3).toLowerCase() === "</a>")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const substr = state.src.slice(pos, Math.min(pos + maxLength,state.posMax));
|
||||
|
||||
const matches = options.matcher.exec(substr);
|
||||
|
||||
Reference in New Issue
Block a user