Skip to content

Commit 94b8ca1

Browse files
boomyjeemarijnh
authored andcommitted
Added support for <div markdown="1"> syntax.
1 parent 23ff767 commit 94b8ca1

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

mode/markdown/markdown.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
7676
state.f = inlineNormal;
7777
state.block = blockNormal;
7878
}
79+
if (state.md_inside && stream.current().indexOf(">")!=-1) {
80+
state.f = inlineNormal;
81+
state.block = blockNormal;
82+
state.htmlState.context = undefined;
83+
}
7984
return style;
8085
}
8186

@@ -118,10 +123,22 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
118123
return switchInline(stream, state, linkText);
119124
}
120125
if (ch === '<' && stream.match(/^\w/, false)) {
126+
var md_inside = false;
127+
if (stream.string.indexOf(">")!=-1) {
128+
var atts = stream.string.substring(1,stream.string.indexOf(">"));
129+
if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) {
130+
state.md_inside = true;
131+
}
132+
}
121133
stream.backUp(1);
122134
return switchBlock(stream, state, htmlBlock);
123135
}
124-
136+
137+
if (ch === '<' && stream.match(/^\/\w*?>/)) {
138+
state.md_inside = false;
139+
return "tag";
140+
}
141+
125142
var t = getType(state);
126143
if (ch === '*' || ch === '_') {
127144
if (stream.eat(ch)) {
@@ -212,13 +229,14 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
212229
block: s.block,
213230
htmlState: CodeMirror.copyState(htmlMode, s.htmlState),
214231
indentation: s.indentation,
215-
232+
216233
inline: s.inline,
217234
text: s.text,
218235
em: s.em,
219236
strong: s.strong,
220237
header: s.header,
221-
quote: s.quote
238+
quote: s.quote,
239+
md_inside: s.md_inside
222240
};
223241
},
224242

0 commit comments

Comments
 (0)