Skip to content
Merged
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions crates/biome_markdown_formatter/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,31 @@ impl IntoFormat<MarkdownFormatContext> for biome_markdown_syntax::AnyMdBlock {
)
}
}
impl AsFormat<MarkdownFormatContext> for biome_markdown_syntax::AnyMdBulletListMember {
type Format<'a> = FormatRefWithRule<
'a,
biome_markdown_syntax::AnyMdBulletListMember,
crate::markdown::any::bullet_list_member::FormatAnyMdBulletListMember,
>;
fn format(&self) -> Self::Format<'_> {
FormatRefWithRule::new(
self,
crate::markdown::any::bullet_list_member::FormatAnyMdBulletListMember::default(),
)
}
}
impl IntoFormat<MarkdownFormatContext> for biome_markdown_syntax::AnyMdBulletListMember {
type Format = FormatOwnedWithRule<
biome_markdown_syntax::AnyMdBulletListMember,
crate::markdown::any::bullet_list_member::FormatAnyMdBulletListMember,
>;
fn into_format(self) -> Self::Format {
FormatOwnedWithRule::new(
self,
crate::markdown::any::bullet_list_member::FormatAnyMdBulletListMember::default(),
)
}
}
impl AsFormat<MarkdownFormatContext> for biome_markdown_syntax::AnyMdCodeBlock {
type Format<'a> = FormatRefWithRule<
'a,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.

use crate::prelude::*;
use biome_markdown_syntax::AnyMdBulletListMember;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyMdBulletListMember;
impl FormatRule<AnyMdBulletListMember> for FormatAnyMdBulletListMember {
type Context = MarkdownFormatContext;
fn fmt(&self, node: &AnyMdBulletListMember, f: &mut MarkdownFormatter) -> FormatResult<()> {
match node {
AnyMdBulletListMember::MdBullet(node) => node.format().fmt(f),
AnyMdBulletListMember::MdNewline(node) => node.format().fmt(f),
}
}
}
1 change: 1 addition & 0 deletions crates/biome_markdown_formatter/src/markdown/any/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.

pub(crate) mod block;
pub(crate) mod bullet_list_member;
pub(crate) mod code_block;
pub(crate) mod container_block;
pub(crate) mod inline;
Expand Down
6 changes: 4 additions & 2 deletions crates/biome_markdown_parser/src/syntax/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,10 @@ fn skip_blank_lines_between_items(
// Blank lines between items make the list loose
*is_tight = false;
*last_item_ends_with_blank = true;
// Skip the blank line as trivia (no tree node created)
p.parse_as_skipped_trivia_tokens(|p| p.bump(NEWLINE));
// Emit blank line as an explicit MdNewline CST node
let newline_m = p.start();
p.bump(NEWLINE);
newline_m.complete(p, MD_NEWLINE);
}
}

