@tinymce/moxiedoc
Advanced tools
Comparing version 0.2.0-feature.20220326065652519.shac1bbb7f to 0.2.0-feature.20220328004447693.sha90b7294
@@ -22,6 +22,6 @@ "use strict"; | ||
const encodeBR = (str) => str.replace(/<br\s*\/?>/g, '\n'); | ||
// convert <em> into __italics__ asciidoc | ||
const encodeEM = (str) => str.replace(/<\/?em>/g, '__'); | ||
// convert <strong> into **bold** asciidoc | ||
const encodeStrong = (str) => str.replace(/<\/?strong>/g, '**'); | ||
// convert <em> into _italics_ asciidoc | ||
const encodeEM = (str) => str.replace(/<\/?em>/g, '_'); | ||
// convert <strong> into *bold* asciidoc | ||
const encodeStrong = (str) => str.replace(/<\/?strong>/g, '*'); | ||
// convert <code> into backtick asciidoc | ||
@@ -47,16 +47,7 @@ const encodeCode = (str) => { | ||
}; | ||
// escape special asciidoc characters | ||
const specialChars = { | ||
'|': '{vbar}', | ||
'+': '{plus}', | ||
'*': '{asterisk}' | ||
}; | ||
const escapeSpecialChars = (str) => str.replace(/[|+*]/g, (match) => specialChars[match] || match); | ||
// convert content that looks like asciidoc attributes (e.g {0}) to literal strings | ||
// Note: Special characters should not be escaped | ||
const specialAttrs = Object.values(specialChars); | ||
const escapeAttributes = (str) => str.replace(/(\{\s*[\w\d-]+\s*\})/g, (match) => specialAttrs.indexOf(match) !== -1 ? match : `+${match}+`); | ||
const escapeAttributes = (str) => str.replace(/(\{\s*[\w\d-]+\s*\})/g, '+$1+'); | ||
// runs a bunch of required cleanup filters, where embedded code/text can break asciidoc rendering | ||
const cleanup = (str) => { | ||
const filters = [escapeSpecialChars, escapeAttributes, escapeComments, encodeBR, encodeEM, encodeStrong, encodeLinks, encodeCode]; | ||
const filters = [escapeComments, encodeBR, encodeEM, encodeStrong, encodeLinks, encodeCode, escapeAttributes]; | ||
return filters.reduce((acc, filter) => filter(acc), str); | ||
@@ -63,0 +54,0 @@ }; |
@@ -129,3 +129,3 @@ "use strict"; | ||
data.keywords = sortMembers(data.keywords); | ||
data.keywords = data.keywords.join(' '); | ||
data.keywords = data.keywords.join(', '); | ||
return [{ | ||
@@ -132,0 +132,0 @@ type: 'json', |
{ | ||
"name": "@tinymce/moxiedoc", | ||
"version": "0.2.0-feature.20220326065652519.shac1bbb7f", | ||
"version": "0.2.0-feature.20220328004447693.sha90b7294", | ||
"description": "A tool for generating API documentation", | ||
@@ -5,0 +5,0 @@ "author": "Tiny Technologies, Inc", |
@@ -32,9 +32,9 @@ import { Return } from '../../lib/member'; | ||
// convert <em> into __italics__ asciidoc | ||
// convert <em> into _italics_ asciidoc | ||
const encodeEM = (str: string): string => | ||
str.replace(/<\/?em>/g, '__'); | ||
str.replace(/<\/?em>/g, '_'); | ||
// convert <strong> into **bold** asciidoc | ||
// convert <strong> into *bold* asciidoc | ||
const encodeStrong = (str: string): string => | ||
str.replace(/<\/?strong>/g, '**'); | ||
str.replace(/<\/?strong>/g, '*'); | ||
@@ -62,20 +62,9 @@ // convert <code> into backtick asciidoc | ||
// escape special asciidoc characters | ||
const specialChars = { | ||
'|': '{vbar}', | ||
'+': '{plus}', | ||
'*': '{asterisk}' | ||
}; | ||
const escapeSpecialChars = (str: string): string => | ||
str.replace(/[|+*]/g, (match) => specialChars[match] || match); | ||
// convert content that looks like asciidoc attributes (e.g {0}) to literal strings | ||
// Note: Special characters should not be escaped | ||
const specialAttrs = Object.values(specialChars); | ||
const escapeAttributes = (str: string): string => | ||
str.replace(/(\{\s*[\w\d-]+\s*\})/g, (match) => specialAttrs.indexOf(match) !== -1 ? match : `+${match}+`); | ||
str.replace(/(\{\s*[\w\d-]+\s*\})/g, '+$1+'); | ||
// runs a bunch of required cleanup filters, where embedded code/text can break asciidoc rendering | ||
const cleanup = (str: string): string => { | ||
const filters = [ escapeSpecialChars, escapeAttributes, escapeComments, encodeBR, encodeEM, encodeStrong, encodeLinks, encodeCode ]; | ||
const filters = [ escapeComments, encodeBR, encodeEM, encodeStrong, encodeLinks, encodeCode, escapeAttributes ]; | ||
return filters.reduce((acc, filter) => filter(acc), str); | ||
@@ -82,0 +71,0 @@ }; |
@@ -161,3 +161,3 @@ import * as fs from 'fs'; | ||
data.keywords = data.keywords.join(' '); | ||
data.keywords = data.keywords.join(', '); | ||
return [{ | ||
@@ -164,0 +164,0 @@ type: 'json', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
344269
6657