fix: markdown render issue

pull/14832/merge
wangruidong 2025-02-12 14:37:23 +08:00 committed by w940853815
parent b0d6a09276
commit 2f1c0090b7
1 changed files with 18 additions and 7 deletions

View File

@ -14,7 +14,7 @@
{% if INTERFACE.footer_content %} {% if INTERFACE.footer_content %}
<style> <style>
.markdown-footer a { .markdown-footer a {
color: inherit; color: #428bca;
} }
.markdown-footer { .markdown-footer {
@ -46,12 +46,23 @@
if ($('.tooltip')[0]) { if ($('.tooltip')[0]) {
$('.tooltip').tooltip(); $('.tooltip').tooltip();
} }
$.fn.select2.defaults.set('language', getUserLang()) $.fn.select2.defaults.set('language', getUserLang());
const md = window.markdownit(); const md = window.markdownit({
const markdownContent = document.querySelector('script[type="text/markdown"]').textContent; html: true,
const markdownRef = document.getElementById('markdown-output') linkify: true,
if (markdownRef) { typographer: true,
markdownRef.innerHTML = md.render(markdownContent); breaks: true
});
const markdownContent = `{{ INTERFACE.footer_content|escapejs }}`;
const markdownRef = document.getElementById('markdown-output');
if (markdownRef && markdownContent) {
const renderedContent = md.render(markdownContent.trim());
markdownRef.innerHTML = renderedContent;
markdownRef.querySelectorAll('a').forEach(link => {
link.setAttribute('target', '_blank');
link.setAttribute('rel', 'noopener noreferrer');
});
} }
}); });
</script> </script>