Expand Down
26 changes: 20 additions & 6 deletions crates/biome_markdown_parser/src/syntax/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,7 @@ fn set_inline_emphasis_context(p: &mut MarkdownParser) -> Option<EmphasisContext
fn inline_list_source_len(p: &mut MarkdownParser) -> usize {
p.lookahead(|p| {
let mut len = 0usize;
let mut has_content = false;

loop {
if p.at(T![EOF]) {
Expand All @@ -1186,11 +1187,19 @@ fn inline_list_source_len(p: &mut MarkdownParser) -> usize {
consume_quote_prefix_without_virtual(p, quote_depth);
}

if has_content && p.at(MD_SETEXT_UNDERLINE_LITERAL) && allow_setext_heading(p) {
break;
}

if has_content && p.at(MD_THEMATIC_BREAK_LITERAL) && is_dash_only_thematic_break(p)
{
break;
}
if quote_depth > 0 && p.at(R_ANGLE) && !has_quote_prefix(p, quote_depth) {
consume_partial_quote_prefix_lookahead(p, quote_depth, &mut len);
}

if at_paragraph_break(p, true) {
if at_paragraph_break(p, has_content) {
break;
}

Expand Down Expand Up @@ -1228,9 +1237,10 @@ fn inline_list_source_len(p: &mut MarkdownParser) -> usize {
// We intentionally skip the heavier post-indent block-interrupt
// check here; the following non-NEWLINE pass still catches
// interrupts for emphasis-context length calculation.
if p.at(MD_SETEXT_UNDERLINE_LITERAL)
|| (p.at(MD_THEMATIC_BREAK_LITERAL)
&& is_dash_only_thematic_break_text(p.cur_text()))
if has_content
&& (p.at(MD_SETEXT_UNDERLINE_LITERAL)
|| (p.at(MD_THEMATIC_BREAK_LITERAL)
&& is_dash_only_thematic_break_text(p.cur_text())))
{
break;
}
Expand All @@ -1239,18 +1249,22 @@ fn inline_list_source_len(p: &mut MarkdownParser) -> usize {
continue;
}

if p.at(MD_SETEXT_UNDERLINE_LITERAL) && allow_setext_heading(p) {
if has_content && p.at(MD_SETEXT_UNDERLINE_LITERAL) && allow_setext_heading(p) {
break;
}

if p.at(MD_THEMATIC_BREAK_LITERAL) && is_dash_only_thematic_break(p) {
if has_content && p.at(MD_THEMATIC_BREAK_LITERAL) && is_dash_only_thematic_break(p) {
break;
}

if p.has_preceding_line_break() && at_block_interrupt(p) {
break;
}

if !p.cur_text().chars().all(|c| c == ' ' || c == '\t') {
has_content = true;
}

len += p.cur_text().len();
p.bump(p.cur());
}
Expand Down
20 changes: 12 additions & 8 deletions crates/biome_markdown_parser/src/to_html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
//! be decided with full context.

use biome_markdown_syntax::{
AnyMdBlock, AnyMdCodeBlock, AnyMdInline, AnyMdLeafBlock, MarkdownLanguage, MdAutolink,
MdBlockList, MdBullet, MdBulletListItem, MdDocument, MdEntityReference, MdFencedCodeBlock,
MdHardLine, MdHeader, MdHtmlBlock, MdIndentCodeBlock, MdInlineCode, MdInlineEmphasis,
MdInlineHtml, MdInlineImage, MdInlineItalic, MdInlineItemList, MdInlineLink, MdLinkBlock,
MdLinkDestination, MdLinkLabel, MdLinkReferenceDefinition, MdLinkTitle, MdOrderedListItem,
MdParagraph, MdQuote, MdReferenceImage, MdReferenceLink, MdReferenceLinkLabel, MdSetextHeader,
MdSoftBreak, MdTextual, MdThematicBreakBlock,
AnyMdBlock, AnyMdBulletListMember, AnyMdCodeBlock, AnyMdInline, AnyMdLeafBlock,
MarkdownLanguage, MdAutolink, MdBlockList, MdBullet, MdBulletListItem, MdDocument,
MdEntityReference, MdFencedCodeBlock, MdHardLine, MdHeader, MdHtmlBlock, MdIndentCodeBlock,
MdInlineCode, MdInlineEmphasis, MdInlineHtml, MdInlineImage, MdInlineItalic, MdInlineItemList,
MdInlineLink, MdLinkBlock, MdLinkDestination, MdLinkLabel, MdLinkReferenceDefinition,
MdLinkTitle, MdOrderedListItem, MdParagraph, MdQuote, MdReferenceImage, MdReferenceLink,
MdReferenceLinkLabel, MdSetextHeader, MdSoftBreak, MdTextual, MdThematicBreakBlock,
};
use biome_rowan::{AstNode, AstNodeList, Direction, SyntaxNode, TextRange, WalkEvent};
use percent_encoding::{AsciiSet, CONTROLS, utf8_percent_encode};
Expand Down Expand Up @@ -565,7 +565,11 @@ impl<'a> HtmlRenderer<'a> {

let start = list
.md_bullet_list()
.first()
.iter()
.find_map(|member| match member {
AnyMdBulletListMember::MdBullet(bullet) => Some(bullet),
_ => None,
})
.and_then(|bullet| bullet.prefix().ok())
.and_then(|prefix| prefix.marker().ok())
.map_or(1, |marker| {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Blank lines between bullet items

- foo

- bar

- baz

# Blank lines between ordered items

1. first

2. second

3. third

# Multiple blank lines between items

- alpha


- beta

# Mixed: some items separated, some not

- one
- two

- three
Loading
Loading