mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-12-02 12:45:09 +08:00
fix(mermaid): escape closing body/html tags in inline script template
The htmlSource template literal in mermaid.pug is rendered as an inline
<script> block and contains a raw </body>. Hexo's injector replaces the
first </body> in the document for body_end entries, so any plugin script
injected via hexo.extend.injector('body_end') lands inside this script
and its </script> terminates the inline script early (SyntaxError:
Unexpected end of input), breaking Mermaid rendering and all subsequent
inline scripts on the page.
Escape the closing tags to <\/body><\/html> (a no-op for the generated
string) so the inline script carries no raw </body> and body_end
injection lands at the real document end again.
Fixes jerryc127/hexo-theme-butterfly#1832
This commit is contained in:
1 parent
ebfe9f4000
commit
31614c36e9
1 file changed
+1
-1
+1
-1
@@ -66,7 +66,7 @@ script.
|
||||
html, body { width: 100%; height: 100%; margin: 0; display: flex; align-items: center; justify-content: center; background: ${bg}; }
|
||||
svg { max-width: 100%; max-height: 100%; height: auto; width: auto; }
|
||||
</style>
|
||||
</head><body>${svgSource}</body></html>`
|
||||
</head><body>${svgSource}<\/body><\/html>`
|
||||
const blob = new Blob([htmlSource], { type: 'text/html;charset=utf-8' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
window.open(url, '_blank', 'noopener')
|
||||
|
||||
Reference in new issue
Block a user