+ mdToOneLinePlainText
+}
+
+// ---------------------------------------------------------------------------
+
+// Thanks: https://github.com/wavesheep/markdown-it-plain-text
+function plainTextPlugin (markdownIt: any) {
+ function plainTextRule (state: any) {
+ const text = scan(state.tokens)
+
+ markdownIt.plainText = text
+ }
+
+ function scan (tokens: any[]) {
+ let lastSeparator = ''
+ let text = ''
+
+ function buildSeparator (token: any) {
+ if (token.type === 'list_item_close') {
+ lastSeparator = ', '
+ }
+
+ if (token.tag === 'br' || token.type === 'paragraph_close') {
+ lastSeparator = ' '
+ }
+ }
+
+ for (const token of tokens) {
+ buildSeparator(token)
+
+ if (token.type !== 'inline') continue
+
+ for (const child of token.children) {
+ buildSeparator(child)
+
+ if (!child.content) continue
+
+ text += lastSeparator + child.content
+ lastSeparator = ''
+ }
+ }
+
+ return text
+ }
+
+ markdownIt.core.ruler.push('plainText', plainTextRule)