fix(frontend): add missing docstrings
This commit is contained in:
parent
8f80db4fc1
commit
ab1e9ea0da
2 changed files with 17 additions and 0 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
/**
|
||||||
|
* Replaces placeholders in a template string with values from a replacement items object.
|
||||||
|
*
|
||||||
|
* The placeholders are in the format %key%, whereby %key% is replaced with the value of the 'key'
|
||||||
|
* attribute in the replacementItems object.
|
||||||
|
*
|
||||||
|
* @param {string} templateString - The template string containing placeholders to be replaced.
|
||||||
|
* @param {object} replacementItems - The object containing key-value pairs for replacement.
|
||||||
|
* @returns {string} The modified string with all placeholders replaced.
|
||||||
|
*/
|
||||||
export function interpolateString(templateString: string, replacementItems: { [key: string]: any }): string {
|
export function interpolateString(templateString: string, replacementItems: { [key: string]: any }): string {
|
||||||
if (typeof templateString !== 'string') {
|
if (typeof templateString !== 'string') {
|
||||||
return '';
|
return '';
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
import { marked } from 'marked';
|
import { marked } from 'marked';
|
||||||
import dompurify from 'dompurify';
|
import dompurify from 'dompurify';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the input text, which is assumed to be in markdown format, into HTML and returns it.
|
||||||
|
* The returned HTML is sanitized to prevent XSS.
|
||||||
|
*
|
||||||
|
* @param {string} text - The input text in markdown format to convert.
|
||||||
|
* @returns {string} The HTML representation of the input text.
|
||||||
|
*/
|
||||||
export function markdownToHtml(text: string): string {
|
export function markdownToHtml(text: string): string {
|
||||||
// Remove zerowidth chars from beginning of input string
|
// Remove zerowidth chars from beginning of input string
|
||||||
// This is probably not necessary...
|
// This is probably not necessary...
|
||||||
|
|
Loading…
Add table
Reference in a new issue