MCPcopy Create free account
hub / github.com/codecombat/codecombat / markdownToPlainText

Function markdownToPlainText

app/core/utils.js:1633–1646  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

1631}
1632
1633const markdownToPlainText = function (text) {
1634 // First, replace HTML tags in text with their plain text contents
1635 let element
1636 text = text.replace(/<[^>]*>/g, '')
1637 const plainTextMarkedRenderer = new marked.Renderer()
1638 for (element of ['code', 'blockquote', 'html', 'heading', 'hr', 'list', 'listitem', 'paragraph', 'table', 'tablerow', 'tablecell', 'strong', 'em', 'codespan', 'br', 'del', 'text']) {
1639 plainTextMarkedRenderer[element] = text => text
1640 }
1641 for (element of ['link', 'image']) {
1642 plainTextMarkedRenderer[element] = (href, title, text) => text
1643 }
1644 const plainText = marked(text, { renderer: plainTextMarkedRenderer })
1645 return plainText
1646}
1647
1648const markedInline = function (text) {
1649 // Like marked, but inline (no wrapper <p></p>); this is an option in newer marked versions

Callers 1

preloadFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected