hackmdio / hackmdio/codimd

@hackmd/codemirror doesn't know of meta-marked

Open
#1,596 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
10.1k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

If the first line is `---`, the lines until `---` or `...` are meta info. So codemirror should do a special case.

For example, codemirror/addon/fold/markdown-fold.js can be modified like the following:

```
CodeMirror.registerHelper("fold", "markdown", function(cm, start) {
var maxDepth = 100;
var lastLineNo = cm.lastLine();

var lineZero = cm.getLine(0);
if (lineZero.match(/^-{3}/)) {
var end = 1;
while (end < lastLineNo) {
if (cm.getLine(end).match(/^\.{3}|-{3}/)) break;
++end;
}
if (start.line == 0) {
return {
from: CodeMirror.Pos(0, lineZero.length),
to: CodeMirror.Pos(end, cm.getLine(end).length)
};
}
if (start.line < end) return undefined;
}
```

Well, modifying codemirror/mode/markdown/markdown.js is beyond my skill.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.