@dendronhq/engine-server
Advanced tools
Comparing version
@@ -83,3 +83,3 @@ "use strict"; | ||
it("no anchor", () => { | ||
expect(utils_1.extractBlock(FILE_TEXT, createFileLink()).block).toEqual(lodash_1.default.trim(FILE_TEXT)); | ||
expect(utils_1.extractBlock(FILE_TEXT, createFileLink()).block).toEqual(FILE_TEXT); | ||
}); | ||
@@ -126,3 +126,13 @@ it("anchor start", () => { | ||
}); | ||
it("anchor start", () => { | ||
expect(utils_1.replaceRefWithMPEImport("((ref:[[ref]]#head2.1))", { | ||
root, | ||
})).toEqual('@import "ref.md" {line_begin=11}'); | ||
}); | ||
it("anchor start", () => { | ||
expect(utils_1.replaceRefWithMPEImport("((ref:[[ref]]#head2.1:#head2.3))", { | ||
root, | ||
})).toEqual('@import "ref.md" {line_begin=11 line_end=19}'); | ||
}); | ||
}); | ||
//# sourceMappingURL=utils.spec.js.map |
@@ -0,1 +1,2 @@ | ||
export declare const VERSION = "BOND"; | ||
export declare type DendronRefLink = { | ||
@@ -2,0 +3,0 @@ label?: string; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.replaceRefWithMPEImport = exports.matchRefMarker = exports.parseFileLink = exports.parseDendronRef = exports.extractBlock = void 0; | ||
exports.replaceRefWithMPEImport = exports.matchRefMarker = exports.parseFileLink = exports.parseDendronRef = exports.extractBlock = exports.VERSION = void 0; | ||
const lodash_1 = __importDefault(require("lodash")); | ||
@@ -14,3 +14,7 @@ const path_1 = __importDefault(require("path")); | ||
const common_server_1 = require("@dendronhq/common-server"); | ||
const fs_extra_1 = __importDefault(require("fs-extra")); | ||
process.env["LOG_DST"] = "/tmp/bond.log"; | ||
const L = common_server_1.createLogger("bond"); | ||
const markdownIt = markdown_it_1.default(); | ||
exports.VERSION = "BOND"; | ||
function genAST(txt) { | ||
@@ -23,2 +27,4 @@ const tokens = markdownIt.parse(txt, {}); | ||
) { | ||
const ctx = "extractBlock"; | ||
L.info({ ctx, txt, link }); | ||
// const copts = _.defaults(opts, { linesOnly: false }); | ||
@@ -30,3 +36,3 @@ const { anchorStart, anchorEnd } = link; | ||
else { | ||
txt = lodash_1.default.trim(txt); | ||
//txt = _.trim(txt); | ||
if (!anchorStart) { | ||
@@ -54,3 +60,3 @@ return { block: txt }; | ||
}); | ||
const txtAsLines = lodash_1.default.trim(txt).split("\n"); | ||
const txtAsLines = txt.split("\n"); | ||
if (lodash_1.default.isNull(out.anchorStart)) { | ||
@@ -158,2 +164,5 @@ return { block: "invalid link" }; | ||
exports.replaceRefWithMPEImport = (line, opts) => { | ||
const ctx = "replaceRefWithMPEImport"; | ||
L.info({ ctx, line }); | ||
fs_extra_1.default.appendFileSync("/tmp/bond2.log", JSON.stringify({ ctx, line })); | ||
const match = exports.matchRefMarker(line); | ||
@@ -178,8 +187,27 @@ let prefix = `@import`; | ||
} | ||
// {line_begin=2 line_end=10} | ||
const offset = []; | ||
//TODO: will be more sophisticated when multi-vault | ||
const { content } = common_server_1.readMD(fsPath); | ||
// @ts-ignore | ||
const { content, matter } = common_server_1.readMD(fsPath); | ||
// the last --- isn't counted, shoud be +1 | ||
// but since mpe is 0 delimited, it cancels each other out | ||
const fmOffset = matter.split("\n").length; | ||
// @ts-ignore | ||
const { lines } = extractBlock(content, link); | ||
return line; | ||
// TODO: throw error | ||
if (!(lines === null || lines === void 0 ? void 0 : lines.start)) { | ||
return line; | ||
} | ||
// +1 because extract block does -1 for 0-indexing file | ||
// +1 because header block gets parsed form line before | ||
const pad = 2 + fmOffset; | ||
offset.push(`line_begin=${lines.start + pad}`); | ||
if (link.anchorEnd) { | ||
// everything up to header is counted here | ||
offset.push(`line_end=${lines.end + pad - 1}`); | ||
} | ||
prefix += ` {${offset.join(" ")}}`; | ||
return prefix; | ||
}; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "@dendronhq/engine-server", | ||
"version": "0.6.6", | ||
"version": "0.6.7", | ||
"description": "dendron-engine", | ||
@@ -5,0 +5,0 @@ "license": "GPLv3", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
217150
1.3%2354
1.68%10
25%