Browse Source

Releases v1.1.9

v1.1.9
Pandao 10 years ago
parent
commit
3724fd14a2
  1. 12
      CHANGE.md
  2. 7
      README.md
  3. 2
      bower.json
  4. 4
      dist/css/editormd.css
  5. 4
      dist/css/editormd.css.map
  6. 2
      dist/css/editormd.css.min.map
  7. 4
      dist/css/editormd.logo.css
  8. 4
      dist/css/editormd.logo.css.map
  9. 2
      dist/css/editormd.logo.css.min.map
  10. 2
      dist/css/editormd.logo.min.css
  11. 2
      dist/css/editormd.min.css
  12. 4
      dist/css/editormd.preview.css
  13. 4
      dist/css/editormd.preview.css.map
  14. 2
      dist/css/editormd.preview.css.min.map
  15. 2
      dist/css/editormd.preview.min.css
  16. 57
      dist/js/editormd.js
  17. 6
      dist/js/editormd.min.js
  18. 4
      dist/js/languages/en.js
  19. 2
      dist/js/languages/en.min.js
  20. 4
      dist/js/languages/zh-tw.js
  21. 2
      dist/js/languages/zh-tw.min.js
  22. 8
      docs/html/index.html
  23. 32
      examples/test.md
  24. 4
      examples/toc.html
  25. 2
      lib/codemirror/addons.min.js
  26. 2
      lib/codemirror/modes.min.js
  27. 2
      package.json
  28. 53
      src/js/editormd.js
  29. 138
      tests/marked-heading-link-test.html

12
CHANGE.md

