Skip to content

Commit

Permalink
fix(converter): list markers causes all subsequent characters to be i…
Browse files Browse the repository at this point in the history
…ncorrectly escaped

Closes #3
  • Loading branch information
skoropadas committed Feb 26, 2023
1 parent 209b8cf commit ed8dac4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/telegramify.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ const createHandlers = definitions => ({
return wrap(value, marker);
},

listItem: (...args) => escapeSymbols(defaultHandlers.listItem(...args).replace(/^\*/, '•')),
list: (...args) => defaultHandlers.list(...args).replace(/^(\d+)./gm, '$1\\.')
,

listItem: (...args) => defaultHandlers.listItem(...args).replace(/^\*/, '•'),

code(node, _parent, context) {
const exit = context.enter('code');
Expand Down
7 changes: 7 additions & 0 deletions tests/convert.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,11 @@ describe('Test convert method', () => {

expect(convert(markdown)).toBe(tgMarkdown);
});

it('Bold text in lists', function () {
const markdown = '- To make text **bold**, surround it with double asterisks (`**`): `**This text is bold.**`';
const tgMarkdown = '• To make text *bold*, surround it with double asterisks \\(`**`\\): `**This text is bold.**`\n';

expect(convert(markdown)).toBe(tgMarkdown);
});
});

0 comments on commit ed8dac4

Please sign in to comment.