fix: rm top margin for 1st md heading

This commit is contained in:
2026-05-13 02:30:26 +08:00
parent 930640f370
commit 2842640995

View File

@@ -152,6 +152,8 @@ impl MarkdownText {
let mut cursor = tree.walk();
cursor.goto_first_child();
let mut is_first_heading = true;
fn block_for_node(
cursor: &mut tree_sitter::TreeCursor,
content: &str,
@@ -394,16 +396,16 @@ impl MarkdownText {
}
};
let block = match marker_node_kind {
let mut block = match marker_node_kind {
| MARKDOWN_KIND_ID_ATX_H1_MARKER => block
.text_size(rems(2.25))
.font_weight(gpui::FontWeight::EXTRA_BOLD)
.mb_8(),
.mb_6(),
| MARKDOWN_KIND_ID_ATX_H2_MARKER => block
.text_2xl()
.font_weight(gpui::FontWeight::BOLD)
.mt_12()
.mb_6(),
.mb_4(),
| MARKDOWN_KIND_ID_ATX_H3_MARKER => block
.text_xl()
.font_weight(gpui::FontWeight::SEMIBOLD)
@@ -418,6 +420,11 @@ impl MarkdownText {
}
.text_color(theme.colors.text);
if is_first_heading {
is_first_heading = false;
block = block.mt_0();
}
cursor.goto_parent();
self.blocks.push(block);