Add magic dark theme and rename formatting config to style

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/7/head
trivernis 4 years ago
parent faa8e57ffa
commit d82c43e5a3
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -290,12 +290,12 @@ max_height = 500
# Visual adjustments # Visual adjustments
[formatting] [style]
# how bibliography references should be displayed # how bibliography references should be displayed
bib_ref_display = '{{number}}' bib_ref_display = '{{number}}'
# the chosen theme for the document # the chosen theme for the document
# one of: GithubLight, SolarizedLight, OceanLight, SolarizedDark, OceanDark # one of: GithubLight, SolarizedLight, OceanLight, SolarizedDark, OceanDark, MagicDark
theme = 'GithubLight' theme = 'GithubLight'
# custom metadata # custom metadata

@ -1,5 +1,5 @@
body { body {
background-color: $background-color-variant-2; background-color: $body-background;
overflow-x: hidden; overflow-x: hidden;
color: $primary-color; color: $primary-color;
word-break: break-word; word-break: break-word;
@ -50,7 +50,7 @@ code {
pre { pre {
font-family: "Fira Code", "Mono", monospace; font-family: "Fira Code", "Mono", monospace;
padding: 0.8em 0.2em; padding: 0.8em 0.2em;
background-color: $background-color-variant-1 !important; background-color: $code-background !important;
border-radius: 0.25em; border-radius: 0.25em;
overflow: auto; overflow: auto;
} }
@ -58,7 +58,7 @@ code {
&.inlineCode { &.inlineCode {
font-family: "Fira Code", monospace; font-family: "Fira Code", monospace;
border-radius: 0.1em; border-radius: 0.1em;
background-color: $background-color-variant-1; background-color: $code-background;
padding: 0 0.1em; padding: 0 0.1em;
} }
} }
@ -77,11 +77,11 @@ table {
tr { tr {
&:nth-child(odd) { &:nth-child(odd) {
background-color: $background-color-variant-2; background-color: $table-background-alt;
} }
&:nth-child(1) { &:nth-child(1) {
background-color: $background-color-variant-2; background-color: $table-background-alt;
font-weight: bold; font-weight: bold;
border-bottom: 1px solid invert($background-color) border-bottom: 1px solid invert($background-color)
} }
@ -107,11 +107,11 @@ a {
} }
.quote { .quote {
border-left: 0.3em solid $background-color-variant-3; border-left: 0.3em solid $quote-background-alt;
border-radius: 0.2em; border-radius: 0.2em;
padding-left: 1em; padding-left: 1em;
margin-left: 0; margin-left: 0;
background-color: $background-color-variant-1; background-color: $quote-background;
.metadata { .metadata {
font-style: italic; font-style: italic;

@ -0,0 +1,14 @@
$background-color: #1e1d2c;
$background-color-variant-1: lighten($background-color, 7%);
$background-color-variant-2: lighten($background-color, 14%);
$background-color-variant-3: lighten($background-color, 21%);
$primary-color: #EEE;
$primary-variant-1: darken($primary-color, 14%);
$secondary-color: #3aa7df;
$body-background: darken($background-color, 5%);
$code-background: lighten($background-color, 5%);
$table-background-alt: $background-color-variant-2;
$quote-background: lighten($background-color-variant-1, 3%);
$quote-background-alt: $background-color-variant-3;

@ -2,6 +2,13 @@ $background-color: darken(#2b303b, 8%);
$background-color-variant-1: lighten($background-color, 7%); $background-color-variant-1: lighten($background-color, 7%);
$background-color-variant-2: lighten($background-color, 14%); $background-color-variant-2: lighten($background-color, 14%);
$background-color-variant-3: lighten($background-color, 21%); $background-color-variant-3: lighten($background-color, 21%);
$primary-color: #EEE; $primary-color: #EEE;
$primary-variant-1: darken($primary-color, 14%); $primary-variant-1: darken($primary-color, 14%);
$secondary-color: #3aa7df; $secondary-color: #3aa7df;
$body-background: darken($background-color, 5%);
$code-background: $background-color-variant-1;
$table-background-alt: $background-color-variant-2;
$quote-background: lighten($background-color-variant-1, 3%);
$quote-background-alt: $background-color-variant-3;

@ -5,3 +5,9 @@ $background-color-variant-3: lighten($background-color, 21%);
$primary-color: #EEE; $primary-color: #EEE;
$primary-variant-1: darken($primary-color, 14%); $primary-variant-1: darken($primary-color, 14%);
$secondary-color: #0096c9; $secondary-color: #0096c9;
$body-background: darken($background-color, 3%);
$code-background: $background-color-variant-1;
$table-background-alt: lighten($background-color, 10%);
$quote-background: lighten($background-color-variant-1, 3%);
$quote-background-alt: $background-color-variant-3;

@ -5,3 +5,9 @@ $background-color-variant-3: darken($background-color, 21%);
$primary-color: #000; $primary-color: #000;
$primary-variant-1: lighten($primary-color, 14%); $primary-variant-1: lighten($primary-color, 14%);
$secondary-color: #00286a; $secondary-color: #00286a;
$body-background: $background-color-variant-1;
$code-background: $background-color-variant-1;
$table-background-alt: $background-color-variant-2;
$quote-background: $background-color-variant-2;
$quote-background-alt: $background-color-variant-3;

@ -5,3 +5,9 @@ $background-color-variant-3: darken($background-color, 21%);
$primary-color: #112; $primary-color: #112;
$primary-variant-1: lighten($primary-color, 14%); $primary-variant-1: lighten($primary-color, 14%);
$secondary-color: #00348e; $secondary-color: #00348e;
$body-background: $background-color-variant-1;
$code-background: $background-color-variant-1;
$table-background-alt: $background-color-variant-2;
$quote-background: $background-color-variant-2;
$quote-background-alt: $background-color-variant-3;

@ -5,3 +5,9 @@ $background-color-variant-3: darken($background-color, 12%);
$primary-color: #112; $primary-color: #112;
$primary-variant-1: lighten($primary-color, 14%); $primary-variant-1: lighten($primary-color, 14%);
$secondary-color: #2b61be; $secondary-color: #2b61be;
$body-background: $background-color-variant-1;
$code-background: $background-color-variant-1;
$table-background-alt: $background-color-variant-2;
$quote-background: $background-color-variant-2;
$quote-background-alt: $background-color-variant-3;

@ -1,4 +1,4 @@
use crate::settings::format_settings::Theme; use crate::settings::style_settings::Theme;
use std::io; use std::io;
use std::io::Write; use std::io::Write;

@ -1,4 +1,4 @@
use crate::settings::format_settings::Theme; use crate::settings::style_settings::Theme;
use std::time::Instant; use std::time::Instant;
use syntect::highlighting::ThemeSet; use syntect::highlighting::ThemeSet;
use syntect::parsing::SyntaxSet; use syntect::parsing::SyntaxSet;
@ -12,6 +12,7 @@ pub fn get_css_for_theme(theme: Theme) -> String {
Theme::SolarizedLight => include_str!("assets/light-solarized.scss"), Theme::SolarizedLight => include_str!("assets/light-solarized.scss"),
Theme::OceanDark => include_str!("assets/dark-ocean.scss"), Theme::OceanDark => include_str!("assets/dark-ocean.scss"),
Theme::OceanLight => include_str!("assets/light-ocean.scss"), Theme::OceanLight => include_str!("assets/light-ocean.scss"),
Theme::MagicDark => include_str!("assets/dark-magic.scss"),
}; };
let style = format!("{}\n{}", vars, include_str!("assets/base.scss")); let style = format!("{}\n{}", vars, include_str!("assets/base.scss"));
@ -33,6 +34,7 @@ pub fn get_code_theme_for_theme(theme: Theme) -> (syntect::highlighting::Theme,
Theme::SolarizedLight => "Solarized (light)", Theme::SolarizedLight => "Solarized (light)",
Theme::OceanDark => "base16-ocean.dark", Theme::OceanDark => "base16-ocean.dark",
Theme::OceanLight => "base16-ocean.light", Theme::OceanLight => "base16-ocean.light",
Theme::MagicDark => "base16-ocean.dark",
}; };
return (TS.themes[theme].clone(), PS.clone()); return (TS.themes[theme].clone(), PS.clone());

@ -207,10 +207,7 @@ fn render_format(opt: &RenderOptions, document: Document, writer: BufWriter<File
} }
fn render_html(document: Document, writer: BufWriter<File>) { fn render_html(document: Document, writer: BufWriter<File>) {
let mut writer = HTMLWriter::new( let mut writer = HTMLWriter::new(Box::new(writer), document.config.lock().style.theme.clone());
Box::new(writer),
document.config.lock().formatting.theme.clone(),
);
document.to_html(&mut writer).unwrap(); document.to_html(&mut writer).unwrap();
writer.flush().unwrap(); writer.flush().unwrap();
} }

@ -373,7 +373,7 @@ impl ParseInline for Parser {
.document .document
.config .config
.lock() .lock()
.formatting .style
.bib_ref_display .bib_ref_display
.clone(), .clone(),
), ),

@ -1,10 +1,10 @@
use crate::elements::{Metadata, MetadataValue}; use crate::elements::{Metadata, MetadataValue};
use crate::settings::feature_settings::FeatureSettings; use crate::settings::feature_settings::FeatureSettings;
use crate::settings::format_settings::FormatSettings;
use crate::settings::image_settings::ImageSettings; use crate::settings::image_settings::ImageSettings;
use crate::settings::import_settings::ImportSettings; use crate::settings::import_settings::ImportSettings;
use crate::settings::metadata_settings::MetadataSettings; use crate::settings::metadata_settings::MetadataSettings;
use crate::settings::pdf_settings::PDFSettings; use crate::settings::pdf_settings::PDFSettings;
use crate::settings::style_settings::StyleSettings;
use config::{ConfigError, Source}; use config::{ConfigError, Source};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashMap; use std::collections::HashMap;
@ -15,11 +15,11 @@ use std::mem;
use std::path::PathBuf; use std::path::PathBuf;
pub mod feature_settings; pub mod feature_settings;
pub mod format_settings;
pub mod image_settings; pub mod image_settings;
pub mod import_settings; pub mod import_settings;
pub mod metadata_settings; pub mod metadata_settings;
pub mod pdf_settings; pub mod pdf_settings;
pub mod style_settings;
pub type SettingsResult<T> = Result<T, SettingsError>; pub type SettingsResult<T> = Result<T, SettingsError>;
@ -67,7 +67,7 @@ pub struct Settings {
pub imports: ImportSettings, pub imports: ImportSettings,
pub pdf: PDFSettings, pub pdf: PDFSettings,
pub images: ImageSettings, pub images: ImageSettings,
pub formatting: FormatSettings, pub style: StyleSettings,
pub custom_attributes: HashMap<String, String>, pub custom_attributes: HashMap<String, String>,
} }

@ -1,12 +1,12 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug)] #[derive(Serialize, Deserialize, Clone, Debug)]
pub struct FormatSettings { pub struct StyleSettings {
pub bib_ref_display: String, pub bib_ref_display: String,
pub theme: Theme, pub theme: Theme,
} }
impl Default for FormatSettings { impl Default for StyleSettings {
fn default() -> Self { fn default() -> Self {
Self { Self {
bib_ref_display: "{{number}}".to_string(), bib_ref_display: "{{number}}".to_string(),
@ -22,4 +22,5 @@ pub enum Theme {
SolarizedLight, SolarizedLight,
OceanDark, OceanDark,
OceanLight, OceanLight,
MagicDark,
} }
Loading…
Cancel
Save