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

Add docx render option #303

Merged
merged 13 commits into from
Nov 3, 2021
Merged

Add docx render option #303

merged 13 commits into from
Nov 3, 2021

Conversation

avahoffman
Copy link
Contributor

Purpose/implementation Section

This PR is attempting to create a docx rendering option. This is mostly because I believe the GDSCN community would like to download student activities in word format so they can have the option be easily edited in whatever format suits them. I'm imagining two links at the bottom of the bookdown, "Download as .Rmd" and "Download as .docx"

What changes are being implemented in this Pull Request?

Addition of a docx rendering section in the rendering workflow

What was your approach?

Adding a rendering script. Not sure this is how we want it / is the best way to do this. Kind of feel it looks ugly compared to the other rendering, but this is just a first pass.

What GitHub issue does your pull request address?

N/A

Tell potential reviewers what kind of feedback you are soliciting.

Does this fit with the quality of the template?

New Content Checklist

@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2021

Re-rendered previews from the latest commit:

Updated at 2021-11-03 with changes from 4947b94

@avahoffman
Copy link
Contributor Author

This is some preliminary code to allow writing .Rmd to .docx. I think by default we'll have it off, but have it here in the template as an option.

I'm not experienced enough with github actions to know what's missing here. Basically, all checks pass and logs look fine but no docx files are created by github actions. Files are created fine locally. @cansavvy @carriewright11 would love your thoughts here! Hopefully I'm just missing something really obvious 🙂

@cansavvy
Copy link
Collaborator

cansavvy commented Nov 3, 2021

@avahoffman thanks for doing this! This is a great start! I have a few things I think we need to add to wrap this up:

  1. We need to add a comment to the preview.yml comment that brings someone to the rendered docx file.

  2. I think it makes sense to make the script only run Rmds that are listed in the _bookdown.yml file. This ensures only Rmds that we want in the course are added to the docx. I could see scenarios where other Rmds are in the repository that aren't necessarily course material (example and template files and etc)

I'm happy to commit these changes to your branch if you want, or if you prefer to do them yourself, that's also fine. Just let me know.

@avahoffman
Copy link
Contributor Author

@cansavvy agreed on all points!

I did a 180 and made the docx creation part of the yml - it just renders the whole book as a docx based on _bookdown.yml - easier for everyone :)

We need to add a comment to the preview.yml comment that brings someone to the rendered docx file.

Not sure what you mean here - is there an equivalent of https://htmlpreview.github.io for other formats (docx?)

@cansavvy
Copy link
Collaborator

cansavvy commented Nov 3, 2021

Not sure what you mean here - is there an equivalent of https://htmlpreview.github.io for other formats (docx?)

Just something in that comment that brings people to the created file -- makes it clear that the file was made and where to find it. I can set this up if you like.

@@ -8,6 +8,9 @@ biblio-style: apalike
link-citations: yes
description: "Description about Course/Book."
favicon: assets/dasl_favicon.ico
output:
bookdown::word_document2:
toc: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary in addition to the output_format = 'all'? Sometimes bookdown has things that are redundant and confusing. So just wondering.

Copy link
Contributor Author

@avahoffman avahoffman Nov 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locally, bookdown::render_book(output_format = "all") renders the docx but bookdown::render_book() doesn't. I agree it's weird and kind of redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the documentation:

If using NULL then the output format is the first one defined in the YAML frontmatter in the input file (this defaults to HTML if no format is specified there).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm always so confused by the various places where yamls are specified and how to know which is prioritized. But if you have it figured out then sounds good to me! 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha me too - it took me forever to find that bit in the docs :P

@cansavvy
Copy link
Collaborator

cansavvy commented Nov 3, 2021

Yay. Take a look at #303 (comment) I definitely think this is something we should add to Release 1.2 #300 I think we can almost merge it (if you are ready).

We might want to think about how we advise this docx is used though. We could probably be fancy and have changes to the docx uploaded to Google Drive, but I'd also hate for people's edits to get overwritten at any point, so I'm not sure what's the ideal workflow for this. I'll make an issue for us to discuss this.

Edit: see #306

@avahoffman
Copy link
Contributor Author

Just something in that comment that brings people to the created file -- makes it clear that the file was made and where to find it. I can set this up if you like.

Thanks for adding! I didn't think to reference the preview branch 🙂

@carriewright11
Copy link
Member

Good job to both of you! I will check out the discussion issue that @cansavvy created.

Copy link
Collaborator

@cansavvy cansavvy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I mark this PR as ready and merge it then, @avahoffman ?

@@ -8,6 +8,9 @@ biblio-style: apalike
link-citations: yes
description: "Description about Course/Book."
favicon: assets/dasl_favicon.ico
output:
bookdown::word_document2:
toc: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm always so confused by the various places where yamls are specified and how to know which is prioritized. But if you have it figured out then sounds good to me! 👍

@cansavvy
Copy link
Collaborator

cansavvy commented Nov 3, 2021

The Render preview fail is just a temporary problem due to Docker's server. Nothing crazy. Should be resolved if we re-run in a tad.

@avahoffman avahoffman marked this pull request as ready for review November 3, 2021 14:52
@avahoffman avahoffman merged commit 3933d6c into main Nov 3, 2021
@avahoffman avahoffman deleted the word-docs branch November 3, 2021 14:53
@avahoffman
Copy link
Contributor Author

Woo! Thanks for working with me here! It's the remote dev I love to see 😄

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

Successfully merging this pull request may close these issues.

3 participants