Clean up partial API tags'

This commit is contained in:
Aaron Carlino 2019-11-13 11:14:12 +13:00
parent 2586cfa9b0
commit 69232395fd
2 changed files with 12 additions and 1 deletions

View File

@ -0,0 +1,8 @@
const cleanApiTags = (html: string): string => {
return html.replace(
/\[api:(.*?)\]\s/,
(_, query) => `<a href="${query}">${query}</a> `
)
};
export default cleanApiTags;

View File

@ -1,6 +1,7 @@
import parse, { DomElement } from 'html-react-parser';
import cleanChildrenTags from './cleanChildrenTags';
import cleanWhitespace from './cleanWhitespace';
import cleanApiTags from './cleanApiTags';
import rewriteLink from './rewriteLink';
import parseChildrenOf from './parseChildrenOf';
import cleanCalloutTags from './cleanCalloutTags';
@ -13,9 +14,11 @@ import rewriteHeader from './rewriteHeader';
* @return ReactElement | ReactElement[] | string
*/
const parseHTML = (html: string): ReactElement | ReactElement[] | string => {
let cleanHTML = cleanChildrenTags(html);
let cleanHTML = html;
cleanHTML = cleanChildrenTags(cleanHTML);
cleanHTML = cleanCalloutTags(cleanHTML);
cleanHTML = cleanWhitespace(cleanHTML);
cleanHTML = cleanApiTags(cleanHTML);
const parseOptions = {
replace(domNode: DomElement): ReactElement | object | undefined | false {