Merge branch 'wbr'
This commit is contained in:
commit
66da272698
@ -25,27 +25,20 @@ Fourchan =
|
|||||||
cb: @code
|
cb: @code
|
||||||
|
|
||||||
if g.BOARD.ID is 'sci'
|
if g.BOARD.ID is 'sci'
|
||||||
$.globalEval '''
|
$.global ->
|
||||||
window.addEventListener('mathjax', function(e) {
|
window.addEventListener 'mathjax', (e) ->
|
||||||
if (window.MathJax) {
|
if window.MathJax
|
||||||
window.MathJax.Hub.Queue(function() {
|
window.MathJax.Hub.Queue ['Typeset', window.MathJax.Hub, e.target]
|
||||||
if (!e.target.querySelector('.MathJax')) {
|
else
|
||||||
window.MathJax.Hub.Typeset(e.target);
|
unless document.querySelector 'script[src^="//cdn.mathjax.org/"]' # don't load MathJax if already loading
|
||||||
}
|
window.loadMathJax()
|
||||||
});
|
window.loadMathJax = ->
|
||||||
} else {
|
# 4chan only handles post comments on MathJax load; anything else (e.g. the QR preview) must be queued explicitly.
|
||||||
if (!document.querySelector('script[src^="//cdn.mathjax.org/"]')) {
|
unless e.target.classList.contains 'postMessage'
|
||||||
window.loadMathJax();
|
document.querySelector('script[src^="//cdn.mathjax.org/"]').addEventListener 'load', ->
|
||||||
window.loadMathJax = function() {};
|
window.MathJax.Hub.Queue ['Typeset', window.MathJax.Hub, e.target]
|
||||||
if (!e.target.classList.contains('postMessage')) {
|
, false
|
||||||
document.querySelector('script[src^="//cdn.mathjax.org/"]').addEventListener('load', function() {
|
, false
|
||||||
window.MathJax.Hub.Queue(['Typeset', window.MathJax.Hub, e.target]);
|
|
||||||
}, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, false);
|
|
||||||
'''
|
|
||||||
Post.callbacks.push
|
Post.callbacks.push
|
||||||
name: 'Parse /sci/ math'
|
name: 'Parse /sci/ math'
|
||||||
cb: @math
|
cb: @math
|
||||||
@ -69,7 +62,9 @@ Fourchan =
|
|||||||
return
|
return
|
||||||
|
|
||||||
math: ->
|
math: ->
|
||||||
return unless /\[(math|eqn)\]/.test(@nodes.comment.textContent) or $('.math:not([id])', @nodes.comment)
|
return unless /\[(math|eqn)\]/.test @nodes.comment.textContent
|
||||||
|
# XXX <wbr> tags frequently break MathJax; remove them.
|
||||||
|
$.rm wbr for wbr in $$ 'wbr', @nodes.comment
|
||||||
cb = =>
|
cb = =>
|
||||||
return unless doc.contains @nodes.comment
|
return unless doc.contains @nodes.comment
|
||||||
$.off d, 'PostsInserted', cb
|
$.off d, 'PostsInserted', cb
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user