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
4 changes: 4 additions & 0 deletions src/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use regex::Regex;

use crate::wrap::is_fence;

/// Characters that mark formatted text at the start of a line.
const FORMATTING_CHARS: [char; 3] = ['*', '_', '`'];

fn parse_numbered(line: &str) -> Option<(&str, &str, &str)> {
static NUMBERED_RE: std::sync::LazyLock<Regex> =
std::sync::LazyLock::new(|| Regex::new(r"^(\s*)([1-9][0-9]*)\.(\s+)(.*)").unwrap());
Expand All @@ -28,6 +31,7 @@ fn drop_deeper(indent: usize, counters: &mut Vec<(usize, usize)>) {

fn is_plain_paragraph_line(line: &str) -> bool {
line.trim_start()
.trim_start_matches(|c: char| FORMATTING_CHARS.contains(&c))
.chars()
.next()
.is_some_and(char::is_alphanumeric)
Expand Down
30 changes: 30 additions & 0 deletions tests/data/renumber_formatting_paragraph_expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
When pytest-forked creates child processes, Slipcover's enhanced capabilities
ensure that:

1. Each forked child process independently collects coverage data for the tests
it executes.

2. This data is temporarily stored.

3. Upon completion of all tests, the main Slipcover process aggregates the
coverage data from all child processes into a single, unified dataset.

4. The final coverage report is generated from this aggregated data.

**Practical Guide to Using Slipcover with** `pytest-forked`**:**
<!-- markdownlint-disable MD029 -->
Comment thread
leynos marked this conversation as resolved.

1. **Prerequisites**:

- Slipcover v1.0.4+

- Pytest

- `pytest-forked`

`bash pip install --upgrade slipcover pytest pytest-forked`

*Note:* `pytest-forked` *relies on the* `fork()` *system call, making it
suitable for Unix-like systems (Linux, macOS).*
Comment thread
leynos marked this conversation as resolved.

2. Command Invocation:
30 changes: 30 additions & 0 deletions tests/data/renumber_formatting_paragraph_input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
When pytest-forked creates child processes, Slipcover's enhanced capabilities
ensure that:

1. Each forked child process independently collects coverage data for the tests
it executes.

1. This data is temporarily stored.

1. Upon completion of all tests, the main Slipcover process aggregates the
coverage data from all child processes into a single, unified dataset.

1. The final coverage report is generated from this aggregated data.

**Practical Guide to Using Slipcover with** `pytest-forked`**:**
<!-- markdownlint-disable MD029 -->
Comment thread
leynos marked this conversation as resolved.

1. **Prerequisites**:

- Slipcover v1.0.4+

- Pytest

- `pytest-forked`

`bash pip install --upgrade slipcover pytest pytest-forked`

*Note:* `pytest-forked` *relies on the* `fork()` *system call, making it
suitable for Unix-like systems (Linux, macOS).*
Comment thread
leynos marked this conversation as resolved.

1. Command Invocation:
13 changes: 13 additions & 0 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,19 @@ fn test_renumber_restart_after_paragraph() {
assert_eq!(renumber_lists(&input), expected);
}

#[test]
fn test_renumber_restart_after_formatting_paragraph() {
let input: Vec<String> = include_str!("data/renumber_formatting_paragraph_input.txt")
.lines()
.map(str::to_string)
.collect();
let expected: Vec<String> = include_str!("data/renumber_formatting_paragraph_expected.txt")
.lines()
.map(str::to_string)
.collect();
assert_eq!(renumber_lists(&input), expected);
}

#[test]
fn test_format_breaks_basic() {
let input = vec!["foo", "***", "bar"]
Expand Down
7 changes: 7 additions & 0 deletions tests/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,10 @@ fn restart_after_nested_paragraph() {
let expected = lines_vec!("1. One", " 1. Sub", "", "Paragraph", "1. Next");
assert_eq!(renumber_lists(&input), expected);
}

#[test]
fn restart_after_formatting_paragraph() {
let input = lines_vec!("1. Start", "", "**Bold intro**", "", "4. Next");
let expected = lines_vec!("1. Start", "", "**Bold intro**", "", "1. Next");
assert_eq!(renumber_lists(&input), expected);
}