Skip to content

Commit 8f8ea9f

Browse files
committed
feat: melhorar geração de eBooks e adicionar documentação
- Atualiza o workflow para instalar LaTeX e fontes adicionais - Modifica o Dockerfile para incluir suporte a locais em português - Adiciona novos arquivos EPUB e PDF gerados - Cria documentação sobre customização da geração de eBooks - Adiciona roadmap para melhorias futuras nos eBooks - Atualiza script de geração para ler capítulos de forma recursiva
1 parent 7a3e8cd commit 8f8ea9f

8 files changed

Lines changed: 490 additions & 23 deletions

File tree

.github/workflows/generate-ebook.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,16 @@ jobs:
2626
- name: Install dependencies
2727
run: yarn install --frozen-lockfile
2828

29-
- name: Install Pandoc
29+
- name: Install Pandoc and LaTeX
3030
run: |
3131
sudo apt-get update
32-
sudo apt-get install -y pandoc texlive-xetex texlive-fonts-recommended texlive-plain-generic
32+
sudo apt-get install -y \
33+
pandoc \
34+
texlive-xetex \
35+
texlive-fonts-recommended \
36+
texlive-fonts-extra \
37+
texlive-plain-generic \
38+
texlive-lang-portuguese
3339
3440
- name: Generate combined Markdown
3541
run: node scripts/generate-ebook.js
@@ -44,6 +50,9 @@ jobs:
4450
-V geometry:margin=1in \
4551
-V documentclass=book \
4652
-V lang=pt-BR \
53+
-V mainfont="DejaVu Serif" \
54+
-V sansfont="DejaVu Sans" \
55+
-V monofont="DejaVu Sans Mono" \
4756
--metadata title="Programação Orientada a Gambiarra" \
4857
--metadata author="Josenaldo Matos Filho"
4958
@@ -53,7 +62,6 @@ jobs:
5362
-o public/downloads/livro-pog.epub \
5463
--toc \
5564
--toc-depth=2 \
56-
--epub-cover-image=public/images/capitulos/introducao.jpg \
5765
--metadata title="Programação Orientada a Gambiarra" \
5866
--metadata author="Josenaldo Matos Filho" \
5967
--metadata lang=pt-BR

Dockerfile.ebook

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@ FROM ubuntu:22.04
22

33
# Avoid interactive prompts during installation
44
ENV DEBIAN_FRONTEND=noninteractive
5+
ENV LANG=pt_BR.UTF-8
6+
ENV LANGUAGE=pt_BR:pt
7+
ENV LC_ALL=pt_BR.UTF-8
8+
9+
# Install locales first
10+
RUN apt-get update && apt-get install -y locales && \
11+
locale-gen pt_BR.UTF-8 && \
12+
update-locale LANG=pt_BR.UTF-8
513

