Open hgodinho opened 1 year ago
I was lookintg at the code, and to implement footnotes it will need to refactor the convertNodes
function, since mdastToDocx
create the document but don't pass a footnote object to parameters as seen here. The convertNodes
function could return a object with nodes and footnotes like so:
// definition
const convertNodes = (nodes: mdast.Content[], ctx: Context): DocxContent[] => {
const results: DocxContent[] = [];
const footnotes: any[] = []; // should define more precise type
for (const node of nodes) {
...
logic to push to footnotes
}
return {
nodes: results,
footnotes
}
}
// calling
const { nodes, footnotes } = convertNodes( nodes, ctx );
this way it will be easier to add more functionalities like splitting the documents into more sections, or adding header and footer options in the future.
But this refactor will affect at least 9 points in transformer.ts
where convertNodes
is called.
I can try a PR if you like.
Hi @hgodinho , I agree refactoring is needed because this plugin is very depending of API of docx. Thank you!
0.1.3
. Thanks!Does this mean footnotes were added?
Yes. It was implemeted but still have limitation described in https://github.com/inokawa/remark-docx/pull/35#issue-1708692883 , and may have some edge case bugs.
Describe the solution you'd like footnotes would be awesome