summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Reeder <vpzomtrrfrt@gmail.com>2020-12-13 12:32:21 -0700
committerColin Reeder <vpzomtrrfrt@gmail.com>2020-12-13 12:32:21 -0700
commita07ab6ad7258d12ee1586ab51cdd159982278f95 (patch)
tree69b330c6c65a7982c44d3a57ceb4c5f04e9995f0
parent8265980733eff941be5399f9211a1919973467aa (diff)
Add extended autolinks (#105)
-rw-r--r--Cargo.lock22
-rw-r--r--Cargo.toml3
-rw-r--r--src/main.rs5
3 files changed, 22 insertions, 8 deletions
diff --git a/Cargo.lock b/Cargo.lock
index a2cf00c..9b32e2c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1073,6 +1073,7 @@ dependencies = [
"lettre",
"mime",
"openssl",
+ "pdcm-linkify",
"percent-encoding",
"postgres-types",
"pulldown-cmark",
@@ -1397,6 +1398,15 @@ dependencies = [
]
[[package]]
+name = "pdcm-linkify"
+version = "0.1.0"
+source = "git+https://git.sr.ht/~vpzom/pdcm-linkify?rev=18c43df5#18c43df5fc1f75341a883f46c07e0b73d3068572"
+dependencies = [
+ "pulldown-cmark",
+ "regex",
+]
+
+[[package]]
name = "percent-encoding"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1546,9 +1556,9 @@ dependencies = [
[[package]]
name = "pulldown-cmark"
-version = "0.7.2"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ca36dea94d187597e104a5c8e4b07576a8a45aa5db48a65e12940d3eb7461f55"
+checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8"
dependencies = [
"bitflags",
"getopts",
@@ -1641,9 +1651,9 @@ checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
[[package]]
name = "regex"
-version = "1.3.9"
+version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
+checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c"
dependencies = [
"aho-corasick",
"memchr",
@@ -1653,9 +1663,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
-version = "0.6.18"
+version = "0.6.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
+checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189"
[[package]]
name = "remove_dir_all"
diff --git a/Cargo.toml b/Cargo.toml
index b9e5b38..74536d4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -35,7 +35,6 @@ postgres-types = "0.1.2"
lazy_static = "1.4.0"
unic-char-range = "0.9.0"
http = "0.2.1"
-pulldown-cmark = "0.7.2"
fluent = "0.12.0"
fluent-langneg = "0.13.0"
unic-langid = { version = "0.9.0", features = ["macros"] }
@@ -50,6 +49,8 @@ tokio-util = "0.3.1"
henry = "0.1.0"
ammonia = "3.1.0"
base64 = "0.13.0"
+pdcm-linkify = { git = "https://git.sr.ht/~vpzom/pdcm-linkify", rev = "18c43df5" }
+pulldown-cmark = "0.8.0"
[dev-dependencies]
rand = "0.7.3"
diff --git a/src/main.rs b/src/main.rs
index ad097b7..c0dff37 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -664,8 +664,11 @@ pub fn spawn_task<F: std::future::Future<Output = Result<(), Error>> + Send + 's
pub fn render_markdown(src: &str) -> String {
let parser = pulldown_cmark::Parser::new(src);
+
+ let stream = pdcm_linkify::AutoLinker::new(parser);
+
let mut output = String::new();
- pulldown_cmark::html::push_html(&mut output, parser);
+ pulldown_cmark::html::push_html(&mut output, stream);
output
}