Update style

This commit is contained in:
ef3d0c3e 2024-07-31 11:56:48 +02:00
parent 131d3b30ee
commit 12e15321a4
2 changed files with 67 additions and 21 deletions

View file

@ -76,6 +76,32 @@ mod default_layouts {
} }
} }
} }
#[derive(Debug)]
pub struct Split;
impl LayoutType for Split {
fn name(&self) -> &'static str { "Split" }
fn expects(&self) -> Range<usize> { 2..usize::MAX }
fn compile(
&self,
token: LayoutToken,
_id: usize,
compiler: &Compiler,
_document: &dyn Document,
) -> Result<String, String> {
match compiler.target() {
Target::HTML => match token {
LayoutToken::BEGIN => Ok(r#"<div class="split-container"><div class="split">"#.to_string()),
LayoutToken::NEXT => Ok(r#"</div><div class="split">"#.to_string()),
LayoutToken::END => Ok(r#"</div></div>"#.to_string()),
},
_ => todo!(""),
}
}
}
} }
#[derive(Debug)] #[derive(Debug)]
@ -158,6 +184,8 @@ impl LayoutRule {
let mut layouts: HashMap<String, Rc<dyn LayoutType>> = HashMap::new(); let mut layouts: HashMap<String, Rc<dyn LayoutType>> = HashMap::new();
let layout_centered = default_layouts::Centered {}; let layout_centered = default_layouts::Centered {};
layouts.insert(layout_centered.name().to_string(), Rc::new(layout_centered)); layouts.insert(layout_centered.name().to_string(), Rc::new(layout_centered));
let layout_split = default_layouts::Split {};
layouts.insert(layout_split.name().to_string(), Rc::new(layout_split));
Self { Self {
re: [ re: [
@ -328,7 +356,7 @@ impl RegexRule for LayoutRule {
Some(last) => last, Some(last) => last,
}; };
if layout_type.expects().end >= tokens.len() if layout_type.expects().end < tokens.len()
// Too many blocks // Too many blocks
{ {
reports.push( reports.push(
@ -372,7 +400,7 @@ impl RegexRule for LayoutRule {
Some(last) => last, Some(last) => last,
}; };
if layout_type.expects().start < tokens.len() if layout_type.expects().start > tokens.len()
// Not enough blocks // Not enough blocks
{ {
reports.push( reports.push(

View file

@ -17,6 +17,24 @@ body {
width: 100%; width: 100%;
} }
/* Layouts */
div.centered {
text-align: center;
}
div.split-container {
display: flex;
width: 100%;
}
div.split-container > div.split {
flex: 1;
flex-shrink: 0;
overflow-x: auto;
margin: 0.5em;
}
/* Styles */ /* Styles */
em { em {
padding-left: .1em; padding-left: .1em;
@ -126,11 +144,10 @@ div.code-block-title {
} }
div.code-block-content { div.code-block-content {
max-height: 20em; max-height: 38em;
margin-bottom: 0.2em; margin-bottom: 0.2em;
width: auto;
overflow: auto; overflow: scroll;
background-color: #0f141a; background-color: #0f141a;
} }
@ -143,6 +160,7 @@ div.code-block-content td {
div.code-block-content pre { div.code-block-content pre {
border: 0; border: 0;
margin: 0; margin: 0;
tab-size: 4;
} }
div.code-block-content .code-block-gutter { div.code-block-content .code-block-gutter {