slack-message-parser
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -24,3 +24,3 @@ "use strict"; | ||
const prevChar = text.charAt(position - 1); | ||
if (prevChar && !prevChar.match(/\s/)) { | ||
if (prevChar && !prevChar.match(/[\s.,([{!?\-=]/)) { | ||
return null; | ||
@@ -27,0 +27,0 @@ } |
@@ -5,3 +5,3 @@ "use strict"; | ||
const combinator_1 = require("./combinator"); | ||
const parseBold = combinator_1.explicit(combinator_1.regexp(/^\*(\S([^*\n]*?|[^*\n]*? `.*?` )\S|\S)\*(?=[\s.,]|$)/, (match, text, position, parseText) => { | ||
const parseBold = combinator_1.explicit(combinator_1.regexp(/^\*(\S([^*\n]*?|[^*\n]*? `.*?` )\S|\S)\*(?=[\s.,\])}!?\-=]|$)/, (match, text, position, parseText) => { | ||
const [matchedText, content] = match; | ||
@@ -16,3 +16,3 @@ return [ | ||
})); | ||
const parseCode = combinator_1.explicit(combinator_1.regexp(/^`([^`]+?)`(?=\s|$)/, (match, text, position) => { | ||
const parseCode = combinator_1.explicit(combinator_1.regexp(/^`([^`]+?)`(?=[\s.,\])}!?\-=]|$)/, (match, text, position) => { | ||
const [matchedText, content] = match; | ||
@@ -27,3 +27,3 @@ return [ | ||
})); | ||
const parsePreText = combinator_1.explicit(combinator_1.regexp(/^```(\s*\S[\s\S]*?\s*)```(?=\s|$)/, (match, text, position) => { | ||
const parsePreText = combinator_1.explicit(combinator_1.regexp(/^```(\s*\S[\s\S]*?\s*)```(?=[\s.,\])}!?\-=]|$)/, (match, text, position) => { | ||
const [matchedText, content] = match; | ||
@@ -38,3 +38,3 @@ return [ | ||
})); | ||
const parseItalic = combinator_1.explicit(combinator_1.regexp(/^_(\S([^_\n]*?|[^_\n]*? `.*?` )\S|\S)\_(?=[\s.,]|$)/, (match, text, position, parseText) => { | ||
const parseItalic = combinator_1.explicit(combinator_1.regexp(/^_(\S([^_\n]*?|[^_\n]*? `.*?` )\S|\S)\_(?=[\s.,\])}!?\-=]|$)/, (match, text, position, parseText) => { | ||
const [matchedText, content] = match; | ||
@@ -49,3 +49,3 @@ return [ | ||
})); | ||
const parseStrike = combinator_1.explicit(combinator_1.regexp(/^~(\S([^~\n]*?|[^~\n]*? `.*?` )\S|\S)\~(?=[\s.,]|$)/, (match, text, position, parseText) => { | ||
const parseStrike = combinator_1.explicit(combinator_1.regexp(/^~(\S([^~\n]*?|[^~\n]*? `.*?` )\S|\S)\~(?=[\s.,\])}!?\-=]|$)/, (match, text, position, parseText) => { | ||
const [matchedText, content] = match; | ||
@@ -100,3 +100,3 @@ return [ | ||
}); | ||
const parseLink = combinator_1.regexp(/^<([^\s<>]+?)(\|([^<>]+?))?>/, (match, text, position, parseText) => { | ||
const parseLink = combinator_1.regexp(/^<([^\s<>][^\n<>]*?)(\|([^<>]+?))?>/, (match, text, position, parseText) => { | ||
const [matchedText, link, _, label] = match; | ||
@@ -103,0 +103,0 @@ const nextPosition = position + matchedText.length; |
{ | ||
"name": "slack-message-parser", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Parser for Slack message", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -45,3 +45,3 @@ import { Node } from './types/Node' | ||
if (prevChar && !prevChar.match(/\s/)) { | ||
if (prevChar && !prevChar.match(/[\s.,([{!?\-=]/)) { | ||
return null | ||
@@ -48,0 +48,0 @@ } |
@@ -7,3 +7,3 @@ import { NodeType } from './types/Node' | ||
regexp( | ||
/^\*(\S([^*\n]*?|[^*\n]*? `.*?` )\S|\S)\*(?=[\s.,]|$)/, | ||
/^\*(\S([^*\n]*?|[^*\n]*? `.*?` )\S|\S)\*(?=[\s.,\])}!?\-=]|$)/, | ||
(match, text, position, parseText) => { | ||
@@ -24,3 +24,3 @@ const [matchedText, content] = match | ||
const parseCode = explicit( | ||
regexp(/^`([^`]+?)`(?=\s|$)/, (match, text, position) => { | ||
regexp(/^`([^`]+?)`(?=[\s.,\])}!?\-=]|$)/, (match, text, position) => { | ||
const [matchedText, content] = match | ||
@@ -39,13 +39,16 @@ | ||
const parsePreText = explicit( | ||
regexp(/^```(\s*\S[\s\S]*?\s*)```(?=\s|$)/, (match, text, position) => { | ||
const [matchedText, content] = match | ||
regexp( | ||
/^```(\s*\S[\s\S]*?\s*)```(?=[\s.,\])}!?\-=]|$)/, | ||
(match, text, position) => { | ||
const [matchedText, content] = match | ||
return [ | ||
{ | ||
type: NodeType.PreText, | ||
text: content | ||
}, | ||
position + matchedText.length | ||
] | ||
}) | ||
return [ | ||
{ | ||
type: NodeType.PreText, | ||
text: content | ||
}, | ||
position + matchedText.length | ||
] | ||
} | ||
) | ||
) | ||
@@ -55,3 +58,3 @@ | ||
regexp( | ||
/^_(\S([^_\n]*?|[^_\n]*? `.*?` )\S|\S)\_(?=[\s.,]|$)/, | ||
/^_(\S([^_\n]*?|[^_\n]*? `.*?` )\S|\S)\_(?=[\s.,\])}!?\-=]|$)/, | ||
(match, text, position, parseText) => { | ||
@@ -73,3 +76,3 @@ const [matchedText, content] = match | ||
regexp( | ||
/^~(\S([^~\n]*?|[^~\n]*? `.*?` )\S|\S)\~(?=[\s.,]|$)/, | ||
/^~(\S([^~\n]*?|[^~\n]*? `.*?` )\S|\S)\~(?=[\s.,\])}!?\-=]|$)/, | ||
(match, text, position, parseText) => { | ||
@@ -144,3 +147,3 @@ const [matchedText, content] = match | ||
const parseLink = regexp( | ||
/^<([^\s<>]+?)(\|([^<>]+?))?>/, | ||
/^<([^\s<>][^\n<>]*?)(\|([^<>]+?))?>/, | ||
(match, text, position, parseText) => { | ||
@@ -147,0 +150,0 @@ const [matchedText, link, _, label] = match |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
152931
29
712