@ -196,4 +196,14 @@
- 改进[#28](https://github.com/pandao/editor.md/issues/28);
- 将`jquery.min.js`、`font-awesome.min.css`、`github-markdown.css`移除(这是一个疏忽,它们不是动态加载的依赖模块或者不需要的,避免不必要的硬盘空间占用);
- 修改了所有相关的示例文件;
- 修改了所有相关的示例文件;
#####v1.1.9
- 修复无法解析heading link的Bug[#29](https://github.com/pandao/editor.md/issues/29);
- 修改了`editormd.markedRenderer()`方法的内部实现;
- 新增了`editormd.trim()`,用于清除字符串两边的空格;
- 修改了所有相关的示例文件和测试用例`marked-heading-link-test.html`;
- 修改了`README.md`,添加了`Shields.io`图标;

7
README.md

@ -2,6 +2,13 @@
![](https://pandao.github.io/editor.md/dist/images/logos/editormd-logo-180x180.png)
![](https://img.shields.io/github/stars/pandao/editor.md.svg)
![](https://img.shields.io/github/forks/pandao/editor.md.svg)
![](https://img.shields.io/github/tag/pandao/editor.md.svg)
![](https://img.shields.io/github/release/pandao/editor.md.svg)
![](https://img.shields.io/github/issues/pandao/editor.md.svg)
![](https://img.shields.io/bower/v/editor.md.svg)
**Editor.md** is an online(In-browser) markdown editor, based on CodeMirror & jQuery.
###Features

2
bower.json

@ -1,6 +1,6 @@
{
"name": "editor.md",
"version": "1.1.8",
"version": "1.1.9",
"homepage": "https://github.com/pandao/editor.md",
"authors": [
"Pandao <pandao@vip.qq.com>"

4
dist/css/editormd.css

@ -1,12 +1,12 @@
/*
* Editor.md
* @file editormd.css
* @version v1.1.8
* @version v1.1.9
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-03-03
* @updateTime 2015-03-04
*/
@charset "UTF-8";

4
dist/css/editormd.css.map

@ -1,12 +1,12 @@
/*
* Editor.md
* @file editormd.css.map
* @version v1.1.8
* @version v1.1.9
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-03-03
* @updateTime 2015-03-04
*/
{

2
dist/css/editormd.css.min.map

File diff suppressed because one or more lines are too long

4
dist/css/editormd.logo.css

@ -1,12 +1,12 @@
/*
* Editor.md
* @file editormd.logo.css
* @version v1.1.8
* @version v1.1.9
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-03-03
* @updateTime 2015-03-04
*/
@font-face {

4
dist/css/editormd.logo.css.map

@ -1,12 +1,12 @@
/*
* Editor.md
* @file editormd.logo.css.map
* @version v1.1.8
* @version v1.1.9
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-03-03
* @updateTime 2015-03-04
*/
{

2
dist/css/editormd.logo.css.min.map

@ -1,2 +1,2 @@
/*! Editor.md v1.1.8 | editormd.logo.css.min.map | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-03-03 */
/*! Editor.md v1.1.9 | editormd.logo.css.min.map | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-03-04 */
{"version":3,"mappings":"AAKA,UASC;EARA,WAAW,EAAE,eAAe;EAC5B,GAAG,EAAC,yCAAyC;EAC7C,GAAG,EAAC,sQAA4E;EAIhF,WAAW,EAAE,MAAM;EACnB,UAAU,EAAE,MAAM;;AAGnB,cAAe;EACd,WAAW,EAAE,eAAe;EAC5B,KAAK,EAAE,IAAI;EACX,UAAU,EAAE,MAAM;EAClB,WAAW,EAAE,MAAM;EACnB,YAAY,EAAE,MAAM;EACpB,cAAc,EAAE,IAAI;EACjB,SAAS,EAAE,OAAO;EACrB,WAAW,EAAE,CAAC;EACX,OAAO,EAAE,YAAY;EACrB,cAAc,EAAE,IAAI;EACpB,cAAc,EAAE,OAAO;EAG1B,sBAAsB,EAAE,WAAW;EACnC,uBAAuB,EAAE,SAAS;;AAE/B,qBAAS;EACL,OAAO,EAAE,QAAQ;;;;;;;AAQzB,iBAAkB;EACd,SAAS,EAAE,GAAG;;;AAGlB,iBAAkB;EACd,SAAS,EAAE,KAAK;;;AAGpB,iBAAkB;EACd,SAAS,EAAE,GAAG;;;AAGlB,iBAAkB;EACd,SAAS,EAAE,GAAG;;;AAGlB,iBAAkB;EACd,SAAS,EAAE,GAAG;;;AAGlB,iBAAkB;EACd,SAAS,EAAE,GAAG;;;AAGlB,iBAAkB;EACd,SAAS,EAAE,GAAG;;;AAGlB,iBAAkB;EACd,SAAS,EAAE,GAAG;;;AAGlB,iBAAkB;EACd,SAAS,EAAE,GAAG;;;AAGlB,oBAAqB;EACjB,KAAK,ECxEO,OAAU","sources"["../editormd.logo.scss","file:///D:/APMServ/www/htdocs/editor.md/src/scss/lib/variables.scss"],"names"[],"file":"editormd.logo.css"}

2
dist/css/editormd.logo.min.css

@ -1,2 +1,2 @@
/*! Editor.md v1.1.8 | editormd.logo.min.css | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-03-03 */
/*! Editor.md v1.1.9 | editormd.logo.min.css | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-03-04 */
@font-face{font-family:editormd-logo;src:url(../fonts/editormd-logo.eot?-5y8q6h);src:url(.../fonts/editormd-logo.eot?#iefix-5y8q6h) format("embedded-opentype"),url(../fonts/editormd-logo.woff?-5y8q6h) format("woff"),url(../fonts/editormd-logo.ttf?-5y8q6h) format("truetype"),url(../fonts/editormd-logo.svg?-5y8q6h#icomoon) format("svg");font-weight:400;font-style:normal}.editormd-logo{font-family:editormd-logo;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;font-size:inherit;line-height:1;display:inline-block;text-rendering:auto;vertical-align:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.editormd-logo:before{content:"\e1987"}.editormd-logo-1x{font-size:1em}.editormd-logo-lg{font-size:1.2em}.editormd-logo-2x{font-size:2em}.editormd-logo-3x{font-size:3em}.editormd-logo-4x{font-size:4em}.editormd-logo-5x{font-size:5em}.editormd-logo-6x{font-size:6em}.editormd-logo-7x{font-size:7em}.editormd-logo-8x{font-size:8em}.editormd-logo-color{color:#2196F3}

2
dist/css/editormd.min.css

@ -1,4 +1,4 @@
/*! Editor.md v1.1.8 | editormd.min.css | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-03-03 */
/*! Editor.md v1.1.9 | editormd.min.css | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-03-04 */
@charset "UTF-8";/*!
* Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome
* License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)

4
dist/css/editormd.preview.css

@ -1,12 +1,12 @@
/*
* Editor.md
* @file editormd.preview.css
* @version v1.1.8
* @version v1.1.9
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-03-03
* @updateTime 2015-03-04
*/
/*! github-markdown-css | The MIT License (MIT) | Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) | https://github.com/sindresorhus/github-markdown-css */

4
dist/css/editormd.preview.css.map

@ -1,12 +1,12 @@
/*
* Editor.md
* @file editormd.preview.css.map
* @version v1.1.8
* @version v1.1.9
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-03-03
* @updateTime 2015-03-04
*/
{

2
dist/css/editormd.preview.css.min.map

File diff suppressed because one or more lines are too long

2
dist/css/editormd.preview.min.css

File diff suppressed because one or more lines are too long

57
dist/js/editormd.js

@ -1,18 +1,18 @@
/*
* Editor.md
* @file editormd.js
* @version v1.1.8
* @version v1.1.9
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-03-03
* @updateTime 2015-03-04
*/
/**
* @fileOverview Editor.md
* @author pandao
* @version 1.1.8
* @version 1.1.9
*/
;(function(factory) {
@ -55,7 +55,7 @@
};
editormd.title = editormd.$name = "Editor.md";
editormd.version = "1.1.8";
editormd.version = "1.1.9";
editormd.homePage = "https://pandao.github.io/editor.md/";
editormd.classPrefix = "editormd-";
@ -2101,7 +2101,7 @@
clear : function() {
this.codeEditor.setValue("");
return this;
return this;
},
/**
@ -2430,6 +2430,18 @@
editormd.fn.init.prototype = editormd.fn;
/**
* 清除字符串两边的空格
* @param {String} str string
* @returns {String} trim string
*/
editormd.trim = function(str) {
return (!String.prototype.trim) ? str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '') : str.trim();
};
var trim = editormd.trim;
/**
* 自定义marked的解析器
* @param {Array} markdownToC 传入用于接收TOC的数组
@ -2442,21 +2454,46 @@
markdownToC = markdownToC || [];
markedRenderer.heading = function(text, level, raw) {
var linkText = text;
var hasLinkReg = /\s*\<a\s*href\=\"(.*)\"\s*([^\>]*)\>(.*)\<\/a\>\s*/;
var getLinkTextReg = /\s*\<a\s*([^\>]+)\>([^\>]*)\<\/a\>\s*/g;
if (hasLinkReg.test(text))
{
var tempText = [];
text = text.split(/\<a\s*([^\>]+)\>([^\>]*)\<\/a\>/);
for (var i = 0, len = text.length; i < len; i++)
{
tempText.push(text[i].replace(/\s*href\=\"(.*)\"\s*/g, ""));
}
text = tempText.join(" ");
}
text = trim(text);
var escapedText = text.toLowerCase().replace(/[^\w]+/g, "-");
var toc = {
text : text,
text : text,
level : level,
slug : escapedText
};
var isChinese = /^[\u4e00-\u9fa5]+$/.test(text);
var id = (isChinese) ? escape(text).replace(/\%/g, "") : text.toLowerCase().replace(/[^\w]+/g, "-");
var id = (isChinese) ? escape(text).replace(/\%/g, "") : text.toLowerCase().replace(/[^\w]+/g, "-");
markdownToC.push(toc);
var headingHTML = "<h" + level + " id=\"h"+ level + "-" + this.options.headerPrefix + id +"\">";
headingHTML += "<a name=\"" + text + "\" class=\"anchor\"></a>";
headingHTML += "<span class=\"header-link octicon octicon-link\"></span>";
headingHTML += (hasLinkReg) ? linkText : text;
headingHTML += "</h" + level + ">";
return "<h" + level + " id=\"h"+ level + "-" + this.options.headerPrefix + id +"\">" +
"<a href=\"#" + text + "\" name=\"" + text + "\" class=\"anchor\"></a>" +
"<span class=\"header-link\"></span>" + text + "</h" + level + ">";
return headingHTML;
};
markedRenderer.paragraph = function(text) {

6
dist/js/editormd.min.js

File diff suppressed because one or more lines are too long

4
dist/js/languages/en.js

@ -1,12 +1,12 @@
/*
* Editor.md
* @file languages\en.js
* @version v1.1.8
* @version v1.1.9
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-03-03
* @updateTime 2015-03-04
*/
(function(){

2
dist/js/languages/en.min.js

@ -1,2 +1,2 @@
/*! Editor.md v1.1.8 | languages\en.min.js | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-03-03 */
/*! Editor.md v1.1.9 | languages\en.min.js | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-03-04 */
!function(){var e=function(e){var t={name:"en",description:"A simple markdown doucment online editor.",toolbar:{undo:"Undo(Ctrl+Z)",redo:"Redo(Ctrl+Y)",bold:"Bold",del:"Strikethrough",italic:"Italic",quote:"Block quote",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6","list-ul":"Unordered list","list-ol":"Ordered list",hr:"Horizontal line",link:"Link",anchor:"Anchor",image:"Image",code:"Code inline","code-block-tab":"Preformatted text / Code block (Tab indent)","code-block":"Code block (Multi-languages)",datetime:"Datetime",watch:"Unwatch",unwatch:"Watch",preview:"HTML Preview (Enter ESC exit)",fullscreen:"Fullscreen (Enter ESC exit)",clear:"Clear",info:"About "+e.title},buttons:{enter:"Enter",cancel:"Cancel"},dialog:{link:{title:"Link",url:"Address",urlTitle:"Title",urlEmpty:"Error: Please fill in the link address.",titleEmpty:"Error: Please fill in the link title."},anchor:{title:"Anchor link",name:"Name",url:"Address",urlTitle:"Title",nameEmpty:"Error: anchor name can't be empty.",titleEmpty:"Error: Please fill in anchor link title.",urlEmpty:"Error: Please fill in anchor link."},image:{title:"Image",url:"Address",link:"Link",alt:"Title",uploadButton:"Upload",imageURLEmpty:"Error: picture url address can't be empty.",uploadFileEmpty:"Error: upload pictures cannot be empty!",formatNotAllowed:"Error: only allows to upload pictures file, upload allowed image file format:"},tabCodeBlock:{title:"Preformatted text / Codes",codeEmptyAlert:"Error: Please fill in the Preformatted text or content of the codes."},codeBlock:{title:"Code block",selectLabel:"Languages: ",selectDefaultText:"select a code language...",otherLanguage:"Other languages",unselectedLanguageAlert:"Error: Please select the code language.",codeEmptyAlert:"Error: Please fill in the code content."}}};e.defaults.lang=t};"function"==typeof require&&"object"==typeof exports&&"object"==typeof module?module.exports=e:"function"==typeof define?define.amd?define(["editormd"],function(t){e(t)}):define(function(t){var l=t("../editormd");e(l)}):e(window.editormd)}();

4
dist/js/languages/zh-tw.js

@ -1,12 +1,12 @@
/*
* Editor.md
* @file languages\zh-tw.js
* @version v1.1.8
* @version v1.1.9
* @description A simple online markdown editor.
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-03-03
* @updateTime 2015-03-04
*/
(function(){

2
dist/js/languages/zh-tw.min.js

@ -1,2 +1,2 @@
/*! Editor.md v1.1.8 | languages\zh-tw.min.js | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-03-03 */
/*! Editor.md v1.1.9 | languages\zh-tw.min.js | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-03-04 */
!function(){var e=function(e){var t={name:"zh-tw",description:"開源在線Markdown編輯器<br/>A simple markdown doucment online editor.",toolbar:{undo:"撤銷(Ctrl+Z)",redo:"重做(Ctrl+Y)",bold:"粗體",del:"刪除線",italic:"斜體",quote:"引用",h1:"標題1",h2:"標題2",h3:"標題3",h4:"標題4",h5:"標題5",h6:"標題6","list-ul":"無序列表","list-ol":"有序列表",hr:"横线",link:"链接",anchor:"錨點",image:"圖片",code:"行內代碼","code-block-tab":"預格式文本 / 代碼塊(縮進風格)","code-block":"代碼塊(多語言風格)",datetime:"日期時間",watch:"關閉實時預覽",unwatch:"開啟實時預覽",preview:"全窗口預覽HTML(可按ESC還原)",fullscreen:"全屏(可按ESC還原)",clear:"清空",info:"關於"+e.title},buttons:{enter:"確定",cancel:"取消"},dialog:{link:{title:"添加鏈接",url:"鏈接地址",urlTitle:"鏈接標題",urlEmpty:"錯誤:請填寫鏈接地址。",titleEmpty:"錯誤:請填寫鏈接標題。"},anchor:{title:"添加錨點鏈接",name:"錨點名稱",url:"鏈接地址",urlTitle:"鏈接標題",nameEmpty:"錯誤:錨點名稱不能為空。",titleEmpty:"錯誤:請填寫錨點鏈接標題。",urlEmpty:"錯誤:請填寫錨點鏈接地址。"},image:{title:"添加圖片",url:"圖片地址",link:"圖片鏈接",alt:"圖片描述",uploadButton:"本地上傳",imageURLEmpty:"錯誤:圖片地址不能為空。",uploadFileEmpty:"錯誤:上傳的圖片不能為空!",formatNotAllowed:"錯誤:只允許上傳圖片文件,允許上傳的圖片文件格式有:"},tabCodeBlock:{title:"添加預格式文本或代碼塊",codeEmptyAlert:"錯誤:請填寫預格式文本或代碼的內容。"},codeBlock:{title:"添加代碼塊",selectLabel:"代碼語言:",selectDefaultText:"請語言代碼語言",otherLanguage:"其他語言",unselectedLanguageAlert:"錯誤:請選擇代碼所屬的語言類型。",codeEmptyAlert:"錯誤:請填寫代碼內容。"}}};e.defaults.lang=t};"function"==typeof require&&"object"==typeof exports&&"object"==typeof module?module.exports=e:"function"==typeof define?define.amd?define(["editormd"],function(t){e(t)}):define(function(t){var l=t("../editormd");e(l)}):e(window.editormd)}();

8
docs/html/index.html

@ -43,6 +43,12 @@
<section>
<article><h1 id="editor-md">Editor.md</h1>
<p><img src="https://pandao.github.io/editor.md/dist/images/logos/editormd-logo-180x180.png" alt=""></p>
<p><img src="https://img.shields.io/github/stars/pandao/editor.md.svg" alt="">
<img src="https://img.shields.io/github/forks/pandao/editor.md.svg" alt="">
<img src="https://img.shields.io/github/tag/pandao/editor.md.svg" alt="">
<img src="https://img.shields.io/github/release/pandao/editor.md.svg" alt="">
<img src="https://img.shields.io/github/issues/pandao/editor.md.svg" alt="">
<img src="https://img.shields.io/bower/v/editor.md.svg" alt=""></p>
<p><strong>Editor.md</strong> is an online(In-browser) markdown editor, based on CodeMirror &amp; jQuery.</p>
<h3 id="features">Features</h3>
<ul>
@ -134,7 +140,7 @@
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Tue Mar 03 2015 23:29:33 GMT+0800 (中国标准时间)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Wed Mar 04 2015 17:12:36 GMT+0800 (中国标准时间)
</footer>
<script> prettyPrint(); </script>

32
examples/test.md

@ -1,13 +1,25 @@
**目录**
# Editor.md
![](https://pandao.github.io/editor.md/dist/images/logos/editormd-logo-180x180.png)
![](https://img.shields.io/github/stars/pandao/editor.md.svg) ![](https://img.shields.io/github/forks/pandao/editor.md.svg) ![](https://img.shields.io/github/tag/pandao/editor.md.svg) ![](https://img.shields.io/github/release/pandao/editor.md.svg) ![](https://img.shields.io/github/issues/pandao/editor.md.svg) ![](https://img.shields.io/bower/v/editor.md.svg)
**目录 (Table of Contents)**
[TOC]
#Hello world!
##Hello world!
###Hello world!
####Hello world!
#####Hello world!
######Hello world!
#Heading 1
##Heading 2
###Heading 3
####Heading 4
#####Heading 5
######Heading 6
#Heading 1 link [Heading link](https://github.com/pandao/editor.md "Heading link")
##Heading 2 link [Heading link](https://github.com/pandao/editor.md "Heading link")
###Heading 3 link [Heading link](https://github.com/pandao/editor.md "Heading link")
####Heading 4 link [Heading link](https://github.com/pandao/editor.md "Heading link") Heading link [Heading link](https://github.com/pandao/editor.md "Heading link")
#####Heading 5 link [Heading link](https://github.com/pandao/editor.md "Heading link")
######Heading 6 link [Heading link](https://github.com/pandao/editor.md "Heading link")
###字符效果和横线等
@ -190,6 +202,12 @@ Content Cell | Content Cell
| `help()` | Display the help window. |
| `destroy()` | **Destroy your computer!** |
| Left-Aligned | Center Aligned | Right Aligned |
| :------------ |:---------------:| -----:|
| col 3 is | some wordy text | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
| Item | Value |
| --------- | -----:|
| Computer | $1600 |

4
examples/toc.html

@ -28,7 +28,9 @@ Linux是一款免费的操作系统,诞生于1991年,用户可以通过网
它能运行主要的UNIX工具软件、应用程序和网络协议。它支持32位和64位硬件。Linux继承了Unix以网络为核心的设计思想,是一个性能稳 定的多用户网络操作系统。这个系统是由全世界各地的成千上万的程序员设计和实现的。其目的是建立不受任何商品化软件的版权制约的、全世界都能自由使用的 Unix兼容产品。
####linux B
#### Test link heading [linux B](https://github.com/pandao/editor.md) Test link heading
#### Test link heading [linux B](https://github.com/pandao/editor.md) Test link heading [linux B](https://github.com/pandao/editor.md) Test link heading, Test link heading, [linux B](https://github.com/pandao/editor.md) Test link heading
#####linux B-1

2
lib/codemirror/addons.min.js

File diff suppressed because one or more lines are too long

2
lib/codemirror/modes.min.js

File diff suppressed because one or more lines are too long

2
package.json

@ -1,6 +1,6 @@
{
"name": "editor.md",
"version": "1.1.8",
"version": "1.1.9",
"description": "A simple online markdown editor.",
"directories": {
"doc": "docs",

53
src/js/editormd.js

@ -1,7 +1,7 @@
/**
* @fileOverview Editor.md
* @author pandao
* @version 1.1.8
* @version 1.1.9
*/
;(function(factory) {
@ -44,7 +44,7 @@
};
editormd.title = editormd.$name = "Editor.md";
editormd.version = "1.1.8";
editormd.version = "1.1.9";
editormd.homePage = "https://pandao.github.io/editor.md/";
editormd.classPrefix = "editormd-";
@ -2090,7 +2090,7 @@
clear : function() {
this.codeEditor.setValue("");
return this;
return this;
},
/**
@ -2419,6 +2419,18 @@
editormd.fn.init.prototype = editormd.fn;
/**
* 清除字符串两边的空格
* @param {String} str string
* @returns {String} trim string
*/
editormd.trim = function(str) {
return (!String.prototype.trim) ? str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '') : str.trim();
};
var trim = editormd.trim;
/**
* 自定义marked的解析器
* @param {Array} markdownToC 传入用于接收TOC的数组
@ -2431,21 +2443,46 @@
markdownToC = markdownToC || [];
markedRenderer.heading = function(text, level, raw) {
var linkText = text;
var hasLinkReg = /\s*\<a\s*href\=\"(.*)\"\s*([^\>]*)\>(.*)\<\/a\>\s*/;
var getLinkTextReg = /\s*\<a\s*([^\>]+)\>([^\>]*)\<\/a\>\s*/g;
if (hasLinkReg.test(text))
{
var tempText = [];
text = text.split(/\<a\s*([^\>]+)\>([^\>]*)\<\/a\>/);
for (var i = 0, len = text.length; i < len; i++)
{
tempText.push(text[i].replace(/\s*href\=\"(.*)\"\s*/g, ""));
}
text = tempText.join(" ");
}
text = trim(text);
var escapedText = text.toLowerCase().replace(/[^\w]+/g, "-");
var toc = {
text : text,
text : text,
level : level,
slug : escapedText
};
var isChinese = /^[\u4e00-\u9fa5]+$/.test(text);
var id = (isChinese) ? escape(text).replace(/\%/g, "") : text.toLowerCase().replace(/[^\w]+/g, "-");
var id = (isChinese) ? escape(text).replace(/\%/g, "") : text.toLowerCase().replace(/[^\w]+/g, "-");
markdownToC.push(toc);
var headingHTML = "<h" + level + " id=\"h"+ level + "-" + this.options.headerPrefix + id +"\">";
headingHTML += "<a name=\"" + text + "\" class=\"anchor\"></a>";
headingHTML += "<span class=\"header-link octicon octicon-link\"></span>";
headingHTML += (hasLinkReg) ? linkText : text;
headingHTML += "</h" + level + ">";
return "<h" + level + " id=\"h"+ level + "-" + this.options.headerPrefix + id +"\">" +
"<a href=\"#" + text + "\" name=\"" + text + "\" class=\"anchor\"></a>" +
"<span class=\"header-link\"></span>" + text + "</h" + level + ">";
return headingHTML;
};
markedRenderer.paragraph = function(text) {

138
tests/marked-heading-link-test.html

@ -0,0 +1,138 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<title>Marked heading link Test</title>
<meta charset="UTF-8">
<meta name="description" content="" />
<meta name="keywords" content="" />
<link rel="stylesheet" href="../examples/css/style.css" />
</head>
<body>
<script src="../examples/js/jquery.min.js"></script>
<script src="../lib/marked.min.js"></script>
<script type="text/javascript">
var linkReg = /\s*\<a\s*href\=\"(.*)\"\s*([^\>]*)\>(.*)\<\/a\>\s*/;
var linkTextReg = /\s*\<a\s*([^\>]+)\>([^\>]*)\<\/a\>\s*/g;
var testLink = "<a href=\"http://daringfireball.net/projects/markdown/basics\" title=\"Markdown Basics\">Markdown Basics</a> ";
var testLink2 = "<a href=\"http://daringfireball.net/projects/markdown/basics\" title=\"Xdfsdf\">Xdfsdf</a> ";
var testLink3 = "<a href=\"\" title=\"\"></a> ";
var texts = (testLink + testLink2 + testLink3).split(/\<a\s*([^\>]+)\>([^\>]*)\<\/a\>/);
console.log(texts);
for (var i = 0, len = texts.length; i < len; i++)
{
if((i+1) % 3 == 0) console.log(texts[i]);
}
(testLink + testLink2).replace(linkTextReg, function(){
//console.log($1, $2);
//console.log("linkText =>", $3);
console.log(arguments);
});
testLink.replace(linkTextReg, function($1, $2, $3){
console.log($1, $2, $3);
});
console.log(linkReg.test(" <a name=\"dddd\" class=\"link\" style=\"color:red;\">Markdown Basics</a> "));
console.log(linkReg.test("<a name=\"dddd\" href=\"http://daringfireball.com/projects/markdown/basics\" class=\"link\" style=\"color:red;\">Markdown Basics</a> "));
console.log(linkReg.test("<a href=\"http://daringfireball.net/projects/markdown/basics?xx=ddd&fddf&temp=265656565665656526\" title=\"dddd\" class=\"link\" style=\"color:red;\">Markdown Basics</a> "));
console.log(linkReg.test("<a href=\"http://daringfireball.net/projects/markdown/basics\" title=\"dddd\"><span>Markdown Basics</span></a> "));
console.log(linkReg.test("<a href=\"http://daringfireball.net/projects/markdown/basics?xx=ddd&fddf&temp=265656565665656526\" title=\"dddd\"><span class=\"active\">Markdown Basics</span></a> "));
console.log(linkReg.test("<a href=\"http://www.fdasfasdfsdaf.com/projects/markdown/basics\" title=\"dddd\"><a href=\"#ddd\" class=\"active\">Markdown Basics</a></a> "));
console.log(linkReg.test("afdsfasfsadf<a href=\"http://daringfireball.net/projects/markdown/basics?xx=ddd&fddf&temp=265656565665656526\" title=\"dddd\"><a href=\"#ddd\" class=\"active\">Markdown Basics</a></a> fdasfasdfadsfsfd <a href=\"http://daringfireball.net/projects/markdown/basics\" title=\"dddd\"><span>Markdown Basics</span></a>"));
$(function() {
var markedRenderer = new marked.Renderer();
var markdownToC = markdownToC || [];
markedRenderer.heading = function(text, level, raw) {
var linkText = text;
var hasLinkReg = /\s*\<a\s*href\=\"(.*)\"\s*([^\>]*)\>(.*)\<\/a\>\s*/;
var getLinkTextReg = /\s*\<a\s*([^\>]+)\>([^\>]*)\<\/a\>\s*/g;
if (hasLinkReg) {
var tempText = [];
text = text.split(/\<a\s*([^\>]+)\>([^\>]*)\<\/a\>/);
console.log(text);
for (var i = 0, len = text.length; i < len; i++)
{
if((i+1) % 3 == 0) tempText.push(text[i]);
}
text = tempText.join(" ");
}
var escapedText = text.toLowerCase().replace(/[^\w]+/g, "-");
var toc = {
text : text,
level : level,
slug : escapedText
};
console.log("text =>", text);
var isChinese = /^[\u4e00-\u9fa5]+$/.test(text);
var id = (isChinese) ? escape(text).replace(/\%/g, "") : text.toLowerCase().replace(/[^\w]+/g, "-");
markdownToC.push(toc);
console.log("toc =>", toc);
var headingHTML = "<h" + level + " id=\"h"+ level + "-" + this.options.headerPrefix + id +"\">";
/*return "<h" + level + " id=\"h"+ level + "-" + this.options.headerPrefix + id +"\">" +
"<a href=\"#" + text + "\" name=\"" + text + "\" class=\"anchor\"></a>" +
"<span class=\"header-link\"></span>" + text + "</h" + level + ">";*/
var anchor = "<a name=\"" + text + "\" class=\"anchor\"></a>";
headingHTML += anchor;
headingHTML += "<span class=\"header-link\"></span>";
headingHTML += (hasLinkReg) ? linkText : text;
headingHTML += "</h" + level + ">";
return headingHTML;
};
marked.setOptions({
renderer : markedRenderer,
gfm : true,
tables : true,
breaks : true,
pedantic : false,
smartLists : true,
smartypants : true
});
var md = marked("## [Markdown Basics](http://daringfireball.net/projects/markdown/basics \"Markdown Basics\")");
console.log(md);
var md2 = marked("## fdasfsd [Markdown Basics](http://daringfireball.net/projects/markdown/basics \"Markdown Basics\") xxx [Editor.md](http://daringfireball.net/projects/markdown/basics \"Editor.md\") fadsfasdfasdf");
console.log(md2);
var md3 = marked("### fdasfsd中文链接 [中文链接](http://daringfireball.net/projects/markdown/basics \"中文链接\") xxx 中文链接 [Editor.md 在线Markdown编辑器](http://daringfireball.net/projects/markdown/basics \"Editor.md 在线Markdown编辑器\") fadsfasdfasdf中文链接");
console.log(md3);
var md4 = marked("#### fdasfsd [Markdown Basics](http://daringfireball.net/projects/markdown/basics?xx=ddd&fddf&temp=265656565665656526 \"Markdown Basics\") xxx [Editor.md](http://www.ipandao.com/#xxxxx \"Editor.md\") fadsfasdfasdf");
console.log(md4);
$("body").append(md).append(md2).append(md3).append(md4);
});
</script>
</body>
</html>
Loading…
Cancel
Save