client/errors: show errors in inline Markdown
This commit is contained in:
parent
e05e0e5fd2
commit
5b565e3b00
3 changed files with 36 additions and 3 deletions
|
@ -132,6 +132,34 @@ function formatMarkdown(text) {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatInlineMarkdown(text) {
|
||||||
|
const renderer = new marked.Renderer();
|
||||||
|
const options = {
|
||||||
|
renderer: renderer,
|
||||||
|
breaks: true,
|
||||||
|
sanitize: true,
|
||||||
|
smartypants: true,
|
||||||
|
};
|
||||||
|
let wrappers = [
|
||||||
|
new TildeWrapper(),
|
||||||
|
new EntityPermalinkWrapper(),
|
||||||
|
new SearchPermalinkWrapper(),
|
||||||
|
new SpoilersWrapper(),
|
||||||
|
new SmallWrapper(),
|
||||||
|
new StrikeThroughWrapper(),
|
||||||
|
];
|
||||||
|
for (let wrapper of wrappers) {
|
||||||
|
text = wrapper.preprocess(text);
|
||||||
|
}
|
||||||
|
text = marked.inlineLexer(text, [], options);
|
||||||
|
wrappers.reverse();
|
||||||
|
for (let wrapper of wrappers) {
|
||||||
|
text = wrapper.postprocess(text);
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
formatMarkdown: formatMarkdown,
|
formatMarkdown: formatMarkdown,
|
||||||
|
formatInlineMarkdown: formatInlineMarkdown,
|
||||||
};
|
};
|
||||||
|
|
|
@ -95,6 +95,10 @@ function formatMarkdown(text) {
|
||||||
return markdown.formatMarkdown(text);
|
return markdown.formatMarkdown(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatInlineMarkdown(text) {
|
||||||
|
return markdown.formatInlineMarkdown(text);
|
||||||
|
}
|
||||||
|
|
||||||
function formatUrlParameters(dict) {
|
function formatUrlParameters(dict) {
|
||||||
let result = [];
|
let result = [];
|
||||||
for (let key of Object.keys(dict)) {
|
for (let key of Object.keys(dict)) {
|
||||||
|
@ -230,6 +234,7 @@ module.exports = arrayToObject([
|
||||||
formatRelativeTime,
|
formatRelativeTime,
|
||||||
formatFileSize,
|
formatFileSize,
|
||||||
formatMarkdown,
|
formatMarkdown,
|
||||||
|
formatInlineMarkdown,
|
||||||
unindent,
|
unindent,
|
||||||
enableExitConfirmation,
|
enableExitConfirmation,
|
||||||
disableExitConfirmation,
|
disableExitConfirmation,
|
||||||
|
|
|
@ -288,15 +288,15 @@ function showMessage(target, message, className) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function showError(target, message) {
|
function showError(target, message) {
|
||||||
return showMessage(target, message, 'error');
|
return showMessage(target, misc.formatInlineMarkdown(message), 'error');
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSuccess(target, message) {
|
function showSuccess(target, message) {
|
||||||
return showMessage(target, message, 'success');
|
return showMessage(target, misc.formatInlineMarkdown(message), 'success');
|
||||||
}
|
}
|
||||||
|
|
||||||
function showInfo(target, message) {
|
function showInfo(target, message) {
|
||||||
return showMessage(target, message, 'info');
|
return showMessage(target, misc.formatInlineMarkdown(message), 'info');
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearMessages(target) {
|
function clearMessages(target) {
|
||||||
|
|
Loading…
Reference in a new issue