Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sections #44

Open
hgodinho opened this issue Jan 3, 2024 · 2 comments
Open

Sections #44

hgodinho opened this issue Jan 3, 2024 · 2 comments

Comments

@hgodinho
Copy link
Contributor

hgodinho commented Jan 3, 2024

Describe the solution you'd like
Split the document into sections.

Describe alternatives you've considered
hello there, happy new year!
I was wondering if we could discuss a way to implement sections into the plugin.
I can visualize two possible paths:

1 - Pass an array of SectionTuple to mdastToDocx which in turns pass to convertNodes at the ctx param:

type SectionTuple = [title: string; type?: CONTINUOUS | EVEN_PAGE | NEXT_COLUMN | NEXT_PAGE | ODD_PAGE ];

const sectionsTuples: SectionTuple[] = [
    ["Introduction", EVEN_PAGE],
    ["Chapter 1"],
    ["Chapter 2"],
    ["Conclusion", NEXT_PAGE]
    ["Bibliography", EVEN_PAGE]
]

Then convertNodes return a reduced array of sections based on title and page heading:

const { nodes, footnotes, sections } = convertNodes(node.chidlren, {
    deco: {},
    images,
    indent: 0,
    sections: sectionsTuples,
})

The sectionsTuples should not be required, and the convertNodes function should still return the nodes as is in a standard way.

2 - Implement a frontmatter definition. For that we would need to finish the implementation of yaml and toml:

---
section: introduction
section_type: EVEN_PAGE
---

# Introduction

I believe that going both ways in parallel would be cool as it would add more versatility to the plugin. What do you think about?

@inokawa
Copy link
Owner

inokawa commented Jan 3, 2024

Hi, thank you for raising this issue.
Both looks nice!

@hgodinho
Copy link
Contributor Author

hgodinho commented Jan 3, 2024

I'll try a PR this weekend!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants