Skip to content

Instantly share code, notes, and snippets.

@Angelfire
Created February 28, 2023 19:29
Show Gist options
  • Save Angelfire/e770ca31a72a9e827fe076951c08dbf0 to your computer and use it in GitHub Desktop.
Save Angelfire/e770ca31a72a9e827fe076951c08dbf0 to your computer and use it in GitHub Desktop.
Raw Markdown
function rawMarkdown(markdown) {
const regex = /(\*{1,2}|_{1,2}|`{1,3}|~{1,2}|#{1,6}|!{0,1}\[.*?\]\(.*?\)|>{1}|`{1,2}|!\[.*?\]\(.*?\))/g
const noMarkdown = markdown.replace(regex, '')
return noMarkdown
}
const markdown = `
# H1
## H2
### H3
#### H4
##### H5
###### H6
> Blockquote
\`\`\`
const code = 'hello world';
console.log(code);
\`\`\`
[Link to example.com](https://www.example.com)
## Paragraph
`;
const plainText = rawMarkdown(markdown);
console.log(plainText);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment