# Node-red-contrib-turndown - Escaping characters

**URL:** https://discourse.nodered.org/t/node-red-contrib-turndown-escaping-characters/43228
**Category:** General
**Created:** [26 March 2021 09:15 UTC](https://discourse.nodered.org/t/node-red-contrib-turndown-escaping-characters/43228 "2021-03-26T09:15:37Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Djibril](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@Djibril](https://discourse.nodered.org/u/Djibril)
#### Post date: [26 March 2021 09:15 UTC](https://discourse.nodered.org/t/node-red-contrib-turndown-escaping-characters/43228/1 "2021-03-26T09:15:38Z")

</div>

Hi,

I would use node-red to create a bot able to grab specific info online through cheerio and send using telegram.

To do that, I would convert html to markdownV2, in order to maintain links and some formatting.

I tried to use node-red-contrib-turndown node, but - as the node effectively transforms formatting - I noticed that markdown special characters are not escaped:  
Asterisk \*   
Underscore \_   
Curly braces { }   
Square brackets   
Brackets ( )  
Hash #   
Plus +   
Minus -   
Period .   
Exclamation point !

So, if I try to send them to telegram, it crash because of errors in parsing.

Node has no configuration, so I don't know what to do... someone else had experienced this? Did I something wrong?

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [26 March 2021 13:23 UTC](https://discourse.nodered.org/t/node-red-contrib-turndown-escaping-characters/43228/2 "2021-03-26T13:23:30Z")

</div>

Telegram's interpretation of Markdown is extremely simplistic anyway and it fails with odd characters as I found out the hard way. I'm working at the moment but I'll see if I can find the details later. Just note that their v1 implementation is more forgiving than their v2. But v1 supports even less markup (which is why it is more forgiving)

---

<div class="post-metadata">

### Author: ![Djibril](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@Djibril](https://discourse.nodered.org/u/Djibril)
#### Post date: [29 March 2021 09:56 UTC](https://discourse.nodered.org/t/node-red-contrib-turndown-escaping-characters/43228/3 "2021-03-29T09:56:36Z")

</div>

I wrote a regex function that escapes special chars... Seems working for now

```auto
replace(/(\[[^\[\]]+\]\((http[^\[\]\(\)]+)\))|[_[\\\]()~>#+=|{}.!-]/gi, (x,y) => y ? y : '\\' + x);

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [12 April 2021 09:56 UTC](https://discourse.nodered.org/t/node-red-contrib-turndown-escaping-characters/43228/4 "2021-04-12T09:56:52Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
