Skip to content

Instantly share code, notes, and snippets.

@Its-Just-Nans
Last active November 22, 2021 16:05
Show Gist options
  • Save Its-Just-Nans/aaab58eff030a0c726676405176c374e to your computer and use it in GitHub Desktop.
Save Its-Just-Nans/aaab58eff030a0c726676405176c374e to your computer and use it in GitHub Desktop.
ShowDownJS problem with &
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/showdown/dist/showdown.min.js"></script>
</head>
<body>
<div id="converted"></div>
<pre id="toConvert" style="display:none">
Here some text with & taht is converted
```c
#include <stdio.h>
int main(){
int number = 7;
int *pointerTOnumber = &number;
}
```
</pre>
<script>
let converter = new showdown.Converter();
let html = converter.makeHtml(document.getElementById('toConvert').innerHTML);
document.getElementById('converted').innerHTML = html;
</script>
</body>
</html>
@aote777
Copy link

aote777 commented Nov 22, 2021

Thank you for your answer. But I got the innerHTML value directly, and the character entity was also escaped。
var text = textarea.innerHTML
I don't understand

@aote777
Copy link

aote777 commented Nov 22, 2021

I've found a solution. Thank you very much 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment