FIX: mentions broken after adding an <abbr> tag

A previous shortcut used was not allowing for <abbr and other tags starting with a

If <abbr> appeared anywhere in the text all mentions would fail to link
This commit is contained in:
Sam 2018-07-05 09:27:11 +10:00
parent d12194c438
commit b54ba4c952
2 changed files with 10 additions and 2 deletions

View File

@ -38,8 +38,12 @@ export function textReplace(state, callback, skipAllLinks) {
if (token.type === "link_open" || token.type === "link_close") {
linkLevel -= token.nesting;
} else if (token.type === "html_inline") {
if (token.content.substr(0, 2).toLowerCase() === "<a") {
linkLevel++;
const openLink = token.content.substr(0, 2).toLowerCase();
if (openLink === "<a") {
if (token.content.match(/^<a(\s.*)?>/i)) {
linkLevel++;
}
} else if (token.content.substr(0, 4).toLowerCase() === "</a>") {
linkLevel--;
}

View File

@ -204,6 +204,10 @@ describe PrettyText do
describe "Mentions" do
it "can handle mentions after abbr" do
expect(PrettyText.cook("test <abbr>test</abbr>\n\n@bob")).to eq("<p>test <abbr>test</abbr></p>\n<p><span class=\"mention\">@bob</span></p>")
end
it "should handle 3 mentions in a row" do
expect(PrettyText.cook('@hello @hello @hello')).to match_html "<p><span class=\"mention\">@hello</span> <span class=\"mention\">@hello</span> <span class=\"mention\">@hello</span></p>"
end