Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(notecard): workaround for prettier #157

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/rari-doc/src/html/rewriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::collections::HashSet;
use lol_html::html_content::ContentType;
use lol_html::{element, rewrite_str, text, HtmlRewriter, RewriteStrSettings, Settings};
use rari_md::ext::DELIM_START;
use rari_md::node_card::NoteCard;
use rari_md::note_card::NoteCard;
use rari_types::fm_types::PageType;
use rari_types::globals::settings;
use rari_utils::concat_strs;
Expand Down
2 changes: 1 addition & 1 deletion crates/rari-md/src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::anchor;
use crate::character_set::character_set;
use crate::ctype::isspace;
use crate::ext::{Flag, DELIM_START};
use crate::node_card::{alert_type_css_class, alert_type_default_title, is_callout, NoteCard};
use crate::note_card::{alert_type_css_class, alert_type_default_title, is_callout, NoteCard};

/// Formats an AST as HTML, modified by the given options.
pub fn format_document<'a>(
Expand Down
2 changes: 1 addition & 1 deletion crates/rari-md/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub(crate) mod dl;
pub mod error;
pub mod ext;
pub(crate) mod html;
pub mod node_card;
pub mod note_card;
pub(crate) mod p;

use dl::{convert_dl, is_dl};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ pub(crate) fn is_callout<'a>(block_quote: &'a AstNode<'a>, locale: Locale) -> Op
let mut data = marker.data.borrow_mut();
if let NodeValue::Text(ref text) = data.value {
if text.starts_with(NoteCard::Callout.new_prefix()) {
if let Some(n) = child.children().nth(1) {
if matches!(n.data.borrow().value, NodeValue::LineBreak) {
n.data.borrow_mut().value = NodeValue::SoftBreak;
}
};
if text.trim() == NoteCard::Callout.new_prefix() {
marker.detach();
} else if let Some(tail) = text.strip_prefix(NoteCard::Callout.new_prefix()) {
Expand All @@ -87,6 +92,11 @@ pub(crate) fn is_callout<'a>(block_quote: &'a AstNode<'a>, locale: Locale) -> Op
return Some(NoteCard::Callout);
}
if text.starts_with(NoteCard::Warning.new_prefix()) {
if let Some(n) = child.children().nth(1) {
if matches!(n.data.borrow().value, NodeValue::LineBreak) {
n.data.borrow_mut().value = NodeValue::SoftBreak;
}
};
if text.trim() == NoteCard::Warning.new_prefix() {
marker.detach();
} else if let Some(tail) = text.strip_prefix(NoteCard::Warning.new_prefix()) {
Expand All @@ -95,6 +105,11 @@ pub(crate) fn is_callout<'a>(block_quote: &'a AstNode<'a>, locale: Locale) -> Op
return Some(NoteCard::Warning);
}
if text.starts_with(NoteCard::Note.new_prefix()) {
if let Some(n) = child.children().nth(1) {
if matches!(n.data.borrow().value, NodeValue::LineBreak) {
n.data.borrow_mut().value = NodeValue::SoftBreak;
}
};
if text.trim() == NoteCard::Note.new_prefix() {
marker.detach();
} else if let Some(tail) = text.strip_prefix(NoteCard::Note.new_prefix()) {
Expand Down
Loading