underline + escaping md

This commit is contained in:
Luna D 2021-09-12 17:53:31 +02:00
parent 4b46ca803f
commit cab0fb1b18
No known key found for this signature in database
GPG key ID: 81AF416F2CC36FC8
4 changed files with 13 additions and 9 deletions

View file

@ -1,7 +1,7 @@
defmodule Philomena.Markdown do defmodule Philomena.Markdown do
use Rustler, otp_app: :philomena use Rustler, otp_app: :philomena
@markdown_chars = ~r/[\*_\[\]\(\)\^`\%\\~<>#\|]/ @markdown_chars ~r/[\*_\[\]\(\)\^`\%\\~<>#\|]/
# When your NIF is loaded, it will override this function. # When your NIF is loaded, it will override this function.
def to_html(_text), do: :erlang.nif_error(:nif_not_loaded) def to_html(_text), do: :erlang.nif_error(:nif_not_loaded)
@ -9,6 +9,8 @@ defmodule Philomena.Markdown do
def escape_markdown(text) do def escape_markdown(text) do
@markdown_chars @markdown_chars
|> Regex.replace(text, "\\\\0") |> Regex.replace(text, fn m ->
"\\#{m}"
end)
end end
end end

View file

@ -137,7 +137,7 @@ dependencies = [
[[package]] [[package]]
name = "comrak" name = "comrak"
version = "0.12.1" version = "0.12.1"
source = "git+https://github.com/furbooru/comrak#4adb01d736b03a25c81451d62148da37256e99c7" source = "git+https://github.com/furbooru/comrak#b69625ef55b855675d9597c9dd5fe2dda50cc0c6"
dependencies = [ dependencies = [
"clap", "clap",
"entities", "entities",
@ -223,7 +223,7 @@ checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394"
[[package]] [[package]]
name = "furbooru_markdown" name = "furbooru_markdown"
version = "0.1.1" version = "0.2.0"
dependencies = [ dependencies = [
"comrak", "comrak",
"jemallocator", "jemallocator",

View file

@ -1,7 +1,7 @@
[package] [package]
name = "furbooru_markdown" name = "furbooru_markdown"
version = "0.1.1" version = "0.2.0"
authors = [] authors = ["Xe <https://github.com/Xe>", "Luna <https://github.com/Meow>", "Liam White <https://github.com/liamwhite>"]
edition = "2018" edition = "2018"
[lib] [lib]
@ -11,11 +11,11 @@ crate-type = ["dylib"]
[dependencies] [dependencies]
comrak = { git = "https://github.com/furbooru/comrak" } comrak = { git = "https://github.com/furbooru/comrak" }
lazy_static = "1.0" lazy_static = "1.4"
regex = "1" regex = "1.5"
log = "0" log = "0"
pretty_env_logger = "0" pretty_env_logger = "0"
rustler = "0.22.0" rustler = "0.22"
jemallocator = "0.3.2" jemallocator = "0.3.2"
[profile.release] [profile.release]

View file

@ -41,6 +41,7 @@ fn to_html(input: String) -> String {
options.extension.subscript = true; options.extension.subscript = true;
options.extension.spoiler = true; options.extension.spoiler = true;
options.extension.strikethrough = true; options.extension.strikethrough = true;
options.extension.underline = true;
// options.extension.furbooru = true; // options.extension.furbooru = true;
options.parse.smart = true; options.parse.smart = true;
options.render.hardbreaks = true; options.render.hardbreaks = true;
@ -84,6 +85,7 @@ fn to_html_unsafe(input: String) -> String {
options.extension.subscript = true; options.extension.subscript = true;
options.extension.spoiler = true; options.extension.spoiler = true;
options.extension.strikethrough = true; options.extension.strikethrough = true;
options.extension.underline = true;
// options.extension.furbooru = true; // options.extension.furbooru = true;
options.parse.smart = true; options.parse.smart = true;
options.render.hardbreaks = true; options.render.hardbreaks = true;