mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 21:32:40 +00:00
markdown preview: Ignore inline HTML tags in text (#19804)
Some checks are pending
CI / Check Postgres and Protobuf migrations, mergability (push) Waiting to run
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Linux) Build Remote Server (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
Some checks are pending
CI / Check Postgres and Protobuf migrations, mergability (push) Waiting to run
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Linux) Build Remote Server (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
Follow up to #19785 This PR ensures that we explicitly ignore inline HTML tags so that we can still extract the text between the tags and show them to the user Release Notes: - N/A
This commit is contained in:
parent
db61711753
commit
b13940720a
1 changed files with 34 additions and 0 deletions
|
@ -234,6 +234,10 @@ impl<'a> MarkdownParser<'a> {
|
|||
text.push('\n');
|
||||
}
|
||||
|
||||
// We want to ignore any inline HTML tags in the text but keep
|
||||
// the text between them
|
||||
Event::InlineHtml(_) => {}
|
||||
|
||||
Event::Text(t) => {
|
||||
text.push_str(t.as_ref());
|
||||
|
||||
|
@ -849,6 +853,16 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_text_with_inline_html() {
|
||||
let parsed = parse("This is a paragraph with an inline HTML <sometag>tag</sometag>.").await;
|
||||
|
||||
assert_eq!(
|
||||
parsed.children,
|
||||
vec![p("This is a paragraph with an inline HTML tag.", 0..63),],
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_raw_links_detection() {
|
||||
let parsed = parse("Checkout this https://zed.dev link").await;
|
||||
|
@ -1092,6 +1106,26 @@ Some other content
|
|||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_list_item_with_inline_html() {
|
||||
let parsed = parse(
|
||||
"\
|
||||
* This is a list item with an inline HTML <sometag>tag</sometag>.
|
||||
",
|
||||
)
|
||||
.await;
|
||||
|
||||
assert_eq!(
|
||||
parsed.children,
|
||||
vec![list_item(
|
||||
0..67,
|
||||
1,
|
||||
Unordered,
|
||||
vec![p("This is a list item with an inline HTML tag.", 4..44),],
|
||||
),],
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_nested_list_with_paragraph_inside() {
|
||||
let parsed = parse(
|
||||
|
|
Loading…
Reference in a new issue