bug fixes
This commit is contained in:
parent
0ff9d65675
commit
84d7bfc02f
|
@ -24,6 +24,12 @@ function ensureMathJax(){
|
|||
|
||||
function decorate(elem, isPreview){
|
||||
const $elem= $(elem);
|
||||
|
||||
if ($elem.data('applied-mathjax')){
|
||||
return;
|
||||
}
|
||||
$elem.data('applied-mathjax', true);
|
||||
|
||||
const tag = elem.tagName === "DIV" ? "div" : "span";
|
||||
const display = tag === "div" ? "; mode=display" : "";
|
||||
|
||||
|
@ -36,7 +42,7 @@ function decorate(elem, isPreview){
|
|||
Em.run.later(this, ()=> {
|
||||
window.MathJax.Hub.Queue(() => {
|
||||
// don't bother processing previews removed from DOM
|
||||
if (elem.parentElement.offsetParent !== null) {
|
||||
if (elem.parentElement && elem.parentElement.offsetParent !== null) {
|
||||
window.MathJax.Hub.Typeset($math[0], ()=> {
|
||||
$elem.remove();
|
||||
$mathWrapper.show();
|
||||
|
@ -51,6 +57,7 @@ function mathjax($elem) {
|
|||
|
||||
if (mathElems.length > 0) {
|
||||
const isPreview = $elem.hasClass('d-editor-preview');
|
||||
|
||||
ensureMathJax().then(()=>{
|
||||
mathElems.each((idx,elem) => decorate(elem, isPreview));
|
||||
});
|
||||
|
|
|
@ -59,7 +59,7 @@ function inlineMath(state, silent) {
|
|||
|
||||
if (found+1 <= posMax) {
|
||||
let next = state.src.charCodeAt(found+1);
|
||||
if (!isSafeBoundary(next, state.md)) {
|
||||
if (next && !isSafeBoundary(next, state.md)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,12 +31,13 @@ describe PrettyText do
|
|||
end
|
||||
|
||||
it 'can handle inline edge cases' do
|
||||
expect(PrettyText.cook ",$+500\\$").not_to include('math')
|
||||
expect(PrettyText.cook "$+500$").to include('math')
|
||||
expect(PrettyText.cook ",$+500$,").to include('math')
|
||||
expect(PrettyText.cook "200$ + 500$").not_to include('math')
|
||||
expect(PrettyText.cook ",$+500\$x").not_to include('math')
|
||||
expect(PrettyText.cook "y$+500\$").not_to include('math')
|
||||
expect(PrettyText.cook ",$+500$x").not_to include('math')
|
||||
expect(PrettyText.cook "y$+500$").not_to include('math')
|
||||
expect(PrettyText.cook "($ +500 $)").to include('math')
|
||||
expect(PrettyText.cook ",$+500\$").not_to include('math')
|
||||
end
|
||||
|
||||
it 'can handle inline math' do
|
||||
|
|
Loading…
Reference in New Issue