From 93cc857d685d51de5a9848c04292124a98dfaccd Mon Sep 17 00:00:00 2001
From: x-rodubou <romuald.dubourg@kereval.com>
Date: Wed, 13 Dec 2023 17:53:25 +0100
Subject: [PATCH] [Update] generation of pdf

---
 Makefile  | 23 +++++++++++++++++++++++
 README.md | 22 ++++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/Makefile b/Makefile
index 8373466..6265050 100755
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,18 @@ TEMPLATE_JEKYLL = _templates/jekyll-gazelle-documentation
 DOCS := $(filter-out _templates/,$(DOCS))
 DOCS := $(filter-out target/,$(DOCS))
 
+# Répertoire source où se trouvent les fichiers Markdown
+SOURCE_DIR := $(CURDIR)
+
+# Récupère tous les fichiers Markdown récursivement dans SOURCE_DIR
+MARKDOWN_FILES := $(shell find $(SOURCE_DIR) -type f -name "*.md")
+
+# Génère la liste des répertoires uniques où se trouvent les fichiers Markdown
+DIRS := $(sort $(dir $(MARKDOWN_FILES)))
+
+# Remplace l'extension .md par .pdf pour les fichiers cibles
+PDF_FILES := $(patsubst $(SOURCE_DIR)/%.md,$(OUTPUT_FOLDER)/%.pdf,$(MARKDOWN_FILES))
+
 all: clean jekyll $(DOCS)
 
 $(DOCS): force | $(OUTPUT_FOLDER)
@@ -62,6 +74,7 @@ copy_source_to_jekyll:
 	@echo "Done!"
 
 .PHONY: clean
+
 clean:
 	-rm -rf $(OUTPUT_FOLDER)
 	@for a in $(DOCS); do \
@@ -71,3 +84,13 @@ clean:
 					fi; \
 			done;
 			@echo "All clear!"
+
+# Règle par défaut pour générer tous les PDF. Attention avec les tableaux il peut y avoir des problèmes de rendu voir README
+pdf-gen: $(PDF_FILES)
+
+# Règle pour convertir un fichier Markdown en PDF
+$(OUTPUT_FOLDER)/%.pdf: $(SOURCE_DIR)/%.md
+	@mkdir -p $(@D) # Crée le répertoire cible s'il n'existe pas
+	cd $(dir $<) && pandoc  $<  -N -s --toc --pdf-engine=xelatex -o $(SOURCE_DIR)/$@
+
+
diff --git a/README.md b/README.md
index 9d7e1bc..c502fce 100755
--- a/README.md
+++ b/README.md
@@ -93,6 +93,28 @@ The YAML header is used by Jekyll and pandoc to generate menus and front pages,
 
 The YAML header is used by Jekyll and pandoc to generate menus and front pages, make sure all the metadata are present and up-to-date. The *.md files must start with the YAML header.
 
+## Conversion Markdown to Pdf files
+
+To generate pdf files use the command (might take some times)
+
+```bash
+sudo make -i pdf-gen
+```
+
+you can use 
+```bash
+sudo make clean 
+```
+to remove all generated files
+
+!!WARNING!!
+Be careful with table in markdown they may break your pdf if table are too big.
+
+In any case if your pdf is break you might want to use the extension markdown pdf with visual studio code.
+
+With this extension you can generate pdf one by one with command available in the extension.
+
+Table with this extension are correct 
 
 ## Links
 
-- 
GitLab