remark-auto-diff
Version:
A remark plugin providing an alternative syntax to author diff code blocks in Markdown.
22 lines (20 loc) • 518 B
JavaScript
import { diffLinesRaw } from "jest-diff";
//#region src/libs/diff.ts
function getDiff(a, b) {
const diff = diffLinesRaw(splitLines(a), splitLines(b));
return diff.map((line) => {
const diffLine = {
text: line[1],
type: void 0
};
if (line[0] === -1) diffLine.type = "del";
else if (line[0] === 1) diffLine.type = "ins";
return diffLine;
});
}
function splitLines(text) {
return text.length === 0 ? [] : text.split("\n");
}
//#endregion
export { getDiff };
//# sourceMappingURL=diff-CLPTCubC.js.map