Skip to content

Commit

Permalink
Compile epub/pdf with images, toc and cover using pandoc in the CI
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae committed Jun 1, 2021
1 parent d867f18 commit a1f79e1
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 19 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Make PDF using pandoc

jobs:
make_pdf:
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
steps:
- uses: actions/checkout@v2
- run: |
sudo apt install pandoc texlive
make pdf
make epub
- uses: actions/upload-artifact@master
with:
path: r2book.*
30 changes: 29 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,35 @@ node_modules:
mkdir -p node_modules
npm i

# CHAPTERS=$(shell find src -iname *.md)
CHAPTERS=$(shell grep -Eoi '\([^\)]+' src/SUMMARY.md | sed -e 's,^.,src/,')
PANDOC_PDF_OPTIONS+=-V papersize:a3
PANDOC_PDF_OPTIONS+=-V geometry:margin=1.5cm
PANDOC_PDF_OPTIONS+=--pdf-engine=xelatex
PANDOC_PDF_OPTIONS+=--resource-path=img
PANDOC_PDF_OPTIONS+=--toc-depth=5 --toc
PANDOC_PDF_OPTIONS+=-B src/COVER.md
# PANDOC_OPTIONS+=--template md.template
PANDOC_EPUB_OPTIONS+=-V papersize:a3
PANDOC_EPUB_OPTIONS+=-V geometry:margin=1.5cm
PANDOC_EPUB_OPTIONS+=--resource-path=img
PANDOC_EPUB_OPTIONS+=--toc-depth=5 --toc
PANDOC_EPUB_OPTIONS+=--epub-cover-image=cover.jpg

pdf:
# Cant add images because of this bug: https://github.com/jgm/pandoc/issues/3752
# pandoc src/**/*.md --verbose --pdf-engine=xelatex -o r2book.pdf
pandoc src/**/*.md --pdf-engine=xelatex -o r2book.pdf
# pandoc src/**/*.md --pdf-engine=xelatex -o r2book.pdf
rm -rf img ; mkdir -p img ; for a in $(shell find src | grep png$$) ; do cp $$a img ; done
cp cover.jpg img
pandoc $(CHAPTERS) $(PANDOC_OPTIONS) -o r2book.pdf
rm -rf img

epub:
# Cant add images because of this bug: https://github.com/jgm/pandoc/issues/3752
# pandoc src/**/*.md --verbose --pdf-engine=xelatex -o r2book.pdf
# pandoc src/**/*.md --pdf-engine=xelatex -o r2book.pdf
rm -rf img ; mkdir -p img ; for a in $(shell find src | grep png$$) ; do cp $$a img ; done
cp cover.jpg img
pandoc $(CHAPTERS) $(PANDOC_EPUB_OPTIONS) -o r2book.epub
rm -rf img
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ This book is an updated version (started by maijin) of the original
radare1 book (written by pancake). Please contribute by updating and
improving the contents.

* Github: [https://github.com/radareorg/radare2book](https://github.com/radareorg/radare2book)
* Github: [https://github.com/radareorg/radare2-book](https://github.com/radareorg/radare2-book)
* Online: [https://book.rada.re/](https://book.rada.re/)


[![mdbook](https://github.com/radareorg/radare2book/actions/workflows/mdbook.yml/badge.svg)](https://github.com/radareorg/radare2book/actions/workflows/mdbook.yml)
[![pandoc](https://github.com/radareorg/radare2book/actions/workflows/pandoc.yml/badge.svg)](https://github.com/radareorg/radare2book/actions/workflows/pandoc.yml)
[![mdbook](https://github.com/radareorg/radare2-book/actions/workflows/mdbook.yml/badge.svg)](https://github.com/radareorg/radare2-book/actions/workflows/mdbook.yml)
[![pandoc](https://github.com/radareorg/radare2-book/actions/workflows/pandoc.yml/badge.svg)](https://github.com/radareorg/radare2-book/actions/workflows/pandoc.yml)
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "radare2book",
"name": "radare2-book",
"version": "1.0.0",
"description": "the official radare2 book",
"scripts": {
Expand All @@ -9,14 +9,14 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/radareorg/radare2book.git"
"url": "git+https://github.com/radareorg/radare2-book.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/radareorg/radare2book/issues"
"url": "https://github.com/radareorg/radare2-book/issues"
},
"homepage": "https://github.com/radareorg/radare2book#readme",
"homepage": "https://github.com/radareorg/radare2-book#readme",
"dependencies": {
"gitbook-cli": "^2.3.2"
}
Expand Down
3 changes: 3 additions & 0 deletions src/COVER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cover
![cover](cover.jpg)
cover2
4 changes: 3 additions & 1 deletion src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ updated by many contributors over the Internet.

Check the Github site to add new contents or fix typos:

* Github: [https://github.com/radareorg/radare2book](https://github.com/radareorg/radare2book)
* Github: [https://github.com/radareorg/radare2-book](https://github.com/radareorg/radare2-book)
* PDF: [GHA Artifacts](https://github.com/radareorg/radare2-book/releases)
* EPUB: [GHA Artifacts](https://github.com/radareorg/radare2-book/releases)
* Online: [https://book.rada.re/](https://book.rada.re/)
2 changes: 1 addition & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
* [Entrypoint](tools/rabin2/entrypoints.md)
* [Imports](tools/rabin2/imports.md)
* [Exports](tools/rabin2/exports.md)
* [Symbols (exports)](tools/rabin2/symbols.md)
* [Symbols](tools/rabin2/symbols.md)
* [Libraries](tools/rabin2/libraries.md)
* [Strings](tools/rabin2/strings.md)
* [Program Sections](tools/rabin2/program_sections.md)
Expand Down
2 changes: 1 addition & 1 deletion src/crackmes/avatao/01-reverse4/radare2.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ use the git version!
Some highly recommended reading materials:

- [Cheatsheet by pwntester](https://github.com/pwntester/cheatsheets/blob/master/radare2.md)
- [Radare2 Book](https://www.gitbook.com/book/radareorg/radare2book/details)
- [Radare2 Book](https://www.gitbook.com/book/radareorg/radare2-book/details)
- [Radare2 Blog](http://radare.today)
- [Radare2 Wiki](https://github.com/radareorg/radare2/wiki)
2 changes: 1 addition & 1 deletion src/crackmes/ioli/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ IOLI CrackMes

The IOLI crackme is a good starting point for learning r2. This is a set of tutorials based on the tutorial at [dustri](http://dustri.org/b/defeating-ioli-with-radare2.html)

The IOLI crackmes are available at a locally hosted [mirror](https://github.com/radareorg/radare2book/raw/master/src/crackmes/ioli/IOLI-crackme.tar.gz)
The IOLI crackmes are available at a locally hosted [mirror](https://github.com/radareorg/radare2-book/raw/master/src/crackmes/ioli/IOLI-crackme.tar.gz)
2 changes: 1 addition & 1 deletion src/first_steps/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Radare2 Book

If you want to contribute to the Radare2 book, you can do it at the [Github repository](https://github.com/radareorg/radare2book).
If you want to contribute to the Radare2 book, you can do it at the [Github repository](https://github.com/radareorg/radare2-book).
Suggested contributions include:

* Crackme writeups
Expand Down
2 changes: 1 addition & 1 deletion src/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ updated by many contributors over the Internet.

Check the Github site to add new contents or fix typos:

* Github: [https://github.com/radareorg/radare2book](https://github.com/radareorg/radare2book)
* Github: [https://github.com/radareorg/radare2-book](https://github.com/radareorg/radare2-book)
* Online: [https://book.rada.re/](https://book.rada.re/)
6 changes: 3 additions & 3 deletions src/visual_mode/visual_assembler.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
You can use Visual Mode to assemble code using `A`.
For example let's replace the `push` by a `jmp`:

![Before](../pics/before.png)
![Before](before.png)

Notice the preview of the disassembly and arrows:

![After](../pics/after.png)
![After](after.png)

You need to open the file in writing mode (`r2 -w` or `oo+`) in order to patch the file.
You can also use the cache mode: `e io.cache = true` and `wc?`.

Remember that patching files in debug mode only patch the memory not the file.
Remember that patching files in debug mode only patch the memory not the file.
5 changes: 3 additions & 2 deletions styles/pdf.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ h1,h2,h3,h4 {
line-height: 0.9;
}

img[alt=cover] { display: inline-block; }

img {
display: block;
margin-left: auto;
margin-right: auto;
}

.markdown-section h1, h1
{
.markdown-section h1, h1 {
margin-bottom: 0px;
margin-left: 25px;
}
Expand Down

0 comments on commit a1f79e1

Please sign in to comment.