614
# Install Pandoc and LaTeX
715
RUN apt-get update && apt-get install -y \
816
pandoc \
917
texlive-xetex \
1018
texlive-fonts-recommended \
19+
texlive-fonts-extra \
1120
texlive-plain-generic \
1221
texlive-lang-portuguese \
1322
&& rm -rf /var/lib/apt/lists/*

public/downloads/livro-pog.epub

199 KB
Binary file not shown.

public/downloads/livro-pog.pdf

339 KB
Binary file not shown.

scripts/CUSTOMIZATION.md

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
# Customização da Geração de eBooks
2+
3+
Este documento detalha as opções de customização para a geração de PDF e EPUB.
4+
5+
## Melhorias Possíveis
6+
7+
### 1. **Formatação do PDF**
8+
9+
#### Opções de Layout
10+
11+
```bash
12+
# Margens personalizadas
13+
-V geometry:margin=1.5in
14+
-V geometry:top=2cm,bottom=2cm,left=3cm,right=3cm
15+
16+
# Tamanho da página
17+
-V papersize=a4
18+
-V papersize=letter
19+
20+
# Fonte
21+
-V mainfont="Arial"
22+
-V monofont="Courier New"
23+
-V fontsize=12pt
24+
```
25+
26+
#### Opções de Estilo
27+
28+
```bash
29+
# Tipo de documento
30+
-V documentclass=book # (atual)
31+
-V documentclass=report # alternativa
32+
-V documentclass=article # mais simples
33+
34+
# Numeração de capítulos
35+
-V numbersections
36+
-V secnumdepth=2
37+
38+
# Header/Footer personalizados
39+
-V header-includes='\usepackage{fancyhdr}'
40+
```
41+
42+
#### Capa Personalizada
43+
44+
```bash
45+
# Adicionar capa
46+
--epub-cover-image=public/images/capa.jpg
47+
48+
# Adicionar metadados
49+
--metadata title="Programação Orientada a Gambiarra"
50+
--metadata author="Josenaldo Matos Filho"
51+
--metadata subject="Humor técnico"
52+
--metadata keywords="programação,gambiarra,humor"
53+
```
54+
55+
### 2. **Formatação do EPUB**
56+
57+
```bash
58+
# Folha de estilo customizada
59+
--css=styles/ebook.css
60+
61+
# Metadados adicionais
62+
--epub-metadata=metadata.xml
63+
64+
# Fontes embarcadas
65+
--epub-embed-font=fonts/*.ttf
66+
```
67+
68+
### 3. **Imagens**
69+
70+
Atualmente apenas uma imagem é incluída. Para incluir todas:
71+
72+
**Opção 1: Copiar imagens para o Docker**
73+
74+
```bash
75+
docker run --rm \
76+
-v "$(pwd)/public:/workspace" \
77+
livro-pog-ebook-builder \
78+
pandoc ...
79+
```
80+
81+
**Opção 2: Remover imagens do markdown**
82+
Adicionar ao `generate-ebook.js`:
83+
84+
```javascript
85+
function removeImages(content) {
86+
return content.replace(/!\[([^\]]*)\]\([^)]+\)/g, '');
87+
}
88+
```
89+
90+
### 4. **Índice (TOC)**
91+
92+
```bash
93+
# Profundidade do índice
94+
--toc-depth=3 # até h3
95+
--toc-depth=2 # até h2 (atual)
96+
--toc-depth=1 # só h1
97+
98+
# Título do índice
99+
-V toc-title="Índice"
100+
```
101+
102+
### 5. **Tipografia Avançada (XeLaTeX)**
103+
104+
```bash
105+
# Suporte a caracteres especiais
106+
-V mainfont="DejaVu Serif"
107+
-V sansfont="DejaVu Sans"
108+
-V monofont="DejaVu Sans Mono"
109+
110+
# Espaçamento
111+
-V linestretch=1.5 # espaçamento entre linhas
112+
-V indent # indentar parágrafos
113+
```
114+
115+
### 6. **Quebras de Página**
116+
117+
Atualmente usa `\newpage` entre capítulos. Opções:
118+
119+
```javascript
120+
// Sempre começar capítulo em página ímpar
121+
combinedContent += '\\cleardoublepage\n\n';
122+
123+
// Adicionar quebra antes de seções
124+
combinedContent += '\\pagebreak\n\n';
125+
```
126+
127+
### 7. **Metadados Avançados**
128+
129+
Criar arquivo `metadata.yaml`:
130+
131+
```yaml
132+
---
133+
title: Programação Orientada a Gambiarra
134+
subtitle: Um Guia Completo
135+
author: Josenaldo Matos Filho
136+
date: 2024
137+
lang: pt-BR
138+
rights: © 2024 Josenaldo Matos Filho. CC BY-NC-SA 4.0
139+
publisher: Auto-publicado
140+
description: |
141+
Um livro satírico sobre as gambiarras no desenvolvimento de software.
142+
---
143+
```
144+
145+
Usar no Pandoc:
146+
147+
```bash
148+
pandoc metadata.yaml livro-pog-combined.md -o livro.pdf ...
149+
```
150+
151+
### 8. **Templates Customizados**
152+
153+
Criar template LaTeX customizado:
154+
155+
```bash
156+
pandoc -D latex > template.tex
157+
# Editar template.tex
158+
pandoc --template=template.tex ...
159+
```
160+
161+
---
162+
163+
## Exemplos de Customizações Comuns
164+
165+
### PDF Bonito (margens maiores, fonte maior)
166+
167+
```bash
168+
pandoc combined.md -o livro.pdf \
169+
--pdf-engine=xelatex \
170+
--toc --toc-depth=2 \
171+
-V geometry:margin=1.5in \
172+
-V fontsize=12pt \
173+
-V linestretch=1.3 \
174+
-V mainfont="DejaVu Serif" \
175+
-V documentclass=book \
176+
-V lang=pt-BR
177+
```
178+
179+
### EPUB com CSS customizado
180+
181+
```bash
182+
pandoc combined.md -o livro.epub \
183+
--toc --toc-depth=2 \
184+
--css=styles/custom.css \
185+
--epub-cover-image=capa.jpg \
186+
--metadata title="..." \
187+
--metadata author="..."
188+
```
189+
190+
### PDF sem imagens
191+
192+
Modificar `generate-ebook.js`:
193+
194+
```javascript
195+
function fixImagePaths(content) {
196+
// Remover todas as imagens
197+
return content.replace(/!\[([^\]]*)\]\([^)]+\)/g, '');
198+
}
199+
```
200+
201+
---
202+
203+
## Aplicar Customizações
204+
205+
1. **Editar scripts:**
206+
- `scripts/generate-ebook.js` - lógica de combinação
207+
- `scripts/docker-generate.sh` - comandos Pandoc
208+
- `.github/workflows/generate-ebook.yml` - CI/CD
209+
210+
2. **Testar localmente:**
211+
212+
```bash
213+
yarn ebook:docker:all
214+
```
215+
216+
3. **Commitar mudanças**

0 commit comments

Comments
 (0)