Skip to content

Commit

Permalink
more kudos and clarifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Francis Meetze committed Apr 18, 2023
1 parent 80c19ca commit 22c0d6c
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 45 deletions.
71 changes: 41 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
# Markdown > Pandoc Book Doctor > Publication

After making a migration from Org-Mode to MD, I needed some easy templates
that I could quickly publish into different formats. I came upon Stefano
Cecere's
After migrating my writing workflow from Org-Mode to Markdown, I needed a more
straightforward process for quickly publishing the files into different formats.
I came across Stefano Cecere's
[repository](https://github.com/StefanoCecere/markdown_pandoc_book_template)
and was duly impressed. So was also inspired by Adam Day's
[work](https://github.com/prosegrinder/pandoc-templates).

However, I didn't want to lug around a bunch of custom configuration
files for everything I wanted to convert with Pandoc. Hence, my little pet
project, the Pandoc Book Doctor.
and was duly impressed. I was also inspired by Adam Day's
[work](https://github.com/prosegrinder/pandoc-templates). I knew I didn't want
to lug around a bunch of custom configuration files for every project I tried to
convert with Pandoc. Hence, my little pet project was named the Pandoc Book Doctor.

The Pandoc Book Doctor is a single bash script that does all the heavy lifting.
With a single script, I can now take the same markup files and publish them to
a PDF, ePub or DocX file without having to maintain and alter several configurations.
A set of samples can be found in the `\examples` directory.
I can publish my markup files with a single script to a PDF, ePub, or DOCX file
without maintaining and altering several configurations. A set of sample conversions
can be found in the `\examples` directory.

Besides saving me some time and grief, this script may be helpful to
those who aren't interested in the peculiarities of modifying modern Latex
just to publish their content on different platforms. If that's you, enjoy!
those who aren't interested in the peculiarities of modifying modern Latex. There are
a lot of great templates out there if you like Latex. Unfortunately, none of this helps
mediate between Markdown and Pandocs.

This project is based on the principles of GNU's copyleft mantra. So, if
you would like to share additional template ideas or would like to offer
some general improvements, please feel free to create a PR.
Markdown certainly isn't as extensive as Latex for rendering concepts precisely as
envisioned, but that's why Markdown is everywhere, and Latex isn't. This script
has already made friends with Latex to make this process less daunting.

This project is based on the principles of GNU's copyleft mantra. So, if you
need to share, steal or modify this script--go for it.
## The Process

### >> Step One - Create the Project Template
Expand All @@ -33,25 +34,35 @@ Create a working template of a novel with the following:
```
bash doctor create <directory>
```
This will create a 5.5 x 8.5 novel template. The size can be adjusted later.
This command will create a 5.5 x 8.5 novel template. The size can easily be adjusted
later.

### >> Step Two - Edit Configuration Files
---
First check out the newly created configuration file, `metadata.yaml`.
First, check out where everything is in the newly created files, specifically: `metadata.yaml` and `front-matter.tex`. Then, note how the information in these files is referenced during each conversion.

The `front-matter.tex` is only used when producing a pdf file. When producing ePub documents, *all
latex* will be ignored. That is why some of the text from `front-matter.tex` is also present
in the `metadata.yaml` configuration file. The section under "rights" does not output to pdf,
but it does to ePub.

Here's a fair warning about exporting to a manuscript. I haven't made friends yet with the DOCX
template yet. The template I discovered *and robbed* from Adam Day's
[repository](https://github.com/prosegrinder/pandoc-templates) is already mostly there,
even without all the crazy lua. In the future, I may add character counts and try to
autofill some of the missing header data. Until then, a few quick runs with search/replace
should set the document up nicely.

Here's the file structure:
```
your-book/ # Your new book directory
your-book/ # the new book directory
|- metadata.yml # Metadata content (title, author...)
|- front-matter.tex # Provides a custom title page, copyright, epigraph, and dedication
|- *.md # Your book's chapter files
|- front-matter.tex # (pdf only) title page, copyright, epigraph, and dedication
|- *.md # the book's chapter files
|- publications/ # File output is placed here
|- images/ # Images folder
| |- cover.png # Cover page for epub
```
You'll also want to review, change and add additional files as needed. Please,
keep in mind that the starting numbers of each new file are important, as this will dictate
the order in which the documents are compiled by Pandoc.
You'll also want to review, change and add additional files as needed. Please remember that the starting numbers of each new file are essential, as this will dictate the order in which Pandoc compiles the documents.

There will be a directory called `images` created in your project file. Any images you wish
to include with your project should be copied here. The standard markdown reference to images
Expand All @@ -61,15 +72,15 @@ placed in this directory would be as follows:
![](images/crow.jpg)
```
You may want to refer to `markdown_guide.md` for creating MD files. More information about syntax
can be found in the [basic syntax guide](https://www.markdownguide.org/basic-syntax).
can be found in the [Markdown syntax guide](https://www.markdownguide.org/basic-syntax).

### >> Step Three - Compile Your Project
---
Lastly, you'll want to compile your project into a new format. Currently, there are three available
formats: ePub, Manuscript(DocX) and PDF. The output will be placed in a directory called `publication`.
Lastly, you'll want to compile your project into a new format. Currently, there are three available formats: ePub, Manuscript(DOCX), and PDF. The output is always generated inside the `publication`
directory.

```
bash doctor build <directory> <epub, manuscript or pdf>
bash doctor convert <directory> <epub, manuscript or pdf>
```
## Requirements
---
Expand Down
40 changes: 25 additions & 15 deletions doctor
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ if ! [ -x "$(command -v pandoc)" ]; then
echo 'Error: pandoc is not installed.' >&2
exit 1
fi
if ! [ -x "$(command -v pandoc-latex-extensions)" ]; then
echo 'Error: pandoc-latex-extensions is not installed. Please see README.md.' >&2
exit 1
fi

# # Create Project
# # # # # # # # # # # # # # # # # # # # # #
Expand All @@ -66,7 +70,15 @@ fi

# # Convert Project
# # # # # # # # # # # # # # # # # # # # # #
if [ "$action" == "build" ]; then
if [ "$action" == "convert" ]; then
if [ ! -f ${METADATA} ]; then
echo "Error: No project found at $directory."
exit 1
fi
if [ ! $format ]; then
echo "Error: No output format specified."
exit 1
fi
echo "Converting project in $directory"
if [ "$format" == "pdf" ]; then
if [ ! -d $directory/publications/${format} ]; then
Expand Down Expand Up @@ -96,17 +108,15 @@ fi

# # Help
# # # # # # # # # # # # # # # # # # # # # #
if [ "$action" == "help" ]; then
echo "Usage: doctor [action] [directory] [format]"
echo " action: create, build, help"
echo " "
echo "To Create a New Project:"
echo " doctor create <directory> <format>"
echo " Available Book formats: novel_5.5x8.5, novel_6x9"
echo " "
echo "To Build an Existing Project"
echo " doctor build <directory> <output>"
echo " Available output: pdf, epub, html, docx"
echo " "
exit 0
fi
echo "Usage: doctor [action] [directory] [format]"
echo " action: create, build, help"
echo " "
echo "To Create a New Project:"
echo " doctor create <directory> <format>"
echo " Available Book formats: novel_5.5x8.5, novel_6x9"
echo " "
echo "To Build an Existing Project"
echo " doctor convert <directory> <output>"
echo " Available output: pdf, epub, html, docx"
echo " "
exit 0

0 comments on commit 22c0d6c

Please sign in to comment.