Skip to content

Commit

Permalink
Merge pull request #42 from Hi-Folks/fix/41-css-https
Browse files Browse the repository at this point in the history
Fix SSL error using external CSS for ePub creation
  • Loading branch information
roberto-butti authored Dec 2, 2024
2 parents ea2200d + 1d38cec commit 91c5fa9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 2.0.6 - 2nd December 2024
- fix SSL error using external CSS for epub creation

## 2.0.5 - 28th November 2024
- fix spaces in code block for epub

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"ext-json": "*",
"ext-mbstring": "*",
"ext-zlib": "*",
"ext-openssl": "*",
"hi-folks/phpepub": "^1.0.0",
"illuminate/filesystem": "^10.0|^11.0",
"illuminate/support": "^10.0|^11.0",
Expand Down
12 changes: 7 additions & 5 deletions src/Commands/BuildEpubCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected function buildEpub(
. "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n"
. "<head>"
. "<meta http-equiv=\"Default-Style\" content=\"text/html; charset=utf-8\" />\n"
. "<link rel=\"stylesheet\" type=\"text/css\" href=\"github.css\" />\n"
. "<link rel=\"stylesheet\" type=\"text/css\" href=\"codeblock.css\" />\n"
. "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />\n"
. "<title>" . $this->config->title() . "</title>\n"
. "</head>\n"
Expand All @@ -112,11 +112,13 @@ protected function buildEpub(
//$book->setLanguage("en");

$book->addCSSFile("style.css", "css1", $this->getStyle($this->config->workingPath, "style"));
//$cssData = file_get_contents("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.css");
$cssData = file_get_contents("https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/github-gist.min.css");
// https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/github-gist.min.css
$book->addCSSFile(
"codeblock.css",
"css2",
$this->getStyle($this->config->workingPath, "highlight.codeblock.min"),
);

$book->addCSSFile("github.css", "css2", $cssData);
//
$cover = $content_start . "<h1>" . $this->config->title() . "</h1>\n";
if ($this->config->author()) {
$cover .= "<h2>By: " . $this->config->author() . "</h2>\n";
Expand Down
1 change: 1 addition & 0 deletions src/Commands/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'theme-dark.html',
'theme-light.html',
'style.css',
'highlight.codeblock.min.css',
'theme-html.html',
'images/aside-examples.png',
'images/ibis-next-cover.png',
Expand Down
1 change: 1 addition & 0 deletions stubs/assets/highlight.codeblock.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 91c5fa9

Please sign in to comment.