doc.silverstripe.org/src/utils/cleanApiTags.ts

13 lines
329 B
TypeScript
Raw Normal View History

2019-11-19 04:29:29 +01:00
/**
* Completes the shorthand [api:Something] syntax to [api:Something](Something)
* @param html
*/
2020-02-12 04:32:55 +01:00
const cleanApiTags = (html: string): string => {
return html
.replace(
2019-11-19 01:55:33 +01:00
/\[api:(.*?)\]([^(])/g,
2020-02-12 04:32:55 +01:00
(_, query, next) => `<a href="api:${query}">${query}</a>${next}`
2019-11-12 23:14:12 +01:00
)
};
export default cleanApiTags;