MCPcopy Create free account
hub / github.com/TruthHun/BookStack / findParagraph

Function findParagraph

static/editor.md/lib/codemirror/addon/wrap/hardwrap.js:16–30  ·  view source on GitHub ↗
(cm, pos, options)

Source from the content-addressed store, hash-verified

14 var Pos = CodeMirror.Pos;
15
16 function findParagraph(cm, pos, options) {
17 var startRE = options.paragraphStart || cm.getHelper(pos, "paragraphStart");
18 for (var start = pos.line, first = cm.firstLine(); start > first; --start) {
19 var line = cm.getLine(start);
20 if (startRE && startRE.test(line)) break;
21 if (!/\S/.test(line)) { ++start; break; }
22 }
23 var endRE = options.paragraphEnd || cm.getHelper(pos, "paragraphEnd");
24 for (var end = pos.line + 1, last = cm.lastLine(); end <= last; ++end) {
25 var line = cm.getLine(end);
26 if (endRE && endRE.test(line)) { ++end; break; }
27 if (!/\S/.test(line)) break;
28 }
29 return {from: start, to: end};
30 }
31
32 function findBreakPoint(text, column, wrapOn, killTrailingSpace) {
33 for (var at = column; at > 0; --at)

Callers 1

hardwrap.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected