Browse Source

Merge pull request #12332 from maxunbearable/fix/markdown-special-chars

Usage of special HTML chars in mardown fix
pull/12347/head
Igor Kulikov 2 years ago
committed by GitHub
parent
commit
208278a68e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      ui-ngx/src/app/shared/models/js-function.models.ts

6
ui-ngx/src/app/shared/models/js-function.models.ts

@ -98,7 +98,7 @@ export const loadModuleMarkdownDescription = (http: HttpClient, translate: Trans
} else {
propDescription += `<p class="!pl-4 !pr-4"><em>const</em> <strong>${propName}</strong>: <code>${type}</code>`;
if (type !== 'object') {
propDescription += ` = ${prop}`;
propDescription += ' = ' + (type === 'string' ? `"${handleHtmlSpecialChars(prop)}"` : `${prop}`);
}
propDescription += '</p>';
}
@ -133,6 +133,10 @@ export const loadModuleMarkdownDescription = (http: HttpClient, translate: Trans
);
}
const handleHtmlSpecialChars = (text: string): string => {
return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
export const loadModuleMarkdownSourceCode = (http: HttpClient, translate: TranslateService, resource: ResourceInfo): Observable<string> => {
let sourceCode = `<div class="flex flex-col !pl-4"><h6>${resource.title}</h6><small>${translate.instant('js-func.source-code')}</small></div>\n\n`;
return loadFunctionModuleSource(http, resource.link).pipe(

Loading…
Cancel
Save