Skip to content

Commit

Permalink
feat: 🎸 implement footnoteOrder list
Browse files Browse the repository at this point in the history
streamich committed Feb 27, 2019
1 parent b743a48 commit 89209c5
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/__tests__/mdastToFlat.spec.ts
Original file line number Diff line number Diff line change
@@ -245,6 +245,9 @@ describe('structure', () => {
footnotes: {
gg: 4,
},
footnoteOrder: [
4,
],
});
});

3 changes: 3 additions & 0 deletions src/__tests__/replace.spec.ts
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ describe('structure', () => {
contents: [],
definitions: {},
footnotes: {},
footnoteOrder: [],
});
});

@@ -58,6 +59,7 @@ describe('structure', () => {
contents: [],
definitions: {},
footnotes: {},
footnoteOrder: [],
});
});

@@ -155,6 +157,7 @@ merge here
contents: [1, 14],
definitions: {link1: 12, gg: 19},
footnotes: {foot: 9, note: 20},
footnoteOrder: [9, 20],
});
});
});
3 changes: 3 additions & 0 deletions src/replace.ts
Original file line number Diff line number Diff line change
@@ -41,6 +41,9 @@ export const replace = (into: Flat, at: number, what: Flat): Flat => {
Object.keys(what.footnotes).forEach(
(identifier) => (merged.footnotes[identifier] = what.footnotes[identifier] + mergeIdx),
);
for (const footnoteIndex of what.footnoteOrder) {
merged.footnoteOrder.push(footnoteIndex + mergeIdx);
}

return merged;
};

0 comments on commit 89209c5

Please sign in to comment.