forked from olegkrivtsov/using-zend-framework-3-book
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_book.php
More file actions
19 lines (15 loc) · 768 Bytes
/
create_book.php
File metadata and controls
19 lines (15 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
require "vendor/autoload.php";
#$Parsedown = new Parsedown();
$Parsedown = new ParsedownExtra(); # Parsedown Extra handles code blocks etc better
$template = file_get_contents('./template/template.html');
// output all files and directories except for '.' and '..'
foreach (new DirectoryIterator('./manuscript/en/') as $fileInfo) {
if($fileInfo->isDot()) continue;
if (!$fileInfo->isDir()) {
$content = file_get_contents('./manuscript/en/' . $fileInfo->getFilename());
$newFilename = substr_replace($fileInfo->getFilename() , 'html', strrpos($fileInfo->getFilename() , '.') +1);
$fullPage = str_replace("###CONTENT###", $Parsedown->text($content), $template);
file_put_contents('./book/en/' . $newFilename, $fullPage);
}
}