From 73f2ae9d128127ad7420fcd924d18cd7351da1f5 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Wed, 10 May 2017 17:37:18 +0200 Subject: [PATCH] Outils de rédaction --- .gitignore | 5 +++++ 7seg.svg | 22 ++++++++++++++++++++++ CR.md | 36 ++++++++++++++++++++++++++++++++++++ Makefile | 20 ++++++++++++++++++++ configure | 20 ++++++++++++++++++++ html2pdf | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ md2html | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 18 ++++++++++++++++++ template.html | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 339 insertions(+), 0 deletions(-) create mode 100644 .gitignore create mode 100644 7seg.svg create mode 100644 CR.md create mode 100644 Makefile create mode 100755 configure create mode 100755 html2pdf create mode 100755 md2html create mode 100644 package.json create mode 100644 template.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9c33e70 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.pdf +*.tmp +*.html +!template.html +node_modules diff --git a/7seg.svg b/7seg.svg new file mode 100644 index 0000000..b6fe123 --- /dev/null +++ b/7seg.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + a + b + c + d + e + f + g + + diff --git a/CR.md b/CR.md new file mode 100644 index 0000000..c6d3e6a --- /dev/null +++ b/CR.md @@ -0,0 +1,36 @@ +# Tutorat de microprocesseurs - Sujet 8 - Thermostat +## DJERABA Taky - HUBERT Thomas - PREUD'HOMME Geoffrey + +# Brouillon + +Wouhou, on peut écrire en **gras** et en *italique*, des ~~conneries~~ bêtises, écrire des formules très complexes telles que $ax^2+bx+c=0$ et écrire du `petit code` et du gros code ! + +```avrasmplus +.equ RAMEND = 0x21FF +.equ SPH = 0x3E ; initialisation de la pile +.equ SPL = 0x3D + +.org 0x000 + ; Vecteur RESET + jmp debut + +.org 0x0080 + +debut: + ldi r16,0xFF ; On configure les ports A et B en sortie + out DDRA,r16 + out DDRB,r16 + r17 <- 0b00000001 ; 8 places de chenillard +``` + +Il faut passer une ligne pour faire un nouveau paragraphe. +Sinon ça marche pas. + +Là oui. + +On peut intégrer des images + +![Afficheur 7 segments](7seg.svg) + + + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2ecfe2a --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +.PHONY: default cleantmp clean + +default: $(subst md,pdf,$(wildcard *.md)) + +SOURCES=$(wildcard *.asm) $(wildcard *.txt) + +%.pdf: %.html + ./html2pdf -i "$<" -o "$@" -t "Tutorat de microprocesseurs S6 - TD1 Sujet 8" + +%.html: %.tmp template.html + ./md2html -i "$<" -o "$@" -t template.html + +%.tmp: %.md $(SOURCES) + markedpp "$<" > "$@" + +cleantmp: + rm -rf $(subst md,html,$(wildcard *.md)) *.tmp + +clean: cleantmp + rm -rf $(subst md,pdf,$(wildcard *.md)) diff --git a/configure b/configure new file mode 100755 index 0000000..c969def --- /dev/null +++ b/configure @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +echo "Vérification de la configuration système..." + +if ! which node &> /dev/null +then + echo "Veuillez installer NodeJS (sudo apt-get install nodejs npm)" + exit 1 +fi + +if ! which npm &> /dev/null +then + echo "Veuillez installer NPM (sudo apt-get install npm)" + exit 1 +fi + +echo "Préparation..." + +npm install + diff --git a/html2pdf b/html2pdf new file mode 100755 index 0000000..8095bd4 --- /dev/null +++ b/html2pdf @@ -0,0 +1,52 @@ +#!/usr/bin/env node + +// Imports +var fs = require('fs'); +var pdf = require('html-pdf'); +var yargs = require('yargs'); + + +// Understanding +var argv = yargs + .usage("Usage: $0 -o out.pdf [options]") + .example('$0 -i doc.pdf -o doc.pdf', 'Convert doc.html to PDF using the default values') + .help('h') + .alias('h', 'help') + + .describe('i', 'Input file') + .alias('i', 'input') + .default('i', '/dev/stdin') + + .describe('o', 'Output file') + .alias('o', 'output') + + .describe('t', 'Title of file') + .alias('t', 'title') + .default('t', 'Sans titre') + + .demandOption(['o']) + .argv; + + +// Settings +options = { + "base": "file://" + process.cwd() + '/', + "format": "A4", + "orientation": "portrait", + "border": "2cm", + + "footer": { + "height": "10mm", + "contents": { + default: '
' + argv.title + '
{{page}}/{{pages}}
', + } + }, +} + +// Reading +htmlString = fs.readFileSync(argv.i, "utf8"); + +// Conversion +pdf.create(htmlString, options).toFile(argv.o, function(err, res) { + if (err) console.error(err); +}); diff --git a/md2html b/md2html new file mode 100755 index 0000000..9cfd340 --- /dev/null +++ b/md2html @@ -0,0 +1,107 @@ +#!/usr/bin/env node + +// Imports +var fs = require('fs'); +var marked = require('marked'); +var highlight = require('highlight.js'); +var katex = require('katex'); +var yargs = require('yargs'); +var extend = require('util')._extend; + + +// Constants +var template = ' %TITLE%
%BODY%
' + + +// Understanding +var argv = yargs + .usage("Usage: $0 [options]") + .example('$0 -i doc.md -o doc.html', 'Convert doc.md to HTML using the default template') + .help('h') + .alias('h', 'help') + + .describe('i', 'Input file') + .alias('i', 'input') + .default('i', '/dev/stdin') + + .describe('o', 'Output file') + .alias('o', 'output') + .default('o', '/dev/stdout') + + .describe('t', 'Template file (%BODY% is replaced by the text)') + .alias('t', 'template') + + .argv; + +if (argv.t) { + template = fs.readFileSync(argv.t, "utf8"); +} + + +// Settings + +var extraLangages = { + avrpseudo: function (hljs) { + lang = extend({}, highlight.getLanguage('avrasm')); + lang.keywords.keyword += 'Si Alors Sinon FinSi TantQue FinTantQue Pour FinPour allant de à ←'; + lang.keywords.keyword += 'Lire Sortir sur Appeler Retourner'; + lang.keywords.keyword += 'DecalerDroite DecalerGauche'; + lang.keywords.built_in += ' vrai faux'; + return lang; + }, + avrasmplus: function (hljs) { + lang = extend({}, highlight.getLanguage('avrasm')); + lang.keywords.keyword += ' si saut alors et ou if then goto && || <-'; + lang.contains.push({ + className: 'meta', + begin: /@\w+/, + }); + return lang; + }, +}; + +for (lang in extraLangages) { + // This must be done before any call to highlight.highlight :/ + highlight.registerLanguage(lang, extraLangages[lang]); +} + +var renderer = new marked.Renderer(); +marked.setOptions({ + highlight: function (code, lang) { + if (highlight.getLanguage(lang)) { + return highlight.highlight(lang, code).value; + } else { + // if (extraLangages[lang]) { + // highlight.registerLanguage(lang, extraLangages[lang]); + // return highlight.highlight(lang, code).value; + // } else { + // } + console.warn("Unknown language: " + lang); + return highlight.highlightAuto(code).value; + } + } +}); + + +// Processing +markdownString = fs.readFileSync(argv.i, "utf8"); + +// TeX +markdownString = markdownString.replace(/\\\$/g, '$') +markdownString = markdownString.replace(/\$\$([\s\S]+)\$\$/gm, function(glob, formula) { + return katex.renderToString(formula, {displayMode: true}); +}); +markdownString = markdownString.replace(/\$([^$]+)\$/g, function(glob, formula) { + return katex.renderToString(formula, {displayMode: false}); +}); + +// Conversion +htmlString = marked(markdownString, {renderer: renderer}); +fullHtmlString = template.replace('%BODY%', htmlString); + +// Saving +if (argv.o == '/dev/stdout') { + console.log(fullHtmlString); +} else { + fs.writeFileSync(argv.o, fullHtmlString); +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..6054ff5 --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "s6-mp-tutorat", + "version": "1.0.0", + "description": "Tutorat de microprocesseurs S6 - TD1 Sujet 8", + "main": "index.js", + "repository": { + "type": "git", + "url": "https://archives.plil.fr/gbontoux/s6-mp-tutorat" + }, + "author": "GeoffreyFrogeye", + "license": "GPL-3.0", + "dependencies": { + "highlight.js": "^9.11.0", + "katex": "^0.7.1", + "marked": "^0.3.6", + "yargs": "^8.0.1" + } +} diff --git a/template.html b/template.html new file mode 100644 index 0000000..7db139a --- /dev/null +++ b/template.html @@ -0,0 +1,59 @@ + + + + + + + + + + + %TITLE% + + + +
+%BODY% +
+ + + -- libgit2 0.21.2