Scrivener + Quarto: a technical/academic publishing workflow

Many thanks, I’ll give that a go and switch to the new thread

1 Like

Something that I would like to ask, maybe to @nontroppo , is if I installed Quarto correctly. When invoked from the Mac Terminal it seems to work, so it should.

However: I let the .pkg install it. It installed a “quarto” folder inside my main Applications folder. Inside it, two other folders, named “bin” and “share”. I guess I should simply leave them there, and not move, for example, the “quarto” app into the /bin/ folder of my system.

Thank you for helping me dissolve some fog!

Paolo

Hi, Paolo (@ptram), if I may chime in, I could not quite get what you are saying: is it working or not? Does it work on the terminal with a dummy file? If so, does it also work from Scrivener? If not, what do you see in the Quarto.log?

The Quarto folders seem right—no need to move them around.

Yes, Quarto is working fine. Typing the name in the Terminal recalls it. So, I assume the installation is fine as it is.

Paolo

Ouch, I had missed this part. So, the answer to the question I’m wandering around is – no, you can’t directly use an .md file compiled by Scrivener to create a web site or book with Quarto.

I’m trying with chunkedhtml in Pandoc, but I have yet to understand how to use the produced .html files with Quarto.

Paolo

I am working on a template to do just that. I will share it shortly.

Edit: also, see this: Scrivener + Quarto + Cite Tools: advanced bibliography for a technical/academic publishing workflow - #9 by bernardo_vasconcelos

Yes, while quarto installs into /Applications, it also adds a softlink to /usr/local/bin:

 ▶︎ ls -al /usr/local/bin/q*
lrwxr-xr-x root wheel 31 B Fri May 19 08:36:27 2023  /usr/local/bin/quarto@ ⇒ /Applications/quarto/bin/quarto

So no need to move it around, the terminal path will find it.

As Bernardo mentions he has some code to do this already. But I would just add that the output from the standard quarto templates may be perfectly sufficient for a book or website page, as it still includes a lot of functionality and navigation. There is overlap between using headings in a single document as chapters, or multiple documents as chapters in terms of structure…

1 Like

In printed terms, the material I have to convert to a web site is a little less than 2,000 pages. Unless I can break it into an articulate web site made of several sections and pages, I doubt that it would be usable.

But, in more general terms, I wonder what the use of a single-page web site could be. In particular, if the source of the “narrative” text is Scrivener, a tool dedicated to long writing.

I’m for sure missing the point, but I really can’t see the use of Scrivener with Quarto as it is. I’m sure it will develop further, but I’m a bit lost at this point.

Paolo

The script is very interesting, and thank you very much for developing it!

But I have to say that it would be great if this feature was added natively to Quarto. It would make the procedure a lot smoother. I’ll try to see if this has already been suggested in the dedicated forum.

Paolo

1 Like

As of now, the only workaround I see is to compile individual sections from Scrivener, and then let Quarto assemble a website or book from them.

With a big project, this would be a big task the first time. I guess it would be much easier with subsequent updates, when one has only to compile the modified/updated sections from Scrivener. The newly compiled .md files would replace the older ones, and put together with the ones that have not changed.

It would obviously be great if Scrivener could compile to separate .md files, split at a certain hierarchy level. Or if Quarto could understand pagebreak commands as instructions to split the source document into separate .html pages. I’m even surprised it doesn’t to it already.

Paolo

1 Like

I suppose because the tools for navigating are similar. Here is a standard Scrivener>Quarto document:

The TOC floats to the left, and both top-level chapters and sub-chapters are all available to navigate through. A browser can easily handle cross-linking within a long document. You can link from any chapter to any other. Why must a long document be physically split into different files? You may say sharing chapter links are easier? But Quarto allows easy copying of any chapter links:

Screenshot 2023-06-06 at 20.32.56

Splitting to different files adds complexity, for example search which is trivial within-document becomes more technically complex across documents (however Quarto handles this too!) Quarto does do some nice things for their multi-file outputs, like put document TOC on the left and within-doc TOC on the right, which someone may prefer (I don’t, as a reader I care about content, not navigating file structures!)

So the reason I think Quarto doesn’t do this is more to do with the fact that this is more a workstyle preference of the author (if you are writing markdown in a plain text editor maybe you prefer a folder of files, not an issue with Scrivener), than it is a limitation of the output for the reader.

Still, the more options the better and as Pandoc does now support chunked HTML the job for Quarto or an extension developer should be much easier. You should open an issue on the Quarto github and see where it goes! :+1: Bernardo already has core code to do this for Scrivener so this will be a second route for those who prefer juggling multiple file projects.

1 Like

@nontroppo or any one that can help, my apologies, I’m new to this, I have downloaded the Quarto.scriv folder/project and I have installed quarto (I’m in a win 11 x64, Scrivener: 3.1.5.1, quarto quarto-1.3.433-win) what would be the next steps to compile such a nice looking pdf as the sample output ? Thank you in advance

Congratulations on completion of the PhD - a fantastic achievement

Hi @eriikals — my usual tests are to download the latest project template linked in the first post (currently V1.04), import that template into the New Project dialog, create a new project from the template and just compile. BUT that is on macOS. The script that performs the modifications that enable Scrivener output to successfully compile with Quarto require a Ruby interpreter, which you will need to install on Windows (it is built-in on macOS). The paths it sets up are also for macOS, and that may need to change for Windows machines. The ideal would be to write a cross-platform script, but I don’t have time and don’t have Windows available to test even if I did… I can answer questions for Windows users who try to get it to work and the errors are obvious.

Parts of that document also runs R code for dynamic figure and table. generation. Instructions are part of a Note in the project:

NOTE: … In addition, for the sample content, if you don’t have R installed, you must remove the [Stimulus Plotting] section from the compile list as they use R. R can easily be installed via homebrew:

brew install homebrew/cask/r
brew install xquartz

Then run R from the terminal and install the tidyverse and kableExtra packages, this should cover the dependencies:

install.packages("tidyverse")
install.packages("kableExtra")

Finally, you must edit the Metadata paths and fonts to those available on your system for the compile to succeed. The script replaces ${USERHOME} with your home folder path, but it is up to you to set up the rest of the path. I use my pandoc folder to store my bibliography, cal and templates files, so for example my CSL file is stored at ${USERHOME}/.local/share/pandoc/csl/apa.csl

For the bibliography you need to replace the in-text citations like [@siegel2015] with your own, or export my Core.json to a location specified by the Metadata bibliography key. The CSL file is also available and you can export it from apa.csl and point to it using the csl metadata key.

If you want to use the same fonts I specify, you can install them from homebrew in the terminal (https://brew.sh):

brew tap homebrew/cask-fonts
brew install font-alegreya font-alegreya-sans

Overall ruby is essential, R is optional if you remove some sections, and you will need to edit the metadata to select files on your system and change fonts or install the ones I use. With the bits in place and hopefully no errors from Windows for the script you should just be able to compile, the script automates the modification and runs Quarto for you… Each piece can be run outside Scrivener for testing (you can scrivener-compile without running the script; then run the script manually)…

I really appreciate the information @nontroppo , just one more question, which files/paths (where are they) that need to be modified ?
I can install ruby, and R, and I can find and modify the files you mention, but my question would be how do I link that compile dialog actions to what is needed, or where should I make such modifications: ${USERHOME}, point to the ruby or R binaries ?

Thank you !

Line 17 of the script is the function that sets up the path:

I don’t know where and how the path needs to be set up for Windows, or if Scrivener on windows even needs this to be done; perhaps it runs with the path already set up. The path is required so that Scrivener can find Quarto and the other bits, but that may work better on Windows than macOS, I just don’t know. You can download just that script and run it from the windows terminal with a sample markdown file to see if it works, as I said each bit can be broken down and tested bit by bit.

1 Like

Oh ok, many thanks for this, this is what I had problems with: -the bird’s eye view- of things, so just to confirm:

document in scrivener → compile to (markdown ?) → run the script in the same folder as the .md file ( ? ) → pdf ( ? )

The process is what I need help with also

As long as Scrivener-windows is broadly similar to Scrivener-mac, then the project template should be set up with the compile format and everything ready to go. Sometimes you may need to check the Compile Layouts are all assigned. But, here for example, I’ve added the project template anew and created a shiny new project, then just hit compile and this is what I see:

The project is compiling to Multimarkdown, has four project formats and the PDF one is already selected, the Section Layouts are all assigned, the front matter is correctly assigned to the :control_knobs:Metadata document. You do need to make changes to paths and fonts in :control_knobs:Metadata as there are absolute paths that are required and font names like Alegreya that are specific to my system.

Now where Windows used to be different was some limitations around post-processing (is that still the case, I don’t know?):

On macOS the Ruby script is embedded in the project format, with the arguments specified. Now &> is used to redirect all errors and output to a log file and I doubt &> works on Windows unless you are using cygwin / msys2 / WSL? This may need a tweak?

The top level view then is: the project template should take care of all the details, it is set up to Multimarkdown[pandoc syntax] output with all the Section Layouts, Styles etc. all wired up. The embedded post-processing script takes the Pandoc-flavoured markdown output from Scrivener, and rewrites it (so e.g. Output.md that Scrivener produces is copied to Output2.qmd, the original is left in place so you can check differences etc.), then runs Quarto on Output2.qmd.

Platform differences may break some of those wires :upside_down_face:

I can confirm that just opening the file: “Quarto.scrivx” with Scrivener, does not import the formart in the compile dialog, I attach an image:

I might need to get more files besides the project folder? and import them? Many thanks for the help really, I really appreciate it

It seems I need another file (a scrivener format file to compile ?)

What happens if instead of the project zip, you use the project template (make sure the file name ends in .scrivtemplate, some browsers may append .txt etc.):

https://github.com/iandol/scrivomatic/raw/master/Scrivener%20%2B%20Quarto.scrivtemplate

You need to open the New Project... dialog then Import Templates..., select that file, the go to Non-fiction and select the Scrivener+Quarto template:

As I know it the project template contains the compile formats. Indeed these should also have been visible when you just opened the .scriv project. If you browser to Quarto.scriv/Settings/Compile formats/ they are there.

I don’t know why they do not show in Scrivener. You may get better traction asking other windows users, they will be better able to contend with what appear to be platform variances.