From cab0fb1b18fb15d3d70a705d478624c0013f52cc Mon Sep 17 00:00:00 2001 From: Luna D Date: Sun, 12 Sep 2021 17:53:31 +0200 Subject: [PATCH] underline + escaping md --- lib/philomena/markdown.ex | 6 ++++-- native/furbooru_markdown/Cargo.lock | 4 ++-- native/furbooru_markdown/Cargo.toml | 10 +++++----- native/furbooru_markdown/src/lib.rs | 2 ++ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/philomena/markdown.ex b/lib/philomena/markdown.ex index fd8f8563..d25cac8d 100644 --- a/lib/philomena/markdown.ex +++ b/lib/philomena/markdown.ex @@ -1,7 +1,7 @@ defmodule Philomena.Markdown do use Rustler, otp_app: :philomena - @markdown_chars = ~r/[\*_\[\]\(\)\^`\%\\~<>#\|]/ + @markdown_chars ~r/[\*_\[\]\(\)\^`\%\\~<>#\|]/ # When your NIF is loaded, it will override this function. def to_html(_text), do: :erlang.nif_error(:nif_not_loaded) @@ -9,6 +9,8 @@ defmodule Philomena.Markdown do def escape_markdown(text) do @markdown_chars - |> Regex.replace(text, "\\\\0") + |> Regex.replace(text, fn m -> + "\\#{m}" + end) end end diff --git a/native/furbooru_markdown/Cargo.lock b/native/furbooru_markdown/Cargo.lock index bf632bd9..10243927 100644 --- a/native/furbooru_markdown/Cargo.lock +++ b/native/furbooru_markdown/Cargo.lock @@ -137,7 +137,7 @@ dependencies = [ [[package]] name = "comrak" version = "0.12.1" -source = "git+https://github.com/furbooru/comrak#4adb01d736b03a25c81451d62148da37256e99c7" +source = "git+https://github.com/furbooru/comrak#b69625ef55b855675d9597c9dd5fe2dda50cc0c6" dependencies = [ "clap", "entities", @@ -223,7 +223,7 @@ checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" [[package]] name = "furbooru_markdown" -version = "0.1.1" +version = "0.2.0" dependencies = [ "comrak", "jemallocator", diff --git a/native/furbooru_markdown/Cargo.toml b/native/furbooru_markdown/Cargo.toml index 7c21e352..66ba6392 100644 --- a/native/furbooru_markdown/Cargo.toml +++ b/native/furbooru_markdown/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "furbooru_markdown" -version = "0.1.1" -authors = [] +version = "0.2.0" +authors = ["Xe ", "Luna ", "Liam White "] edition = "2018" [lib] @@ -11,11 +11,11 @@ crate-type = ["dylib"] [dependencies] comrak = { git = "https://github.com/furbooru/comrak" } -lazy_static = "1.0" -regex = "1" +lazy_static = "1.4" +regex = "1.5" log = "0" pretty_env_logger = "0" -rustler = "0.22.0" +rustler = "0.22" jemallocator = "0.3.2" [profile.release] diff --git a/native/furbooru_markdown/src/lib.rs b/native/furbooru_markdown/src/lib.rs index 16587cba..466439af 100644 --- a/native/furbooru_markdown/src/lib.rs +++ b/native/furbooru_markdown/src/lib.rs @@ -41,6 +41,7 @@ fn to_html(input: String) -> String { options.extension.subscript = true; options.extension.spoiler = true; options.extension.strikethrough = true; + options.extension.underline = true; // options.extension.furbooru = true; options.parse.smart = true; options.render.hardbreaks = true; @@ -84,6 +85,7 @@ fn to_html_unsafe(input: String) -> String { options.extension.subscript = true; options.extension.spoiler = true; options.extension.strikethrough = true; + options.extension.underline = true; // options.extension.furbooru = true; options.parse.smart = true; options.render.hardbreaks = true;