Skip to content

Commit

Permalink
Merge pull request #37 from ntadej/legacy-dialects
Browse files Browse the repository at this point in the history
Support older versions of Discourse
  • Loading branch information
kasperpeulen authored Jan 15, 2017
2 parents 80a5810 + d4b751a commit 6b7ca80
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
69 changes: 69 additions & 0 deletions assets/javascripts/tex_dialect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
(function() {
// Don't bother with this code if the new dialect system is present
if (Discourse.dialect_deprecated) { return; }

Discourse.Dialect.inlineBetween({
start: '\\(',
stop: '\\)',
rawContents: true,
emitter: function (contents) {
return '\\(' + contents + '\\)';
}
});

Discourse.Dialect.inlineBetween({
start: '\\[',
stop: '\\]',
rawContents: true,
emitter: function (contents) {
return '\\[' + contents + '\\]';
}
});

Discourse.Dialect.inlineBetween({
start: '$$',
stop: '$$',
rawContents: true,
emitter: function (contents) {
return '$$' + contents + '$$';
}
});


Discourse.Dialect.inlineBetween({
start: '$',
stop: '$',
rawContents: true,
emitter: function (contents) {
return '$' + contents + '$';
}
});

Discourse.Dialect.inlineRegexp({
start: '\\begin',
matcher: /(\\begin{[\S\s]+})([\S\s]*)(\\end{[\S\s]+})/,
emitter: function (matches) {
return matches[0];
}
});

//these last two are to make asciimath support possible

Discourse.Dialect.inlineBetween({
start: 'ˊˊ',
stop: 'ˊˊ',
rawContents: true,
emitter: function (contents) {
return 'ˊˊ' + contents + 'ˊˊ';
}
});

Discourse.Dialect.inlineBetween({
start: 'ˊ',
stop: 'ˊ',
rawContents: true,
emitter: function (contents) {
return 'ˊ' + contents + 'ˊ';
}
});
})();
2 changes: 2 additions & 0 deletions plugin.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# name: MathJax support for Discourse
# version: 0.4.1
# authors: Sam Saffron, Kasper Peulen

register_asset('javascripts/tex_dialect.js', :server_side)

0 comments on commit 6b7ca80

Please sign in to comment.