mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-20 06:37:59 +01:00
dgr
This commit is contained in:
parent
245eb781c8
commit
f9a7a28df3
1 changed files with 4 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
use comrak::{markdown_to_html, ComrakOptions};
|
use comrak::{markdown_to_html, ComrakOptions};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use regex::{Captures, Regex};
|
use regex::{Captures, Regex};
|
||||||
|
use rustler::Term;
|
||||||
|
|
||||||
mod atoms {
|
mod atoms {
|
||||||
rustler::atoms! {
|
rustler::atoms! {
|
||||||
|
@ -40,6 +41,7 @@ fn to_html(input: String) -> String {
|
||||||
options.parse.smart = true;
|
options.parse.smart = true;
|
||||||
options.render.hardbreaks = true;
|
options.render.hardbreaks = true;
|
||||||
options.render.github_pre_lang = true;
|
options.render.github_pre_lang = true;
|
||||||
|
options.render.escape = true;
|
||||||
let mut result = markdown_to_html(&text, &options);
|
let mut result = markdown_to_html(&text, &options);
|
||||||
|
|
||||||
result = match IMAGE_MENTION_REPLACE.captures(&result) {
|
result = match IMAGE_MENTION_REPLACE.captures(&result) {
|
||||||
|
@ -51,7 +53,7 @@ fn to_html(input: String) -> String {
|
||||||
"p" => result, // TODO(Xe): large preview rendering
|
"p" => result, // TODO(Xe): large preview rendering
|
||||||
"" => String::from(
|
"" => String::from(
|
||||||
IMAGE_MENTION_REPLACE.replace_all(&result, |caps: &Captures| {
|
IMAGE_MENTION_REPLACE.replace_all(&result, |caps: &Captures| {
|
||||||
format!(r#"<a href="/{0}">>>{0}</a>"#, &caps[1])
|
format!(r#"<a href="/images/{0}">>>{0}</a>"#, &caps[1])
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
_ => result,
|
_ => result,
|
||||||
|
@ -78,6 +80,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.front_matter_delimiter = Some("---".to_owned());
|
||||||
// options.extension.furbooru = true;
|
// options.extension.furbooru = true;
|
||||||
options.parse.smart = true;
|
options.parse.smart = true;
|
||||||
options.render.hardbreaks = true;
|
options.render.hardbreaks = true;
|
||||||
|
|
Loading…
Reference in a new issue