[add] markup: arrow alignment

[add] markup: highlight (==)
[add] homepage redirect
This commit is contained in:
hkau 2024-03-30 12:53:25 -04:00
parent 971c202f53
commit 35edda448e
3 changed files with 67 additions and 2 deletions

View File

@ -76,6 +76,68 @@ pub fn render(input: &str) -> String {
"<div class=\"mdnote note-$2\"><b class=\"mdnote-title\">$3</b></div>\n",
);
// highlight
out = regex_replace(
&out,
"(\\={2})(.*?)(\\={2})",
"<span class=\"highlight\">$2</span>",
);
// unescape arrow alignment
out = regex_replace(&out, "-&gt;&gt;", "->>");
out = regex_replace(&out, "&lt;&lt;-", "<<-");
out = regex_replace(&out, "-&gt;", "->");
out = regex_replace(&out, "&lt;-", "<-");
// arrow alignment (flex)
let arrow_alignment_flex_regex = RegexBuilder::new("(\\->{2})(.*?)(\\->{2}|<{2}\\-)")
.multi_line(true)
.dot_matches_new_line(true)
.build()
.unwrap();
for capture in arrow_alignment_flex_regex.captures_iter(&out.clone()) {
let _match = capture.get(0).unwrap().as_str();
let content = capture.get(2).unwrap().as_str();
let align = if _match.ends_with(">") {
"right"
} else {
"center"
};
out = out.replacen(
_match,
&format!("<rf class=\"justify-{align}\">{content}</rf>\n"),
1,
);
}
// arrow alignment
let arrow_alignment_regex = RegexBuilder::new("(\\->{1})(.*?)(\\->{1}|<{1}\\-)")
.multi_line(true)
.dot_matches_new_line(true)
.build()
.unwrap();
for capture in arrow_alignment_regex.captures_iter(&out.clone()) {
let _match = capture.get(0).unwrap().as_str();
let content = capture.get(2).unwrap().as_str();
let align = if _match.ends_with(">") {
"right"
} else {
"center"
};
out = out.replacen(
_match,
&format!("<r class=\"text-{align}\">{content}</r>\n"),
1,
);
}
// some bbcode stuff
out = regex_replace(&out, r"\[b\](.*?)\[/b\]", "<strong>$1</strong>"); // bold
out = regex_replace(&out, r"\[i\](.*?)\[/i\]", "<em>$1</em>"); // italic

View File

@ -90,7 +90,7 @@
login
</a>
{% else %}
<a href="/d" class="button full round border justify-start">
<a href="{{ bundlrs }}/d" class="button full round border justify-start">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
class="lucide lucide-layout-dashboard">

View File

@ -7,7 +7,10 @@
{% endif %}
{% endblock %}
{% block head %}
<meta http-equiv="refresh" content="0; url={{ bundlrs }}" />
{% endblock %}
{% block content %}
<h1>Guppy!</h1>
{% call super() %}
{% endblock %}