Code Monkey home page Code Monkey logo

pandoc-prose's Introduction

pandoc-novel

This is a template project for generating a novel or story collection from markdown files and building an ePub file, a SFFMS format manuscript PDF, and an electronic-submission-friedly DOCX file using Pandoc, LaTeX, and GNU Make. This project is fork of pandoc-novel, upated for the needs of modern writers who stil seek traditional publication. For the time being I have deprecated print-ready PDF support because the createspace package on which it depends is weird and old and hard to set up.

Well formatted ePub should be enough for publishing ebooks books with Amazon KDP, Barnes and Noble Press, Smashwords.com, and other self-publishing outlets.

You can see example output for ePub, DOCX and manuscript PDF.

Set Up

Install prequisites

Clone this repo

git clone [email protected]:jp-fosterson/pandoc-novel.git

...or fork the repo (it's a template), and clone your own copy.

Try it out

cd pandoc-novel
make

This will build three targets out/example.epub, out/example.docx, and example-ms.pdf. Open them in your favorite viewers.

If you're on macOS make view-epub will attempt to build the epub target and open the file in Calibre's ebook viewer component (without actually adding the book to your library). Likewise make view-pdf will build the pdf target and open it with the default PDF viewer (probably Preview). If you're not on macOS, you can edit these targets in the Makefile to open the documents in your favorite viewers.

Writing

text/

The most important part of the novel, the text, goes in markdown-format chapter files in the text/ directory. Aside from the .md extension, there are no particular requirements about the file names, chapter ordering will be defined in the Makefile (see below). Chapter titles should be indicated with a H1-level header. If you wish your chapters to be unnumbered, tag them with {.unnumbered} after the title. Backmatter such as acknowledgements and an author bio should just be included as {.unnumbered} chapters; they will be indicated in the Makefile.

Makefile

Set the SLUG variable in the Makefile to change the prefix used on the output files

#
# Slug: filename prefix that will be used for the generated
# files. e.g. example.epub and example.pdf, plus intermediate
# files like example.tex
#
SLUG=example

To define the chapter ordering add the chapter files, in order, in the CONTENTS and BACKMATTER variables in Makefile:

#
# The main text of the book. This sequence determines the
# chapter order.
#
CONTENTS = \
	text/beginning.md\
	text/middle.md\
	text/end.md\
	\
#
# The stuff in the back, not part of the story.
#
BACKMATTER = \
	text/ack.md \
	text/about.md\
	\

metadata.yaml

The title, author, copyright notice, ePub cover image, and other important metadata are defined in metadata.yaml.

make targets

  • make or make all --- makes the main ePub and PDF targets in out/.
  • make docx -- builds the submission-ready book DOCX.
  • make epub --- builds the epub book.
  • make ms --- builds the manuscript-format PDF.
  • make unzip --- Builds the ePub document, which really just a zip archive full of files, and then unzips it into out/$(SLUG).unzip so that you can examine the contents. This is fun for the curious, or if you need to understand the style classes used in the document when modifying the stylesheet (see below).
  • make clean --- cleans up everything, including the output and all the LaTeX shrapnel left in the directory after building.
  • make tkcheck --- searches for "TK" in the text and fails if it finds any. [Editors use "TK" to indicate more to come, i.e. unfinished writing. You can do make tkcheck all to build the documents only when all TKs are removed.]

Customization

You can customize the style of the generated ePub via CSS stylesheets, and the PDF via the LaTeX document template. The style of the DOCX requires a reference doc.

DOCX Reference Doc

A default reference doc is provided in the templates directory, but this can be edited with Microsoft Word or Google Docs to suit your needs. It is currently in beta.

ePub Stylesheets

The STYLESHEET variable in the Makefile selects the stylesheet to use when building the ePub document. Two stylesheets are provided in the /css directory, one with an indented paragraph style and one with a block-paragraph style. Either can be used as a starting point for a new style. If you're not sure what style classes you need to modify, do make unzip then examine the chXXX.xhtml files in out/$(SLUG).unzip/EPUB/text.

LaTeX Template

The LaTeX files that generate the book and manuscript PDF are built from templates in templates/book.tex and templates/sffms.tex. They use Pandoc template syntax.

For the book PDF, the title page design for the book template was taken from Peter Wilson's great collection of LaTeX title pages, feel free to replace it with a design you like better. The page header and numbering are controlled by the fancyhdr package.

For the manuscript PDF, I had to define or override a handful of LaTeX commands to get some things to work (e.g. sections). Inputs that deviate consierably from the example text may require some LaTeX tinkering to get right. By default, the manuscript omits the backmatter like "Acknowledgements" and "About the Author" sections. To include them, add $(BACKMATTER) to the $(SLUG)-ms.tex target in the Makefile.

Publishing

Ebooks

Amazon KDP will take an ePub doc and covert it to a Kindle book, and it does a fairly good job. If you're curious what it looks like, you can get Kindle Previewer, and other ebook sites take ePubs directly.

Print

I have only tried KDP, but the KDP site does a pretty good job of showing how your PDF will fit in different page trim sizes. I found that despite using the "pocket" size parameter in the createspace package, it fits well in 6x9" with good size margins (IMO).

pandoc-prose's People

Contributors

jp-fosterson avatar captainlexington avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.