MCPcopy Index your code
hub / github.com/nodejs/node / indentCodeCompensation

Function indentCodeCompensation

test/fixtures/snapshot/marked.js:442–465  ·  view source on GitHub ↗
(raw, text)

Source from the content-addressed store, hash-verified

440 }
441
442 function indentCodeCompensation(raw, text) {
443 var matchIndentToCode = raw.match(/^(\s+)(?:```)/);
444
445 if (matchIndentToCode === null) {
446 return text;
447 }
448
449 var indentToCode = matchIndentToCode[1];
450 return text.split('\n').map(function (node) {
451 var matchIndentInNode = node.match(/^\s+/);
452
453 if (matchIndentInNode === null) {
454 return node;
455 }
456
457 var indentInNode = matchIndentInNode[0];
458
459 if (indentInNode.length >= indentToCode.length) {
460 return node.slice(indentToCode.length);
461 }
462
463 return node;
464 }).join('\n');
465 }
466 /**
467 * Tokenizer
468 */

Callers 1

marked.jsFile · 0.85

Calls 5

matchMethod · 0.65
mapMethod · 0.65
sliceMethod · 0.65
joinMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected