[Batch - Python] Github Markdown vers PDF

Arcadia_sama

Etudiant en informatique
Ancien
19 Juin 2017
44
10
78
25
Bonjour,

Ce post est réservé pour une audience relativement limitée. Je le poste juste au cas où.

Voici une commande utilisable sur console que j'ai fais pour un projet personnel. Je me suis dis qu'il était opportun de le poster sur le forum bien qu'elle possède tout de même de nombreuses lacunes et requière des installations lourdes (python, pandoc et pdflatex). La commande est encore en phase de beta-test. Un système de mise à jour est intégré pour permettre aux utilisateurs éventuels de télécharger les prochaines versions.

L'idée de cette commande m'est venue en rédigeant le README.md d'un dépôt github. Le fichier contenait toutes les informations qu'un rapport de projet contiendrait en temps normal avec les descriptions, le concept, les idées et le processus de pensée. J'ai donc créé cette commande afin de convertir le fichier README.md en PDF en passant par Latex pour formatter le fichier et ainsi pouvoir utiliser la syntaxe simple de MARKDOWN GITHUB pour écrire mon rapport tout en profitant de Latex.

Cette commande converti tout fichier .md en mardown de github en PDF en utilisant une conversion vers un format Latex. Elle utilise pandoc, un script python et pdflatex. Par défaut, la commande téléchargera un fichier Main.tex dans le dossier temporaire qui sera le fichier Latex racine. Ce dernier inclut les tags d'initialisation, la page de garde et la table des matères générée par Latex automatiquement. Le fichier Latex racine est un modèle. Vous êtes libre de le modifier. Notez que si le fichier Main.tex est introuvable, il sera retéléchargé et réinitialisé.

Environnement de développement :
Windows 10 - 64 bits

Environnement compatible
Aucun environnement n'a encore pu être testé.

Commandes externes utilisées :

Aide et description en anglais (disponible via l'option /?):
Code:
This command will convert any github markdown file to PDF while reformatting it using
a Latex format file. It uses pandoc, a python script and pdflatex. By default, the command
will download a Main.tex file in the temp folder which will be the root Latex file.

This file include all boot tags, the coverpage and the table of contents generated by Latex
automatically. The downloaded file is a template. Feel free to edit it.
Note that if the file is deleted, it will be redownloaded and reloaded.


Syntax: convert <Input filename> <Output filename> [options]
  Input filename  : Name of the input file.
  Output filename : Name of the file which will receive the result of the
                    conversion without extension.

Options :
  --overwrite     : Option to overwrite, disabled by default, the contentof any file
                    named as the given output filename with the result of the conversion.
  --update        : Update the command to the latest release.
  --force-update  : Force the update even if the version is already up-to-date.
  --check-update  : Search for the latest release.
  --version       : Stop the execution to only display the version header.

Error codes index:
  [0] The process ended without any errors.
  [1] The process couldn't find the given input filename.
  [2] The conversion failed to LATEX from GITHUB MARKDOWN or the outputed result/file
      from the conversion couldn't be found by the process.
  [3] The process found a file already named as the given output PDF filename.
  [4] The conversion failed to PDF from LATEX or the outputed result/file
      from the conversion couldn't be found by the process.
  [5] The Main.tex file used for the generation of PDF could not be found and downloaded.
  [6] The format.py script used to reformat Latex file could not be found and downloaded.
  [7] One the following required command is not installed :
         - pandoc (https://pandoc.org/)
         - pdflatex (https://miktex.org/)
         - py (https://www.python.org/)


Outre les commandes requises (pandoc, pdflatex et py), les fichiers auxiliaires (Main.tex et format.py) sont téléchargés automatiquement.
Vous pouvez trouver le code ici : https://joan-teriihoania.fr/program/convert/updater/download.php?filename=convert.bat&download=true. Je vous donne le lien pour que vous puissiez télécharger la dernière version mise en ligne. Ainsi que pour éviter les incompatibilités de mise à jour.

A titre d'exemple, vous trouverez joint à ce message la génération du fichier README.md du dépôt : https://gist.github.com/PurpleBooth/109311bb0361f32d87a2.


Cordialement,
Arcadia_sama.
 

Fichiers joints

Dernière édition: