add: hide_social_follows setting

This commit is contained in:
trisua 2025-07-25 13:39:34 -04:00
parent e78c43ab62
commit a337e0c7c1
11 changed files with 179 additions and 96 deletions

View file

@ -1,7 +1,7 @@
[package]
name = "tetratto-shared"
description = "Shared stuff for Tetratto"
version = "12.0.5"
version = "12.0.6"
edition = "2024"
authors.workspace = true
repository.workspace = true

View file

@ -3,7 +3,7 @@ use pulldown_cmark::{Parser, Options, html::push_html};
use std::collections::HashSet;
pub fn render_markdown_dirty(input: &str) -> String {
let input = &autolinks(&parse_alignment(input));
let input = &autolinks(&parse_alignment(&parse_backslash_breaks(input)));
let mut options = Options::empty();
options.insert(Options::ENABLE_STRIKETHROUGH);
@ -180,6 +180,32 @@ pub fn parse_alignment(input: &str) -> String {
output
}
pub fn parse_backslash_breaks(input: &str) -> String {
let mut in_pre_block = false;
let mut output = String::new();
for line in input.split("\n") {
if line.starts_with("```") {
in_pre_block = !in_pre_block;
output.push_str(&format!("{line}\n"));
continue;
}
if in_pre_block {
output.push_str(&format!("{line}\n"));
continue;
}
if line.trim_end().ends_with("\\") {
output.push_str(&format!("{line}<br />\n"));
} else {
output.push_str(&format!("{line}\n"));
}
}
output
}
/// Adapted from <https://git.cypr.io/oz/autolink-rust>.
///
/// The only real change here is that autolinks require a whitespace OR end the