Skip to content

Commit

Permalink
#964: attempt to fix images and dates
Browse files Browse the repository at this point in the history
  • Loading branch information
commjoen committed Aug 31, 2018
1 parent 28c7099 commit b7ba05e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Document/0x00-Header.md
@@ -1,5 +1,5 @@

![OWASP LOGO](Images/OWASP_logo.png)
![OWASP LOGO](./Images/OWASP_logo.png)

# Mobile Application Security Testing Guide

Expand Down
39 changes: 36 additions & 3 deletions Tools/genpdf.js
@@ -1,4 +1,8 @@
var markdownpdf = require("markdown-pdf");
var markdownpdf = require("markdown-pdf")
, fs = require("fs")
, split = require("split")
, through = require("through")
, duplexer = require("duplexer");
//try to fix images https://github.com/alanshaw/markdown-pdf/issues/65
var lang = "";
var help = false;
Expand All @@ -23,7 +27,36 @@ if (!help) {
}

function runFrontispiece(){


}

function preProcessMd () {
// Split the input stream by lines
var splitter = split()

var replacer = through(function (data) {
this.queue(data.replace("[date]", setDate())+"\n")
})

splitter.pipe(replacer)
return duplexer(splitter, replacer)
}

function setDate(){
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {
dd = '0'+dd
}

if(mm<10) {
mm = '0'+mm
}

return mm + '/' + dd + '/' + yyyy;
}

function runPDF() {
Expand Down Expand Up @@ -68,7 +101,7 @@ function runPDF() {
],
bookPath = "./test.pdf";

markdownpdf()
markdownpdf({preProcessMd: preProcessMd})
.concat.from(mdDocs)
.to(bookPath, function() {
console.log("Created", bookPath);
Expand Down
6 changes: 5 additions & 1 deletion Tools/package.json
Expand Up @@ -9,6 +9,10 @@
"author": "Jeroen Willemsen",
"license": "MIT",
"dependencies": {
"markdown-pdf": "9.0.0"
"duplexer": "^0.1.1",
"fs": "0.0.1-security",
"markdown-pdf": "9.0.0",
"split": "^1.0.1",
"through": "^2.3.8"
}
}

0 comments on commit b7ba05e

Please sign in to comment.