Merge pull request #15 from Trivernis/develop

Fixes to monospace and block elements
pull/17/head v0.32.2
Trivernis 4 years ago committed by GitHub
commit 673a7527d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

6
Cargo.lock generated

@ -235,9 +235,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "charred"
version = "0.3.3"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e01302bf6a3d92a90baa965f84a735938520ab9fd896f0694a71e8dec5405ce"
checksum = "ed9759715d56a062d5636cd0cbc71f2aa8a978afe08c572a69e65e8cf53418f5"
[[package]]
name = "chrono"
@ -2315,7 +2315,7 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "snekdown"
version = "0.32.1"
version = "0.32.2"
dependencies = [
"asciimath-rs",
"base64 0.12.3",

@ -1,6 +1,6 @@
[package]
name = "snekdown"
version = "0.32.1"
version = "0.32.2"
authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018"
license-file = "LICENSE"
@ -21,7 +21,7 @@ path = "src/main.rs"
pdf = ["headless_chrome", "failure"]
[dependencies]
charred = "0.3.3"
charred = "0.3.5"
asciimath-rs = "0.5.7"
bibliographix = "0.6.0"
crossbeam-utils = "0.7.2"

@ -135,8 +135,9 @@ impl ParseBlock for Parser {
let language = self.ctm.get_string_until_any(&[LB], &[])?;
self.ctm.seek_one()?;
let text = self.ctm.get_string_until_sequence(&[&SQ_CODE_BLOCK], &[])?;
for _ in 0..2 {
self.ctm.seek_one()?;
self.ctm.try_seek();
}
Ok(CodeBlock {
@ -153,7 +154,7 @@ impl ParseBlock for Parser {
self.ctm.seek_one()?;
let text = self.ctm.get_string_until_sequence(&[SQ_MATH], &[])?;
for _ in 0..1 {
self.ctm.seek_one()?;
self.ctm.try_seek();
}
Ok(MathBlock {
expression: asciimath_rs::parse(text),
@ -231,6 +232,7 @@ impl ParseBlock for Parser {
let ordered = self.ctm.get_current().is_numeric();
list.ordered = ordered;
let mut list_hierarchy: Vec<ListItem> = Vec::new();
while let Ok(mut item) = self.parse_list_item() {
while let Some(parent_item) = list_hierarchy.pop() {
if parent_item.level < item.level {
@ -289,6 +291,7 @@ impl ParseBlock for Parser {
}
let seek_index = self.ctm.get_index();
let mut table = Table::new(header);
while let Ok(_) = self.ctm.seek_one() {
self.ctm.seek_any(&INLINE_WHITESPACE)?;
if !self.ctm.check_any(&[MINUS, PIPE]) || self.ctm.check_char(&LB) {

@ -6,6 +6,7 @@ use crate::parser::block::ParseBlock;
use crate::references::glossary::GlossaryDisplay;
use crate::references::glossary::GlossaryReference;
use crate::references::templates::{GetTemplateVariables, Template, TemplateVariable};
use crate::utils::parsing::remove_single_backlslash;
use crate::Parser;
use bibliographix::references::bib_reference::BibRef;
use parking_lot::Mutex;
@ -295,9 +296,10 @@ impl ParseInline for Parser {
let start_index = self.ctm.get_index();
self.ctm.assert_char(&BACKTICK, Some(start_index))?;
self.ctm.seek_one()?;
let content = self
.ctm
.get_string_until_any_or_rewind(&[BACKTICK, LB], &[], start_index)?;
let mut content =
self.ctm
.get_string_until_any_or_rewind(&[BACKTICK, LB], &[], start_index)?;
content = remove_single_backlslash(content);
self.ctm.assert_char(&BACKTICK, Some(start_index))?;
self.ctm.seek_one()?;

@ -60,7 +60,7 @@ impl ImageConverter {
}
pb.lock().tick();
});
pb.lock().finish();
pb.lock().finish_and_clear();
}
}

@ -1,6 +1,15 @@
use regex::Regex;
#[macro_export]
macro_rules! parse {
($str:expr) => {
Parser::new($str.to_string(), None).parse()
};
}
/// Removes a single backslash from the given content
pub(crate) fn remove_single_backlslash<S: ToString>(content: S) -> String {
let content = content.to_string();
lazy_static::lazy_static! {static ref R: Regex = Regex::new(r"\\(?P<c>[^\\])").unwrap();}
R.replace_all(&*content, "$c").to_string()
}

Loading…
Cancel
Save