fsavje / math-with-slack

Rendered math (MathJax) with Slack's desktop client
MIT License
431 stars 62 forks source link

Just in case anyone would like to use this within Rambox #23

Open ghennequin opened 6 years ago

ghennequin commented 6 years ago

Rambox (http://rambox.pro) lets you aggregate all your favorite messaging apps into one big app that unifies handling of notifications etc (similar to Franz, but open source). If you want to use math-with-slack in Rambox, simply add the following code in the "Custom code" box you will be presented within "Advanced" config when you add your slack service (this is merely copy/pasted from math-with-slack.sh found in this repo - I've removed the document.addEventListener wrapper because Rambox automatically adds this as an DOMContentLoaded event listener):

var mathjax_config = document.createElement('script');
mathjax_config.type = 'text/x-mathjax-config';
mathjax_config.text = `
  MathJax.Hub.Config({
    messageStyle: 'none',
    extensions: ['tex2jax.js'],
    jax: ['input/TeX', 'output/HTML-CSS'],
    tex2jax: {
      displayMath: [['$$', '$$']],
      element: 'msgs_div',
      ignoreClass: 'ql-editor',
      inlineMath: [['$', '$']],
      processEscapes: true,
      skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    },
    TeX: {
      extensions: ['AMSmath.js', 'AMSsymbols.js', 'noErrors.js', 'noUndefined.js']
    }
  });
`;
var mathjax_script = document.createElement('script');
mathjax_script.type = 'text/javascript';
mathjax_script.src = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js';
document.head.appendChild(mathjax_config);
document.head.appendChild(mathjax_script);

var target = document.querySelector('#msgs_div');
var options = { attributes: false, childList: true, characterData: true, subtree: true };
var observer = new MutationObserver(function (r, o) { MathJax.Hub.Queue(['Typeset', MathJax.Hub]); });
observer.observe(target, options);
ghennequin commented 6 years ago

(maybe that would be a useful addition to README.md (will probably get lost if it remains a repo "issue", which it really isn't)

JZZQuant commented 5 years ago

Hi ism wondering can something like this be done with hangouts chat desktop app as well