This time I will share jQuery Plugin and tutorial about Markdown and LaTeX Compatible Text Editor – Writing.js, hope it will help you in programming stack.
Writing is a simple, lightweight online text editor that supports both Markdown and LaTeX syntax. Implemented in jQuery, JavaScript and CSS.
The text editor is designed to be lightweight and, unlike some other similar solutions, fast to display (no delay when writing, no flickering when writing math), as close as possible to the math.stackexchange.com editor.
Commands:
- CTRL + D: toggle display mode (editor only, preview only or both-at-the-same-time)
- CTRL + P: print or export as PDF
- CTRL + S: save source code as .MD file
- CTRL + SHIFT + L: enable / disable LaTeX (i.e. math formulas)
- CTRL + SHIFT + R: toggle roman (LaTex-like) or sans-serif font
- CTRL + SHIFT + H: show this help dialog
- F11: full-screen (in most browsers)
How to use it:
1. Load JavaScript library and other required resources in the html document.
1 |
< script src = "Markdown.Converter.js" ></ script > |
2 |
< script src = "Markdown.Sanitizer.js" ></ script > |
3 |
< script src = "Markdown.Editor.js" ></ script > |
4 |
< script src = "Markdown.Extra.js" ></ script > |
5 |
< script src = "//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_HTML-full" ></ script > |
6 |
< script src = "mathjax-editing_writing.js" ></ script > |
7 |
< script src = "//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js" ></ script > |
2. Create the html for the text editor. Write text on the left, and the result is displayed on the right.
01 |
< div id = "wmd-button-bar" class = "wmd-button-bar" ></ div > |
02 |
< textarea id = "wmd-input" class = "column wmd-input" spellcheck = "false" ></ textarea > |
03 |
< div id = "wmd-preview" class = "column wmd-preview" > |
04 |
< noscript >This text editor requires JavaScript.</ noscript > |
06 |
< div id = "helpicon" class = "unselectable" >?</ div > |
08 |
< div id = "closeicon" class = "unselectable" >X</ div > |
3. The CSS to style the editor.
009 |
-webkit-touch-callout: none ; |
010 |
-webkit-user-select: none ; |
011 |
-khtml-user-select: none ; |
012 |
-moz-user-select: none ; |
013 |
-ms-user-select: none ; |
017 |
.fixedheight { height : 100% ; } |
019 |
.column { padding : 20px ; } |
021 |
#wmd-button-bar { display : none ; } |
025 |
box-sizing: border-box; |
029 |
border-right : 1px solid #ddd ; |
039 |
box-sizing: border-box; |
042 |
#wmd-preview li { margin-left : 20px ; } |
044 |
#wmd-preview code , #wmd-input { font-family : Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace , sans-serif ; } |
046 |
#wmd-preview p code , #wmd-preview li code { |
047 |
background-color : #f5f5f5 ; |
048 |
white-space : pre-wrap; |
054 |
background-color : #f5f5f5 ; |
062 |
#wmd-preview blockquote { |
063 |
background-color : #defcff ; |
068 |
border-left : 2px solid #0ae2f5 ; |
071 |
#wmd-preview blockquote p { margin-bottom : 0 ; } |
074 |
background-color : #ddd ; |
075 |
color : #ddd ;
source : jqueryscript.net
|