diff --git a/src/data/extra/web/js/graphpreviewer.js b/src/data/extra/web/js/graphpreviewer.js index 58c724fd..226c7bf3 100644 --- a/src/data/extra/web/js/graphpreviewer.js +++ b/src/data/extra/web/js/graphpreviewer.js @@ -143,7 +143,7 @@ class GraphPreviewer { p_dataSetter = this.setGraphPreviewData.bind(this); } if (!p_svgNode) { - console.error('failed to preview graph', p_id, p_timeStamp); + console.warn('failed to preview graph', p_id, p_timeStamp); p_dataSetter(p_id, p_timeStamp); return; } @@ -182,6 +182,10 @@ class GraphPreviewer { // Fix SVG with width and height being '100%'. fixSvgRelativeWidth(p_svgNode) { + if (!p_svgNode) { + return; + } + if (p_svgNode.getAttribute('width').indexOf('%') != -1) { // Try maxWidth. if (p_svgNode.style.maxWidth && p_svgNode.style.maxWidth.endsWith('px')) { diff --git a/src/data/extra/web/js/markdown-it/markdown-it-texmath.js b/src/data/extra/web/js/markdown-it/markdown-it-texmath.js index 6d28ba9e..30e69132 100644 --- a/src/data/extra/web/js/markdown-it/markdown-it-texmath.js +++ b/src/data/extra/web/js/markdown-it/markdown-it-texmath.js @@ -186,19 +186,19 @@ texmath.$_post = (str,end) => { texmath.rules = { brackets: { inline: [ - { name: 'math_inline', + { name: 'math_brackets_inline', rex: /\\\((.+?)\\\)/gy, tmpl: '$1', tag: '\\(' } ], block: [ - { name: 'math_block_eqno', + { name: 'math_brackets_block_eqno', rex: /\\\[(((?!\\\]|\\\[)[\s\S])+?)\\\]\s*?\(([^)$\r\n]+?)\)\s*$/gmy, tmpl: '
$1($2)
', tag: '\\[' }, - { name: 'math_block', + { name: 'math_brackets_block', rex: /\\\[([\s\S]+?)\\\]\s*$/gmy, tmpl: '
$1
', tag: '\\[' @@ -207,19 +207,19 @@ texmath.rules = { }, gitlab: { inline: [ - { name: 'math_inline', + { name: 'math_gitlab_inline', rex: /\$`(.+?)`\$/gy, tmpl: '$1', tag: '$`' } ], block: [ - { name: 'math_block_eqno', + { name: 'math_gitlab_block_eqno', rex: /`{3}math\s*([^`]+?)\s*?`{3}\s*\(([^)\r\n]+?)\)/gm, tmpl: '
$1($2)
', tag: '```math' }, - { name: 'math_block', + { name: 'math_gitlab_block', rex: /`{3}math\s*([^`]*?)\s*`{3}/gm, tmpl: '
$1
', tag: '```math' @@ -228,12 +228,12 @@ texmath.rules = { }, julia: { inline: [ - { name: 'math_inline', + { name: 'math_julia_inline', rex: /`{2}([^`]+?)`{2}/gy, tmpl: '$1', tag: '``' }, - { name: 'math_inline', + { name: 'math_julia_inline', rex: /\$((?:\S?)|(?:\S.*?\S))\$/gy, tmpl: '$1', tag: '$', @@ -242,12 +242,12 @@ texmath.rules = { } ], block: [ - { name: 'math_block_eqno', + { name: 'math_julia_block_eqno', rex: /`{3}math\s+?([^`]+?)\s+?`{3}\s*?\(([^)$\r\n]+?)\)\s*$/gmy, tmpl: '
$1($2)
', tag: '```math' }, - { name: 'math_block', + { name: 'math_julia_block', rex: /`{3}math\s+?([^`]+?)\s+?`{3}\s*$/gmy, tmpl: '
$1
', tag: '```math' @@ -256,19 +256,19 @@ texmath.rules = { }, kramdown: { inline: [ - { name: 'math_inline', + { name: 'math_kramdown_inline', rex: /\${2}(.+?)\${2}/gy, tmpl: '$1', tag: '$$' } ], block: [ - { name: 'math_block_eqno', + { name: 'math_kramdown_block_eqno', rex: /\${2}([^$]+?)\${2}\s*?\(([^)\s]+?)\)\s*$/gmy, tmpl: '
$1($2)
', tag: '$$' }, - { name: 'math_block', + { name: 'math_kramdown_block', rex: /\${2}([^$]+?)\${2}\s*$/gmy, tmpl: '
$1
', tag: '$$' @@ -277,7 +277,7 @@ texmath.rules = { }, dollars: { inline: [ - { name: 'math_inline_double', + { name: 'math_dollars_inline_double', rex: /\${2}((?:\S)|(?:\S.*?\S))\${2}/gy, tmpl: '
$1
', tag: '$$', @@ -285,7 +285,7 @@ texmath.rules = { pre: texmath.$_pre, post: texmath.$_post }, - { name: 'math_inline', + { name: 'math_dollars_inline', rex: /\$((?:\S)|(?:\S.*?\S))\$/gy, tmpl: '$1', tag: '$', @@ -294,13 +294,13 @@ texmath.rules = { } ], block: [ - { name: 'math_block_eqno', - rex: /\${2}([^$]+?)\${2}\s*?\(([^)\s]+?)\)\s*$/gmy, + { name: 'math_dollars_block_eqno', + rex: /\${2}((?:[^$]|\$(?!\$))+?)\${2}\s*?\(([^)\s]+?)\)\s*$/gmy, tmpl: '
$1($2)
', tag: '$$' }, - { name: 'math_block', - rex: /\${2}([^$]+?)\${2}\s*$/gmy, + { name: 'math_dollars_block', + rex: /\${2}((?:[^$]|\$(?!\$))+?)\${2}\s*$/gmy, tmpl: '
$1
', tag: '$$' } @@ -310,7 +310,7 @@ texmath.rules = { inline: [], block: [ { - name: 'math_block', + name: 'math_raw_block', rex: /(\\begin\s*\{([^{}\s\r\n]+)\}(?:[^\\]|\\(?!end\s*\{\2\}))*\\end\s*\{\2\})\s*$/gmy, tmpl: '
$1
', tag: '\\begin' diff --git a/src/data/extra/web/js/markdownit.js b/src/data/extra/web/js/markdownit.js index a323ea64..ae6e80c2 100644 --- a/src/data/extra/web/js/markdownit.js +++ b/src/data/extra/web/js/markdownit.js @@ -164,7 +164,7 @@ class MarkdownIt extends VxWorker { this.mdit.use(window['markdown-it-imsize.js']); - this.mdit.use(texmath, { delimiters: ['dollars', 'raw'] }); + this.mdit.use(texmath, { delimitersList: ['dollars', 'raw'] }); // Support '::: alert-xxx \n contents \n :::\n'. this.mdit.use(window.markdownitContainer, 'alert', { diff --git a/src/data/extra/web/js/mathjax.js b/src/data/extra/web/js/mathjax.js index 3ef770b8..32c9519d 100644 --- a/src/data/extra/web/js/mathjax.js +++ b/src/data/extra/web/js/mathjax.js @@ -178,6 +178,8 @@ class MathJaxRenderer extends VxWorker { display = true; } else if (text.startsWith('$') && text.endsWith('$')) { text = text.substring(1, text.length - 1); + } else if (text.match(/^\\begin\s*\{\S+}[\s\S]+\\end\s*\{\S+\}$/)) { + display = true; } else { return null; } diff --git a/src/widgets/markdownviewwindow.cpp b/src/widgets/markdownviewwindow.cpp index 474bd4b9..680af137 100644 --- a/src/widgets/markdownviewwindow.cpp +++ b/src/widgets/markdownviewwindow.cpp @@ -131,10 +131,6 @@ void MarkdownViewWindow::setModeInternal(ViewWindowMode p_mode, bool p_syncBuffe case ViewWindowMode::Edit: { - if (m_debugViewer && m_debugViewer->isVisible()) { - toggleDebug(); - } - if (!m_editor) { // We need viewer to preview. if (!m_viewer) { @@ -325,13 +321,7 @@ void MarkdownViewWindow::setupToolBar() addAction(toolBar, ViewWindowToolBarHelper::FindAndReplace); addAction(toolBar, ViewWindowToolBarHelper::Print); - { - auto act = addAction(toolBar, ViewWindowToolBarHelper::Debug); - connect(this, &ViewWindow::modeChanged, - this, [this, act]() { - act->setEnabled(m_mode == ViewWindowMode::Read || m_editViewMode != MarkdownEditorConfig::EditViewMode::EditOnly); - }); - } + addAction(toolBar, ViewWindowToolBarHelper::Debug); } void MarkdownViewWindow::setupTextEditor()