Skip to content

Commit

Permalink
Add fetch feature to headless_chromium dep
Browse files Browse the repository at this point in the history
Signed-off-by: trivernis <trivernis@protonmail.com>
  • Loading branch information
Trivernis committed Apr 13, 2021
1 parent 8181119 commit 0e608e2
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 4 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,13 @@ jobs:
run: cargo build --verbose --all-features

- name: Run tests
run: cargo test --verbose --all-features
run: cargo test --verbose --all-features

- name: Test init
run: cargo run -- init

- name: Test HTML
run: cargo run -- render README.md README.html --format html

- name: Test PDF
run: cargo run --all-features -- render README.md README.pdf --format pdf
172 changes: 172 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ sha2 = "0.9.2"
config = "0.10.1"
rsass = "0.16.0"

headless_chrome = { version = "0.9.0", optional = true }
headless_chrome = { version = "0.9.0", optional = true, features = ["fetch"] }
failure = { version = "0.1.8", optional = true }
4 changes: 2 additions & 2 deletions src/format/chromium_pdf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::settings::Settings;
use crate::utils::caching::CacheStorage;
use bibliographix::Mutex;
use headless_chrome::protocol::page::PrintToPdfOptions;
use headless_chrome::{Browser, LaunchOptionsBuilder, Tab};
use headless_chrome::{Browser, Tab};
use std::fs;
use std::fs::OpenOptions;
use std::io::BufWriter;
Expand Down Expand Up @@ -50,7 +50,7 @@ pub fn render_to_pdf(document: Document) -> PdfRenderingResult<Vec<u8>> {
}
});

let browser = Browser::new(LaunchOptionsBuilder::default().build().unwrap())?;
let browser = Browser::default()?;
let tab = browser.wait_for_initial_tab()?;
handle.join().unwrap()?;
tab.navigate_to(format!("file:///{}", file_path.to_string_lossy()).as_str())?;
Expand Down

0 comments on commit 0e608e2

Please sign in to comment.