mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
underline + escaping md
This commit is contained in:
parent
4b46ca803f
commit
cab0fb1b18
4 changed files with 13 additions and 9 deletions
|
@ -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
|
||||
|
|
4
native/furbooru_markdown/Cargo.lock
generated
4
native/furbooru_markdown/Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "furbooru_markdown"
|
||||
version = "0.1.1"
|
||||
authors = []
|
||||
version = "0.2.0"
|
||||
authors = ["Xe <https://github.com/Xe>", "Luna <https://github.com/Meow>", "Liam White <https://github.com/liamwhite>"]
|
||||
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]
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue