|
@@ -4,6 +4,34 @@
|
|
|
|
|
|
|
|
|
|
const syntax = {
|
|
const syntax = {
|
|
|
|
+ a:{
|
|
|
|
+ paired: true,
|
|
|
|
+ recursive: false,
|
|
|
|
+ startRegexp: /\[(.*)\]\(/,
|
|
|
|
+ endRegexp: /\)/,
|
|
|
|
+ content: {
|
|
|
|
+ start: {
|
|
|
|
+ point: 'end',
|
|
|
|
+ offset: 0
|
|
|
|
+ },
|
|
|
|
+ end: {
|
|
|
|
+ point: 'start',
|
|
|
|
+ offset: -1
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ begin: 0,
|
|
|
|
+ forward: {
|
|
|
|
+ point: 'end', //start, startEnd, end, endEnd
|
|
|
|
+ offset: 1
|
|
|
|
+ },
|
|
|
|
+ title: {
|
|
|
|
+ //index: 1,
|
|
|
|
+ recursive: true,
|
|
|
|
+ },
|
|
|
|
+ onbuild(md, mdTags, buildAST){ //this = {tag: }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ },
|
|
strike: {
|
|
strike: {
|
|
paired: true,
|
|
paired: true,
|
|
recursive: true,
|
|
recursive: true,
|
|
@@ -25,7 +53,7 @@ const syntax = {
|
|
offset: -1
|
|
offset: -1
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- bold: {
|
|
|
|
|
|
+ bold1: {
|
|
paired: true,
|
|
paired: true,
|
|
recursive: true,
|
|
recursive: true,
|
|
startRegexp: /\*\*\S.*/,
|
|
startRegexp: /\*\*\S.*/,
|
|
@@ -67,7 +95,7 @@ const syntax = {
|
|
offset: -1
|
|
offset: -1
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- italic: {
|
|
|
|
|
|
+ italic1: {
|
|
paired: true,
|
|
paired: true,
|
|
recursive: true,
|
|
recursive: true,
|
|
startRegexp: /\*\S.*/,
|
|
startRegexp: /\*\S.*/,
|
|
@@ -416,8 +444,8 @@ const syntax = {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-const indentRegexp = (regexp,count) => new RegExp(`\\n(\\s${count === undefined ? '*' : `{${count}}` })` + regexp.toString().slice(1,-1))
|
|
|
|
-const indentEndRegexp = (count) => new RegExp(`\\n(\\s${count === undefined ? '*' : `{0,${count}}` })\\S`)
|
|
|
|
|
|
+const indentRegexp = (regexp,count) => new RegExp(`\\n([ \\t]${count === undefined ? '*' : `{${count}}` })` + regexp.toString().slice(1,-1))
|
|
|
|
+const indentEndRegexp = (count) => new RegExp(`\\n([ \\t]${count === undefined ? '*' : `{0,${count}}` })\\S`)
|
|
|
|
|
|
function findNearest(md, mdTags, offset=0){
|
|
function findNearest(md, mdTags, offset=0){
|
|
let nearest, nearestMatch = {index: Infinity};
|
|
let nearest, nearestMatch = {index: Infinity};
|
|
@@ -482,7 +510,7 @@ function buildAST(md, mdTags=syntax, offset=0, tree={tag: 'root'}, stack=[]){
|
|
endRegexp = indentEndRegexp(indentLength)
|
|
endRegexp = indentEndRegexp(indentLength)
|
|
let endMatch = md.offsetMatch(offset, endRegexp) || {index: md.length +1, 0: 'zzz'}
|
|
let endMatch = md.offsetMatch(offset, endRegexp) || {index: md.length +1, 0: 'zzz'}
|
|
|
|
|
|
- let listMD = md.slice(offset, endMatch.index + offset).cutIndent(currentNode.startMatch[0].length -1)
|
|
|
|
|
|
+ let listMD = md.slice(offset, endMatch.index + offset).cutIndent(currentNode.startMatch[0].length -2)
|
|
debugger;
|
|
debugger;
|
|
|
|
|
|
const newNode = {tag: childName, startOffset: offset, parent: currentNode, startMatch: currentNode.startMatch}
|
|
const newNode = {tag: childName, startOffset: offset, parent: currentNode, startMatch: currentNode.startMatch}
|
|
@@ -552,6 +580,11 @@ const Heading = ({react:React, children, title, node: {tag}}) => {
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const A = ({react:React, children, title}) =>{
|
|
|
|
+ const _ = React.createElement.bind(React)
|
|
|
|
+ return _("a", {children: title, href: children})
|
|
|
|
+}
|
|
|
|
+
|
|
const defaultMapMDToComponents = {
|
|
const defaultMapMDToComponents = {
|
|
heading1: Heading,
|
|
heading1: Heading,
|
|
heading2: Heading,
|
|
heading2: Heading,
|
|
@@ -562,6 +595,7 @@ const defaultMapMDToComponents = {
|
|
strike: "strike",
|
|
strike: "strike",
|
|
bold1: "strong",
|
|
bold1: "strong",
|
|
bold2: "strong",
|
|
bold2: "strong",
|
|
|
|
+ a: A,
|
|
italic1: "i",
|
|
italic1: "i",
|
|
italic2: "i",
|
|
italic2: "i",
|
|
unOrderedList: 'ul',
|
|
unOrderedList: 'ul',
|