Skip to content
This repository has been archived by the owner on Feb 2, 2019. It is now read-only.

Commit

Permalink
Fixed issue where Tarmogoyf power and toughness would be incorrectly …
Browse files Browse the repository at this point in the history
…formatted (#15)
  • Loading branch information
SamStonehouse authored and chuckharmston committed Feb 17, 2017
1 parent a0d27d8 commit a4e25ae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions lib/middleware/markdown-escape.js
@@ -0,0 +1,18 @@
function escape(str) {
// Markdown on Slack can't always be escaped, the best solution is to use a
// vertical tab character which doesn't embolden text
// http://webapps.stackexchange.com/questions/86557/how-do-i-escape-formatting-characters-in-slack
return str.replace(new RegExp('\\*', 'g'), '\u000B\*');
}


module.exports = attachment => {
if (attachment.text) {
attachment.text = escape(attachment.text);
if (!('mrkdwn_in' in attachment)) {
attachment.mrkdwn_in = [];
}
attachment.mrkdwn_in.push('text');
}
return attachment;
};
4 changes: 3 additions & 1 deletion lib/response-types.js
Expand Up @@ -5,6 +5,7 @@ const abilityWords = require('./middleware/ability-words');
const footer = require('./middleware/footer');
const manamoji = require('./middleware/manamoji');
const reminderText = require('./middleware/reminder-text');
const markdownEscape = require('./middleware/markdown-escape');

const COLOR = '#431E3F';

Expand Down Expand Up @@ -68,7 +69,8 @@ TextResponse.prototype.middleware = [
footer,
manamoji,
reminderText,
abilityWords
abilityWords,
markdownEscape
];
TextResponse.prototype.url = 'https://api.scryfall.com/cards/named';

Expand Down

0 comments on commit a4e25ae

Please sign in to comment.