-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Completely rework the file structure and the project ideology 🛸
- Loading branch information
Showing
15 changed files
with
111 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,36 +3,36 @@ name: Build and Push PDF Document | |
on: | ||
push: | ||
paths: | ||
- '.github/workflows/*' | ||
- 'md/*' | ||
- ".github/workflows/*" | ||
- "docs/md/*" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
container: | ||
|
||
container: | ||
image: knsit/pandoc:latest | ||
options: --user root | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build PDF | ||
run: | | ||
cd "$SOURCE_DIR" | ||
pandoc -s -o "$DEST_FILE_NAME" -f "$SOURCE_FORMAT" --data-dir="$DATA_DIR" --template "$TEMPLATE" --toc --listings --columns=50 --number-sections --dpi=300 --pdf-engine xelatex -M date="$(date +%Y-%m-%d)" md/HEADER.YAML md/*.md | ||
pandoc -s -o "$DEST_FILE_NAME" -f "$SOURCE_FORMAT" --data-dir="$DATA_DIR" --template "$TEMPLATE" --toc --listings --columns=50 --number-sections --dpi=300 --pdf-engine xelatex -M date="$(date +%Y-%m-%d)" docs/md/HEADER.YAML docs/md/*.md | ||
env: | ||
DEST_FILE_NAME: "artifact.pdf" | ||
DEST_FILE_NAME: "docs/artifact.pdf" | ||
TEMPLATE: "eisvogel.tex" | ||
SOURCE_FORMAT: markdown_strict+backtick_code_blocks+pipe_tables+auto_identifiers+yaml_metadata_block+implicit_figures+table_captions+footnotes+smart+escaped_line_breaks+header_attributes | ||
DATA_DIR: pandoc | ||
DATA_DIR: docs/pandoc | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: artifact | ||
path: artifact.pdf | ||
path: docs/artifact.pdf | ||
|
||
push_pdf: | ||
needs: build | ||
|
@@ -47,12 +47,12 @@ jobs: | |
uses: actions/download-artifact@v4 | ||
with: | ||
name: artifact | ||
path: . | ||
path: docs/. | ||
|
||
- name: Commit PDF | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add artifact.pdf | ||
git add docs/artifact.pdf | ||
git commit -m "Add or update PDF" || echo "No changes to commit" | ||
git push | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,17 @@ | ||
# pdf-from-markdown | ||
|
||
This repository is an exploration of how to generate a PDF from a Markdown file using Pandoc. | ||
A fast and efficient way to generate PDF files from Markdown files. Perfect for markdown enjoyers that need to communicate with pdf lovers. | ||
|
||
## Requirements | ||
## Get Started | ||
|
||
- [Pandoc](https://pandoc.org/) | ||
- [LaTeX](https://www.latex-project.org/get/) | ||
- Latex packages : <br> | ||
```sudo tlmgr install adjustbox footnotebackref pagecolor csquotes mdframed zref needspace sourcesanspro sourcecodepro titling selnolig lualatex-math``` (for Mac users) | ||
|
||
## Usage | ||
|
||
There are three levels of complexity: | ||
|
||
### 1. A simple PDF file with no special formatting. | ||
|
||
To generate the PDF, run the following command: | ||
|
||
```bash | ||
pandoc README.md -o README.pdf | ||
``` | ||
|
||
[And here is the result !](README.pdf) | ||
|
||
### 2. Usage of a template to generate a PDF with a title page and better looking. | ||
|
||
We are using the template eisvogel.tex from the [pandoc-latex-template](https://github.com/Wandmalfarbe/pandoc-latex-template) repository. | ||
|
||
To generate the PDF, run the following command: | ||
To set up the generation of the PDF files, navigate to your project folder and run the following command: | ||
|
||
```bash | ||
pandoc -s -o document.pdf -f markdown_strict+backtick_code_blocks+pipe_tables+auto_identifiers+yaml_metadata_block+implicit_figures+table_captions+footnotes+smart+escaped_line_breaks+header_attributes --data-dir=pandoc --template eisvogel.tex --toc --listings --columns=50 --number-sections --dpi=300 --pdf-engine xelatex -M date="$(date +%Y-%m-%d)" md/HEADER.YAML md/*.md | ||
git archive --remote=https://github.com/Nishogi/pdf-from-markdown.git | tar -x | ||
``` | ||
[And here is the result !](document.pdf) | ||
|
||
### 3. Automate the generation of the PDF using GitHub Actions. | ||
|
||
See the [GitHub Actions workflow file](.github/workflows/pandoc.yml) for more details. | ||
Now, upon push, the Markdown files in the `docs/md` directory are compiled into a single PDF file and pushed to the `docs` directory. | ||
|
||
And the artifacts generated by the workflow are available in the [Actions tab](https://github.com/Nishogi/pdf-from-markdown/actions/) of this repository. | ||
## Contributing | ||
|
||
It is also pushed [at the root of the repository.](artifact.pdf) | ||
Feel free to use and/or contribute to the project! |
Binary file not shown.
Binary file not shown.
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Introduction | ||
|
||
This document explores how to generate a PDF from a Markdown file using Pandoc. | ||
|
||
## Requirements | ||
|
||
Here are the requirements for each level of complexity described in the next section: | ||
|
||
### Level 1 | ||
|
||
- [Pandoc](https://pandoc.org/) | ||
- [LaTeX](https://www.latex-project.org/get/) | ||
|
||
### Level 2 | ||
|
||
- Pandoc | ||
- LaTeX | ||
- LaTeX packages: | ||
```bash | ||
sudo tlmgr install adjustbox footnotebackref pagecolor csquotes mdframed zref needspace sourcesanspro sourcecodepro titling selnolig lualatex-math | ||
``` | ||
(for Mac users) | ||
|
||
### Level 3 | ||
|
||
None! Everything is done in a container in the cloud. | ||
|
||
## Contributors | ||
|
||
This is a small project I did in my free time to help generate good-looking documentation for my school projects. Feel free to make pull requests! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Usage | ||
|
||
There are three levels of complexity: | ||
|
||
## Simple PDF Generation | ||
|
||
To generate a basic PDF without special formatting, use: | ||
|
||
```bash | ||
pandoc <file.md> -o <file.pdf> | ||
``` | ||
|
||
## Enhanced PDF with Template | ||
|
||
To generate a PDF that uses the `eisvogel.tex` template from the [pandoc-latex-template](https://github.com/Wandmalfarbe/pandoc-latex-template) repository, use: | ||
|
||
```bash | ||
pandoc -s -o <file.pdf> -f markdown_strict+backtick_code_blocks+pipe_tables+auto_identifiers+yaml_metadata_block+implicit_figures+table_captions+footnotes+smart+escaped_line_breaks+header_attributes --data-dir=pandoc --template eisvogel.tex --toc --listings --columns=50 --number-sections --dpi=300 --pdf-engine=xelatex -M date="$(date +%Y-%m-%d)" md/HEADER.YAML md/*.md | ||
``` | ||
|
||
Ensure your directory structure is as follows: | ||
|
||
```plaintext | ||
. | ||
+-- assets | ||
| +-- (...) | ||
| +-- your-assets.png | ||
+-- md | ||
| +-- (...) | ||
| +-- your-files.md | ||
| +-- HEADER.YAML | ||
+-- pandoc | ||
+-- templates | ||
+-- eisvogel.tex | ||
``` | ||
|
||
## Automated PDF Generation with GitHub Actions | ||
|
||
Artifacts generated by the workflow are available in the [Actions tab](https://github.com/Nishogi/pdf-from-markdown/actions) of this repository and are also pushed to the root of the `docs` folder. | ||
|
||
For more details, check the GitHub workflow file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Sources | ||
|
||
Markdown Syntax | ||
|
||
> https://www.markdownguide.org/basic-syntax/ | ||
![Markdown Cheatsheet](docs/assets/cheatsheet.png) | ||
|
||
CI with Pandoc | ||
|
||
> https://gitlab.com/pandoc/pandoc-ci-example | ||
Templating with Pandoc | ||
|
||
> https://github.com/alexeygumirov/pandoc-for-pdf-how-to | ||
GitHub Actions | ||
|
||
> https://docs.github.com/en/actions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.