mirror of
https://github.com/redlib-org/redlib.git
synced 2025-06-04 13:50:19 +00:00
* fix Code blocks https://github.com/redlib-org/redlib/issues/227 * add pulldown-cmark * add pulldown-cmark * fix Code blocks err #227 * add pre style for post codeblock * Update style.css (fix Code blocks err #227 ) --------- Co-authored-by: Matthew Esposito <matt@matthew.science>
This commit is contained in:
parent
c7f55c146a
commit
7770c57856
4 changed files with 36 additions and 1 deletions
10
src/utils.rs
10
src/utils.rs
|
@ -743,7 +743,15 @@ pub async fn parse_post(post: &Value) -> Post {
|
|||
get_setting("REDLIB_PUSHSHIFT_FRONTEND").unwrap_or_else(|| String::from(crate::config::DEFAULT_PUSHSHIFT_FRONTEND)),
|
||||
)
|
||||
} else {
|
||||
rewrite_urls(&val(post, "selftext_html"))
|
||||
let selftext = val(post, "selftext");
|
||||
if selftext.contains("```") {
|
||||
let mut html_output = String::new();
|
||||
let parser = pulldown_cmark::Parser::new(&selftext);
|
||||
pulldown_cmark::html::push_html(&mut html_output, parser);
|
||||
rewrite_urls(&html_output)
|
||||
} else {
|
||||
rewrite_urls(&val(post, "selftext_html"))
|
||||
}
|
||||
};
|
||||
|
||||
// Build a post using data parsed from Reddit post API
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue