Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Merge Development branch into Master #4

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
63 changes: 59 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,73 @@
previewRender: markjax
});
```

And of course you can still write and use LaTeX:
$$\sum_{n=1}^{\infty} 2^{-n} = 1$$
</textarea>

<script>
function getCursorCoordinates() {
var cursorLine = simplemde.codemirror.getCursor()["line"];
var cursorCh = simplemde.codemirror.getCursor()["ch"];

return { line: cursorLine, ch: cursorCh };
}

function insertAfterCursor(string, len) {
simplemde.codemirror.doc.replaceRange(string, getCursorCoordinates());

var cursorCoordinates = getCursorCoordinates();
simplemde.codemirror.setCursor({ line: cursorCoordinates.line, ch: cursorCoordinates.ch - len });

simplemde.codemirror.focus();
}

var simplemde = new SimpleMDE({
previewRender: markjax,
previewRender: function(plainText, preview) {
setTimeout(function() {
markjax(plainText, preview);
}, 50);
return preview.innerHTML;
},
spellChecker: false,
indentWithTabs: false
indentWithTabs: false,
toolbar: [
"bold",
"italic",
"heading",
"|",
{
name: "inlineMath",
action: function inlineMath(editor) {
insertAfterCursor("$$", 1)
},
className: "fa fa-bar-chart-o",
title: "Inline Latex Expression"
},
{
name: "mathBlock",
action: function mathBlock(editor) {
insertAfterCursor("$$$$", 2)
},
className: "fa fa-area-chart",
title: "Latex Expression Block"
},
"|",
"quote",
"unordered-list",
"ordered-list",
"|",
"link",
"image",
"|",
"preview",
"side-by-side",
"fullscreen",
"|",
"guide"
]
});
SimpleMDE.toggleSideBySide(simplemde);
simplemde.toggleSideBySide(simplemde);
</script>
</body>
</html>