-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added helper binary to regenerate READMEs
- Loading branch information
Showing
4 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "readme-render" | ||
version = "0.1.0" | ||
edition = "2018" | ||
authors = ["Nicolas Polomack <[email protected]>"] | ||
description = "A simple helper to generate syntect's binary dumps for Alexandrie" | ||
repository = "https://github.com/Hirevo/alexandrie" | ||
documentation = "https://crates.polomack.eu/docs/alexandrie" | ||
license = "MIT OR Apache-2.0" | ||
publish = false | ||
|
||
[dependencies] | ||
alexandrie-rendering = { path = "../../crates/alexandrie-rendering", version = "0.1.0" } | ||
serde = { version = "1.0.124", features = ["derive"] } | ||
toml = "0.5.8" | ||
|
||
[features] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use std::fs; | ||
use std::env; | ||
|
||
use alexandrie_rendering::config::{SyntectConfig, SyntectState}; | ||
|
||
use serde::{Serialize, Deserialize}; | ||
|
||
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] | ||
pub struct Config { | ||
/// The syntax-highlighting configuration. | ||
pub syntect: SyntectConfig, | ||
} | ||
|
||
fn main() { | ||
let readme_path = env::args().skip(1).next().expect("could not find a command-line argument"); | ||
|
||
let contents = fs::read("alexandrie.toml").expect("could not open configuration file `alexandrie.toml`"); | ||
let config: Config = toml::from_slice(contents.as_slice()).expect("could not parse configuration file"); | ||
|
||
let state = SyntectState::from(config.syntect); | ||
|
||
let contents = fs::read_to_string(readme_path).expect("could not open README file"); | ||
let rendered = alexandrie_rendering::render_readme(&state, &contents); | ||
|
||
fs::write("output.html", &rendered).expect("could not write rendered HTML output"); | ||
} |