Remove url short syntax and update Readme

pull/1/head
trivernis 4 years ago
parent 8896ea27b3
commit 7b901ee984

52
Cargo.lock generated

@ -1,58 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "aho-corasick"
version = "0.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "markdown-rs"
version = "0.1.0"
dependencies = [
"regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "memchr"
version = "2.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "regex"
version = "1.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex-syntax"
version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "thread_local"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[metadata]
"checksum aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada"
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
"checksum regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
"checksum regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)" = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
"checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"

@ -6,5 +6,4 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
regex = "1.3.9"
[dependencies]

@ -5,30 +5,20 @@ for my needs.
## Syntax
### URLs
```
The simplest way to insert an url is
(valid url)
The default syntax can also be used
[text](valid url)
```
### Images
```
Simple Syntax
!(valid url)
!(url)
Extended syntax with a description
![description](valid url)
![description](url)
Extended syntax with metadata to specify the size
![description](valid url)[metadata]
![description](url)[metadata]
Extended syntax with metadata and no description
!(valid url)[metadata]
!(url)[metadata]
```
### Quotes

@ -1,6 +1,5 @@
use crate::elements::*;
use crate::tokens::*;
use regex::Regex;
use std::error::Error;
use std::fmt;
use std::fmt::{Display, Formatter};
@ -534,7 +533,7 @@ impl Parser {
if let Ok(image) = self.parse_image() {
return Ok(SubText::Image(image));
}
if let Ok(url) = self.parse_url() {
if let Ok(url) = self.parse_url(false) {
return Ok(SubText::Url(url));
}
match self.current_char {
@ -600,7 +599,7 @@ impl Parser {
if !self.check_special(&IMG_START) || self.next_char() == None {
return Err(self.revert_with_error(start_index));
}
if let Ok(url) = self.parse_url() {
if let Ok(url) = self.parse_url(true) {
let metadata = if let Ok(meta) = self.parse_inline_metadata() {
if self.check_special(&META_CLOSE) && self.next_char() == None {
return Err(self.revert_with_error(start_index));
@ -616,7 +615,7 @@ impl Parser {
}
// parses an url
fn parse_url(&mut self) -> Result<Url, ParseError> {
fn parse_url(&mut self, short_syntax: bool) -> Result<Url, ParseError> {
let start_index = self.index;
self.seek_inline_whitespace();
@ -632,6 +631,8 @@ impl Parser {
// it stopped at a linebreak or EOF
return Err(self.revert_with_error(start_index));
}
} else if !short_syntax {
return Err(self.revert_with_error(start_index));
}
if !self.check_special(&URL_OPEN) {
@ -650,10 +651,6 @@ impl Parser {
return Err(self.revert_with_error(start_index));
}
parse_option!(self.next_char(), self.index);
let matcher = Regex::new(EXPR_URI).unwrap();
if !matcher.is_match(&url) {
return Err(self.revert_with_error(start_index));
}
if description.is_empty() {
Ok(Url::new(None, url))

Loading…
Cancel
Save