Render and publish Quarto manuscripts to Google Drive. Fixes figure
formatting issues that occur when converting .qmd files to Google
Docs. Keeps everyone working on the manuscript pointed to the same
shared Google Doc.
Suggested workflow: write in Quarto, publish to Google Drive, get comments from collaborators, update the Quarto file, and repeat. Changes do not sync back from Google Docs to Quarto. The Quarto file remains the source of truth. This lets collaborators comment and suggest changes in Google Docs. The lead researcher then reviews the suggestions and manually transfers accepted changes back into the Quarto file.
# install.packages("pak")
pak::pak("milanwiedemann/pubthis")To run the publishing workflow from the terminal you also need to install just to run the just recipes.
Run once per project to add the required files:
pubthis::use_publish_workflow()This adds:
publish/reference.docx: Word template for consistent stylespublish/docx-format.lua: Lua filter that fixes figures in Google Docsjustfile: task runner withpublish,open, andauth-gdrivecommands
pubthis::publish() applies the reference document and Lua filter
automatically — no changes to your .qmd YAML are needed. If you also
render with plain quarto render and want the same Word styles, set
reference-doc: ../publish/reference.docx under format: docx: in your
.qmd YAML (adjust the relative path to where your manuscript lives).
Run once in an interactive R session to cache your Google Drive credentials. From terminal using just (prints the commands to run):
just auth-gdriveOr from R console:
googledrive::drive_auth()From terminal using just:
# Render and upload to Google Drive as Google Doc
just publish manuscripts/paper.qmd
# Open the published Google Doc in the browser
just open manuscripts/paper.qmdOr from R console:
pubthis::publish("manuscripts/paper.qmd")
pubthis::open_published("manuscripts/paper.qmd")pubthis uses a _publish.yml file next to your .qmd to remember which
Google Doc to update. This is the same publish-record file
quarto publish itself uses, so a gdrive entry lives alongside any
posit-connect-cloud (or other provider) entry for the same file
without disturbing it. Commit this file so everyone on the project
opens the same doc. There are two ways to set this up:
- Let pubthis create a new doc: On first publish, a new Google Doc is
created and a
gdriveentry is added to_publish.ymlautomatically. Every subsequentpublishcall updates that same doc in place. - Use an existing doc: If a shared doc already exists, add an entry to
_publish.ymlmanually and paste in the doc ID (the long string between/d/and/editin the doc URL)
- source: paper.qmd
gdrive:
- id: <paste-google-doc-id-here>Every subsequent publish call will update that doc in place.