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

Improve templating for docx export from myst-cli #63

Closed
fwkoch opened this issue Oct 28, 2022 · 3 comments
Closed

Improve templating for docx export from myst-cli #63

fwkoch opened this issue Oct 28, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@fwkoch
Copy link
Member

fwkoch commented Oct 28, 2022

Context

  • myst-cli has introduced functionality to export myst files as tex/pdf/docx from the command line
  • tex/pdf exports allow you to specify a latex template to customize the output. There are already a number of templates available: https://github.com/myst-templates. These are totally standalone, with a template.yml config (defining template metadata, required frontmatter fields, and additional template options), a nunjuks-style template to use, and all additional supplementary files (icons, latex document classes, etc).
  • jtex validates user input against the template options and fills in the template based on these options, myst frontmatter, and tex content (converted with myst-to-tex)
  • docx templating, however, requires passing in a renderer function (since we use docx to generate the document). It can take additional template options (and these can be defined in a template.yml file), but there is nothing like jtex validating these options and holding it all together.
  • Additionally, there is no easy way to define additional static files required by the renderer...

Proposal

  • I don't think we should move away from using the docx library for now. This would require writing valid docx nunjuks-style templates in XML, doesn't feel great, but certainly a future possibility.
  • For now it would be great to at least:
    • validate options based on a template.yml
    • bundle static files together with the template.yml
    • connect this template to the renderer function so they are used together
  • This means teasing apart the template download / validation part of jtex from the tex-specific rendering, and updating the docx build to consume a template package using the non-tex part of jtex.

Tasks and updates

No response

@fwkoch fwkoch added the enhancement New feature or request label Oct 28, 2022
@fwkoch fwkoch self-assigned this Oct 28, 2022
@rowanc1
Copy link
Member

rowanc1 commented Oct 28, 2022

Some other things that I noticed after the merge is that the current docx template still has a curvenote footer on it. We should fix that up and provide some extensibility there.

@rowanc1
Copy link
Member

rowanc1 commented Nov 8, 2022

Parts of this have been addressed in #67, I think we still need another pass of moving parts from jtex --> myst-templates

@rowanc1
Copy link
Member

rowanc1 commented Nov 24, 2022

With the addition of SVG conversion, this is now complete!

The docx template is here:
https://github.com/myst-templates/docx_default

@rowanc1 rowanc1 closed this as completed Nov 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants