Skip to content

Commit

Permalink
chore: squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 689dcb7
Author: Nadir Fejzic <nadirfejzo@gmail.com>
Date:   Thu Jun 30 14:13:36 2022 +0200

    chore: revert "chore: update release-please"

    This reverts commit 25c1b34.

commit 25c1b34
Author: Nadir Fejzić <nadirfejzo@gmail.com>
Date:   Thu Jun 30 14:09:38 2022 +0200

    chore: update release-please

commit 6fca1ea
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Thu Apr 28 03:33:06 2022 +0200

    refactor: simplify verbatim test

commit 1f2e748
Merge: 3b2a5f6 6d026cd
Author: Manuel Hatzl <49341624+mhatzl@users.noreply.github.com>
Date:   Thu Apr 28 03:30:35 2022 +0200

    chore: merge pull request #70 from Unimarkup/syntax-highlight

    feat: add syntax highlighting for verbatim blocks

    Uses the syntect crate to highlight content in HTML. The crate also allows to create custom output formats.
    In the future, the content could be highlighted using Unimarkup elements instead.
    For this, text groups with attributes must be implemented first.

commit 6d026cd
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Thu Apr 28 03:18:48 2022 +0200

    style: format code according to styleguide

commit 2102a44
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Thu Apr 28 03:17:16 2022 +0200

    feat: add syntax highlighting for verbatim blocks

commit 3b2a5f6
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Thu Apr 28 01:11:59 2022 +0200

    fix: remove file dependency from metadata

    The file must not exist on the plarform in order to create a metadata.
    This allows to use the core crate purely in memory.

commit e92e9be
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Thu Apr 28 00:16:22 2022 +0200

    fix: handle empty content

commit 921ad24
Merge: 1b90863 27aaae0
Author: Manuel Hatzl <49341624+mhatzl@users.noreply.github.com>
Date:   Thu Apr 28 00:00:15 2022 +0200

    chore: merge pull request #67 from Unimarkup/inline

    Introduce inline functionality

commit 27aaae0
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Wed Apr 27 23:57:38 2022 +0200

    test: adapt file path of log test for actions

commit b7b3db3
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Wed Apr 27 23:46:14 2022 +0200

    style: format code according to styleguide

commit 8272903
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Wed Apr 27 23:40:19 2022 +0200

    test: set paths in log test to work in run and dbg

commit ff93085
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Wed Apr 27 16:51:26 2022 +0200

    fix(inline): correct open token cleanup

commit 1e913c9
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Wed Apr 27 16:38:19 2022 +0200

    fix(inline): correct verbatimOpen str representation

commit 82b4fda
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Tue Apr 26 02:21:24 2022 +0200

    feat(inline): add inline token identifiers

    fix: change heading_level to u8 for easier conversions

commit 20d9765
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Apr 25 16:02:20 2022 +0200

    fix: correct heading id generation of empty content

commit 520f2bb
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Sun Apr 24 17:31:32 2022 +0200

    fix(inline): add validation against timing issues

    Fast lsp changes create timing issues, circumventing some grammar restrictions.

commit af71710
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Sun Apr 24 15:56:09 2022 +0200

    fix: change to `code` tag for inline verbatim

commit e4e9104
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Sun Apr 24 15:28:05 2022 +0200

    fix: update rendering of verbatim and text group

commit 8761263
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Sun Apr 24 15:19:46 2022 +0200

    feat(inline): add TextGroup element to ast

commit 214dd5d
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Sun Apr 24 14:36:58 2022 +0200

    fix(inline): convert verbatim to nested inline

    Needed for correct tokenization using LSP.

commit e8041dd
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Sat Apr 23 22:10:43 2022 +0200

    fix(inline): correct handling of invalid inner italic

commit 7869d10
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Sat Apr 23 13:41:03 2022 +0200

    fix(inline): correct nested italic before word

commit 3d3566a
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Wed Apr 20 16:22:55 2022 +0200

    feat(inline): introduce plain newline token

    This helps to recreate the original Unimarkup file.

    Needed for LSP semantic highlighting.

commit 138765c
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Wed Apr 20 16:09:56 2022 +0200

    feat: make um elements public

    Elements of a unimarkup document may now be accessed outside of the core crate.

commit d4d28c1
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Wed Mar 23 23:26:58 2022 +0100

    test(inline): add verbatim testcase for char escaping

commit 128129a
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Wed Mar 23 23:06:56 2022 +0100

    fix(inline): correct ItalicClose without ItalicOpen

commit 57fb41d
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Wed Mar 23 12:46:00 2022 +0100

    doc(inline): add documentation for the inline crate

commit ba88b48
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Wed Mar 23 00:10:06 2022 +0100

    feat: move to inline crate for inline formatting

commit 0d538cd
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Tue Mar 22 21:27:12 2022 +0100

    feat(inline): add offset possibility for parsing

    This allows to set an offset for the start position of the first token.

commit d894001
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Tue Mar 22 17:49:25 2022 +0100

    refactor(inline): remove and restructure code

    Tests are moved out of source, since they got too long, bloating src files.

commit 99231e7
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Mar 21 14:07:05 2022 +0100

    feat(inline): add arow and emoji substitution

commit 665b330
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Mar 21 13:09:27 2022 +0100

    feat(inline): add newline handling

commit 89b4fb1
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Mar 21 12:51:45 2022 +0100

    feat(inline): add escape handling to collect()

commit 571aea4
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Mar 21 12:07:48 2022 +0100

    feat(inline): add basic collect() functionality

    collect() creates an AST out of the returned token list from tokenize().

commit a63d743
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Fri Mar 18 20:28:49 2022 +0100

    feat(inline): add basic support for text groups

commit d6ed958
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Tue Mar 15 00:22:32 2022 +0100

    fix(inline): correct splitting of four asterisks

commit 031dde8
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Mar 14 18:04:16 2022 +0100

    feat(inline): add verbatim formatting

commit 8f9c123
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Mar 14 17:22:27 2022 +0100

    refactor(inline): split tokenize for nested tokenization

commit 16eed17
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Mar 14 15:08:01 2022 +0100

    feat(inline): switch to grapheme iterator

commit 0ccdff1
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Mar 14 14:19:04 2022 +0100

    test(inline): add open constraint test

commit c2feda1
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Mar 14 14:10:15 2022 +0100

    fix(inline): enforce open constraint

commit dc34282
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Mar 14 13:42:26 2022 +0100

    fix(inline): change 4 open asterisks to plain

    Instead of empty bold.

commit 5dfe0fc
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Mar 14 12:12:43 2022 +0100

    fix(inline): correct bold-italic edge cases

    Fixes combined bold-italic and empty bold cases.

commit f675e97
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Mar 14 02:09:37 2022 +0100

    feat(inline): add escape functionality

commit 6612553
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Mar 14 01:32:18 2022 +0100

    fix(inline): correct rightside combined bold-italic

commit 1b3af04
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Mar 14 01:14:00 2022 +0100

    fix(inline): correct bold-italic ombined opening

commit 8a17ff1
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Mar 14 00:17:08 2022 +0100

    fix(inline): correct bold closing

commit 9d5edc8
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Mon Mar 14 00:04:13 2022 +0100

    chore(inline): pass first formatting test

commit 3999368
Author: Manuel Hatzl <hatzlmanuel@outlook.com>
Date:   Sat Mar 12 14:20:21 2022 +0100

    chore: introduce base structure for inline handling

commit 2a3b677
Author: Nadir Fejzic <nadirfejzo@gmail.com>
Date:   Thu Mar 10 02:29:51 2022 +0100

    test: add basic tests for inline lexer

commit 0c006ad
Author: Nadir Fejzic <nadirfejzo@gmail.com>
Date:   Thu Mar 10 02:29:35 2022 +0100

    feat: implement basic inline lexer

commit 45a71cd
Author: Nadir Fejzic <nadirfejzo@gmail.com>
Date:   Thu Mar 10 02:29:20 2022 +0100

    feat: implement basic inline tokens

commit 7f42ab0
Author: Nadir Fejzic <nadirfejzo@gmail.com>
Date:   Thu Mar 10 02:24:54 2022 +0100

    chore: remove unused deps. from inline crate

commit 54a8ef7
Author: Nadir Fejzic <nadirfejzo@gmail.com>
Date:   Sat Feb 26 23:26:36 2022 +0100

    feat: implement basic lexer for plain, bold tokens
  • Loading branch information
nfejzic committed Jul 31, 2022
1 parent 53f5ca4 commit f380906
Show file tree
Hide file tree
Showing 28 changed files with 391 additions and 346 deletions.
1 change: 1 addition & 0 deletions cli/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ impl From<CoreError> for CliError {
CoreError::Backend(log_id) => CliError::Core(log_id),
CoreError::Element(log_id) => CliError::Core(log_id),
CoreError::Config(log_id) => CliError::Core(log_id),
CoreError::Security(log_id) => CliError::Core(log_id),
}
}
}
2 changes: 2 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ clap = { version = "^3.1.0", features = ["derive", "cargo", "env"] }
sha3 = "0.10"
hex = "0.4"
unimarkup_inline = { path = "../inline/"}
syntect = "4.6"
lazy_static = "1.4.0"
234 changes: 0 additions & 234 deletions core/src/backend/inline_formatting.rs

This file was deleted.

23 changes: 14 additions & 9 deletions core/src/backend/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ use std::{collections::VecDeque, str::FromStr};
use rusqlite::Connection;

use crate::{
backend::{BackendError, Render},
backend::BackendError,
elements::{types, types::UnimarkupType, HeadingBlock, ParagraphBlock, VerbatimBlock},
log_id::{LogId, SetLog},
middleend::{self, ContentIrLine},
unimarkup_block::UnimarkupBlockKind,
};

use super::{log_id::LoaderErrLogId, RenderBlock};
use super::log_id::LoaderErrLogId;

/// Trait that must be implemented for a [`UnimarkupType`] to be stored in IR
pub trait ParseFromIr {
Expand All @@ -33,27 +34,31 @@ pub trait ParseFromIr {
/// # Arguments
///
/// * `connection` - [`rusqlite::Connection`] used for interaction with IR
pub fn get_blocks_from_ir(connection: &mut Connection) -> Result<Vec<RenderBlock>, BackendError> {
let mut blocks: Vec<Box<dyn Render>> = vec![];
pub fn get_blocks_from_ir(
connection: &mut Connection,
) -> Result<Vec<UnimarkupBlockKind>, BackendError> {
let mut blocks: Vec<UnimarkupBlockKind> = vec![];
let mut content_lines: VecDeque<ContentIrLine> =
middleend::get_content_lines(connection)?.into();

while let Some(line) = content_lines.get(0) {
let um_type = parse_um_type(&line.um_type)?;

let block: Box<dyn Render> = match um_type {
let block = match um_type {
// UnimarkupType::List => todo!(),
UnimarkupType::Heading => Box::new(HeadingBlock::parse_from_ir(&mut content_lines)?),
UnimarkupType::Heading => {
UnimarkupBlockKind::Heading(HeadingBlock::parse_from_ir(&mut content_lines)?)
}
UnimarkupType::Paragraph => {
Box::new(ParagraphBlock::parse_from_ir(&mut content_lines)?)
UnimarkupBlockKind::Paragraph(ParagraphBlock::parse_from_ir(&mut content_lines)?)
}
UnimarkupType::VerbatimBlock => {
Box::new(VerbatimBlock::parse_from_ir(&mut content_lines)?)
UnimarkupBlockKind::Verbatim(VerbatimBlock::parse_from_ir(&mut content_lines)?)
}
_ => {
let _ = content_lines.pop_front();

Box::new(HeadingBlock::default())
UnimarkupBlockKind::Paragraph(ParagraphBlock::default())
}
};

Expand Down
9 changes: 2 additions & 7 deletions core/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
//!
//! [`UnimarkupBlocks`]: crate::frontend::UnimarkupBlocks

use crate::{config::Config, unimarkup::UnimarkupDocument};
use crate::{config::Config, unimarkup::UnimarkupDocument, unimarkup_block::UnimarkupBlockKind};
use rusqlite::Connection;

mod inline_formatting;
mod loader;
mod renderer;

pub use inline_formatting::*;
pub use loader::ParseFromIr;
pub use renderer::*;

Expand All @@ -20,9 +18,6 @@ use self::error::BackendError;
pub mod error;
pub mod log_id;

/// Abstract type for elements that implement the [`Render`] trait
pub type RenderBlock = Box<dyn Render>;

/// This is the entry function for the [`backend`](crate::backend) module. It fetches
/// [`UnimarkupBlocks`] from IR, renders them to the wanted output format and writes the resulting output.
///
Expand All @@ -34,7 +29,7 @@ pub type RenderBlock = Box<dyn Render>;
///
/// [`UnimarkupBlocks`]: crate::frontend::UnimarkupBlocks
pub fn run(connection: &mut Connection, config: Config) -> Result<UnimarkupDocument, BackendError> {
let blocks: Vec<RenderBlock> = loader::get_blocks_from_ir(connection)?;
let blocks: Vec<UnimarkupBlockKind> = loader::get_blocks_from_ir(connection)?;

Ok(UnimarkupDocument {
elements: blocks,
Expand Down
3 changes: 2 additions & 1 deletion core/src/backend/renderer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::backend::error::BackendError;

use super::RenderBlock;
/// Abstract type for elements that implement the [`Render`] trait
pub type RenderBlock = Box<dyn Render>;

/// Used to provide render implementation for supported output formats
pub trait Render {
Expand Down
18 changes: 10 additions & 8 deletions core/src/elements/heading_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Default for HeadingLevel {
}
}

impl From<HeadingLevel> for usize {
impl From<HeadingLevel> for u8 {
fn from(level: HeadingLevel) -> Self {
match level {
HeadingLevel::Level1 => 1,
Expand Down Expand Up @@ -152,20 +152,22 @@ impl HeadingBlock {
None => None,
};

let level = heading_start.as_str().trim().into();
let level = heading_start.as_str().trim();
let (line_nr, _) = heading_start.as_span().start_pos().line_col();

// unwrap() is ok becuase heading grammar guarantees that heading has non-empty content
let generated_id = match parser::generate_id(heading_content.as_str()) {
Some(id) => id.to_lowercase(),
None => format!("heading-{}-line-{}", level, line_nr),
};

let id = match attributes {
Some(ref attrs) if attrs.get("id").is_some() => attrs.get("id").unwrap().to_string(),
_ => parser::generate_id(heading_content.as_str())
.unwrap()
.to_lowercase(),
_ => generated_id,
};

Ok(HeadingBlock {
id,
level,
level: level.into(),
content: heading_content.as_str().parse_unimarkup_inlines().collect(),
attributes: serde_json::to_string(&attributes.unwrap_or_default()).unwrap(),
line_nr,
Expand Down Expand Up @@ -302,7 +304,7 @@ impl Render for HeadingBlock {
fn render_html(&self) -> Result<String, BackendError> {
let mut html = String::default();

let tag_level = usize::from(self.level).to_string();
let tag_level = u8::from(self.level).to_string();

html.push_str("<h");
html.push_str(&tag_level);
Expand Down
Loading

0 comments on commit f380906

Please sign in to comment.