Skip to content

Improve fence specifier handling#127

Merged
leynos merged 4 commits intomainfrom
codex/fix-code-fence-indentation-issues
Jul 26, 2025
Merged

Improve fence specifier handling#127
leynos merged 4 commits intomainfrom
codex/fix-code-fence-indentation-issues

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Jul 25, 2025

Summary

  • preserve indentation from orphaned language lines when attaching code fence specifiers
  • allow comma separated specifiers with spaces
  • document the updated behaviour
  • cover the edge cases with tests

Testing

  • make fmt
  • make lint
  • make test
  • make markdownlint
  • make nixie (fails: too many arguments)

https://chatgpt.com/codex/tasks/task_e_6883f8be90ac8322999b36de77ba4f56

Summary by Sourcery

Improve code fence specifier handling by preserving indent from orphaned language lines and supporting comma-separated specifiers with spaces, update documentation, and add tests for edge cases

Enhancements:

  • Preserve indentation from orphaned specifier lines when attaching code fence specifiers to unindented fences
  • Accept and normalize comma-separated specifiers with spaces in code fences

Documentation:

  • Document new indentation preservation and space-tolerant comma-separated specifier behavior in function and architecture docs

Tests:

  • Add tests for indentation preservation when fences are unindented and for space-tolerant comma-separated specifiers

Preserves indentation from orphaned language lines and accepts spaces in comma-separated signifiers.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 25, 2025

Summary by CodeRabbit

  • Documentation
    • Improved documentation for code block specifier handling, clarifying indentation and formatting behaviour.
    • Updated README for clearer link text in the HTML table support section.
  • Bug Fixes
    • Enhanced handling of code block language specifiers to support multiple, comma-separated identifiers and preserve correct indentation.
  • Tests
    • Added new tests to verify correct attachment and normalisation of orphan specifiers, including indentation and formatting scenarios.

Walkthrough

Update the attach_orphan_specifiers function to support multiple comma-separated language identifiers with spaces, normalise them, and preserve indentation from the orphan specifier line when the fence is unindented. Enhance documentation to clarify these behaviours and add targeted tests to verify the new logic.

Changes

File(s) Change Summary
src/fences.rs Refactor attach_orphan_specifiers to allow multiple, spaced, comma-separated language specifiers and preserve indentation from the orphan specifier line when the fence is unindented. Improve normalisation and matching logic.
tests/fences.rs Add three tests verifying indentation preservation from orphan specifier lines, handling of mismatched indent styles, and normalisation of multi-specifier lines with spaces and commas.
docs/architecture.md Update documentation for attach_orphan_specifiers, detailing new handling of indentation and multi-specifier normalisation.
README.md Replace non-breaking space HTML entities with normal spaces in a Markdown link text under "HTML table support" section.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MarkdownLines
    participant attach_orphan_specifiers

    User->>MarkdownLines: Provide markdown lines (possibly with orphan specifier)
    MarkdownLines->>attach_orphan_specifiers: Pass lines for processing
    attach_orphan_specifiers->>attach_orphan_specifiers: Detect orphan specifier line
    attach_orphan_specifiers->>attach_orphan_specifiers: Normalise specifiers (trim, lowercase, join with commas)
    attach_orphan_specifiers->>attach_orphan_specifiers: Preserve indentation from orphan line if fence is unindented
    attach_orphan_specifiers->>MarkdownLines: Return processed lines
    MarkdownLines->>User: Output with attached specifiers and correct indentation
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

Possibly related PRs

Poem

Fences and specifiers, now neatly aligned,
With commas and spaces, their quirks redefined.
Indents preserved, no formatting askew,
Tests standing guard as the code marches through.
Markdown, rejoice—your fences are true!
🦾✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8046355 and 2823af3.

📒 Files selected for processing (2)
  • README.md (1 hunks)
  • src/fences.rs (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.md

📄 CodeRabbit Inference Engine (AGENTS.md)

**/*.md: Validate Markdown files using make markdownlint.
Run make fmt after any documentation changes to format all Markdown files and fix table markup.
Validate Mermaid diagrams in Markdown files by running make nixie.
Markdown paragraphs and bullet points must be wrapped at 80 columns.
Code blocks must be wrapped at 120 columns.
Tables and headings must not be wrapped.
Use dashes (-) for list bullets.
Use GitHub-flavoured Markdown footnotes ([^1]) for references.

Files:

  • README.md

⚙️ CodeRabbit Configuration File

**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")

  • Use en-GB-oxendict (-ize / -our) spelling and grammar
  • Paragraphs and bullets must be wrapped to 80 columns, except where a long URL would prevent this (in which case, silence MD013 for that line)
  • Code blocks should be wrapped to 120 columns.
  • Headings must not be wrapped.
  • Documents must start with a level 1 heading
  • Headings must correctly increase or decrease by no more than one level at a time
  • Use GitHub-flavoured Markdown style for footnotes and endnotes.
  • Numbered footnotes must be numbered by order of appearance in the document.

Files:

  • README.md
**/*.rs

📄 CodeRabbit Inference Engine (AGENTS.md)

**/*.rs: Comments must use en-GB-oxendict spelling and grammar.
Function documentation must include clear examples.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not use return in single-line functions.
Prefer immutable data and avoid unnecessary mut bindings.
Handle errors with the Result type instead of panicking where feasible.
Avoid unsafe code unless absolutely necessary and document any usage clearly.
Clippy warnings MUST be disallowed.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Prefer expect over allow.
Prefer .expect() over .unwrap().
Use concat!() to combine long string literals rather than escaping newlines with a backslash.
Use predicate functions for conditional criteria with more than two branches.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider using Arc to reduce the amount of data returned.
Comment why, not what. Explain assumptions, edge cases, trade-offs, or complexity. Don't echo the obvious.
Use functions and composition. Avoid repetition by extracting reusable logic. Prefer generators or comprehensions, and declarative code to imperative repetition when readable.
Small, meaningful functions. Functions must be small, clear in purpose, single responsibility, and obey command/query segregation.
Name things precisely. Use clear, descriptive variable and function names. For booleans, prefer names with is, has, or should.
Structure log...

Files:

  • src/fences.rs

⚙️ CodeRabbit Configuration File

**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.

  • Adhere to single responsibility and CQRS

  • Place function attributes after doc comments.

  • Do not use return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless absolutely necessary.

  • Every module must begin with a //! doc comment that explains the module's purpose and utility.

  • Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar

  • Lints must not be silenced except as a last resort.

    • #[allow] is forbidden.
    • Only narrowly scoped #[expect(lint, reason = "...")] is allowed.
    • No lint groups, no blanket or file-wide suppression.
    • Include FIXME: with link if a fix is expected.
  • Use rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for mocks/stubs.

  • Prefer .expect() over .unwrap()

  • Ensure that any API or behavioural changes are reflected in the documentation in docs/

  • Ensure that any completed roadmap steps are recorded in the appropriate roadmap in docs/

  • Files must not exceed 400 lines in length

    • Large modules must be decomposed
    • Long match statements or dispatch tables should be decomposed by domain and collocated with targets
    • Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.

Files:

  • src/fences.rs
⏰ Context from checks skipped due to timeout of 240000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-test
🔇 Additional comments (5)
src/fences.rs (4)

18-42: Well-implemented helper function.

The normalize_specifier function cleanly handles the requirements for processing orphaned language specifiers. The logic correctly extracts leading indentation and normalizes comma-separated identifiers with proper trimming and lowercasing. Using rust,ignore in the doctest appropriately addresses the previous visibility concerns whilst maintaining documentation.


79-81: Documentation accurately reflects new behaviour.

The updated function documentation correctly describes the indentation preservation and space normalization features introduced in this PR.


117-118: Proper integration of normalization helper.

The use of normalize_specifier correctly extracts both the cleaned specifier and indentation, with the regex match appropriately performed on the normalized string.


121-127: Correct indentation preservation logic.

The conditional logic properly preserves indentation from the orphan specifier line when the fence itself is unindented, whilst maintaining the fence's original indentation otherwise. The final fence construction correctly uses the normalized specifier.

README.md (1)

163-163: Improved link text readability.

Replacing HTML entities with regular spaces makes the link text more readable whilst maintaining the same semantic meaning.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/fix-code-fence-indentation-issues

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jul 25, 2025

Reviewer's Guide

This PR refines the orphan specifier attachment in fence processing by preserving indentation, normalizing comma-separated specifiers (with spaces), updates related documentation, and adds tests for these edge cases.

Class diagram for updated fence specifier handling

classDiagram
    class Fences {
        +compress_fences(lines: &[String]) -> Vec<String>
        +attach_orphan_specifiers(lines: &[String]) -> Vec<String>
    }
    Fences : +Preserves indentation from orphaned specifier lines
    Fences : +Normalizes comma-separated specifiers with spaces
    Fences : +Removes orphaned specifier lines and applies to following fence
Loading

File-Level Changes

Change Details Files
Preserve indentation from orphaned specifier lines when attaching them to opening fences
  • Capture leading whitespace from the specifier line
  • Decide on final_indent based on existing fence indent or specifier indent
  • Inject final_indent when formatting the opening fence
src/fences.rs
Normalize comma-separated code fence specifiers
  • Split raw specifier on commas, trim and filter out empty entries
  • Rejoin cleaned specifiers with commas and lowercase them
  • Match against ORPHAN_LANG_RE using the cleaned string
src/fences.rs
Update documentation for fence specifier behavior
  • Extend attach_orphan_specifiers doc comment to note indent preservation and space-tolerant specifiers
  • Update architecture.md to describe the revised fence specifier handling
src/fences.rs
docs/architecture.md
Add edge-case tests for updated fence handling
  • Test indent retention when the fence itself is unindented
  • Test acceptance and normalization of space-separated specifiers
tests/fences.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @leynos - I've reviewed your changes - here's some feedback:

  • Extract the comma-separated specifier normalization (split, trim, filter, join) into a helper function to improve readability and maintainability.
  • Consider adding an explicit example of comma-separated specifiers with spaces in docs/architecture.md to illustrate the new normalization behavior.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Extract the comma-separated specifier normalization (split, trim, filter, join) into a helper function to improve readability and maintainability.
- Consider adding an explicit example of comma-separated specifiers with spaces in docs/architecture.md to illustrate the new normalization behavior.

## Individual Comments

### Comment 1
<location> `tests/fences.rs:184` </location>
<code_context>
     assert_eq!(out, lines_vec![" \t```rust", " \tfn main() {}", " \t```"]);
 }
+
+#[test]
+fn attaches_orphan_specifier_uses_candidate_indent_when_fence_unindented() {
+    let input = lines_vec!["  Rust", "", "```", "fn main() {}", "```"];
+    let out = attach_orphan_specifiers(&compress_fences(&input));
+    assert_eq!(out, lines_vec!["  ```rust", "fn main() {}", "```"]);
+}
+
</code_context>

<issue_to_address>
Consider adding a test for mixed indentation between orphan specifier and fence.

Adding tests with varying indentation types or levels between the orphan specifier and the fence (e.g., tabs vs. spaces, or different space counts) will help verify the robustness of the indentation handling.
</issue_to_address>

### Comment 2
<location> `src/fences.rs:91` </location>
<code_context>
                 if idx > 0 {
-                    let candidate = out[idx - 1].trim().to_string();
-                    if ORPHAN_LANG_RE.is_match(&candidate)
+                    let candidate_raw = out[idx - 1].as_str();
+                    let candidate_trimmed = candidate_raw.trim();
+                    let candidate_clean = candidate_trimmed
</code_context>

<issue_to_address>
Consider extracting the specifier normalization and indentation logic into a helper function to simplify the loop body.

```suggestion
You can collapse the “raw → trimmed → cleaned” logic and the indent‐extraction into a small helper, which makes the loop body much flatter. For example:

```rust
/// Returns (cleaned_specifier, leading_indent)
fn normalize_specifier(line: &str) -> (String, String) {
    // capture leading whitespace
    let indent: String = line.chars().take_while(|c| c.is_whitespace()).collect();
    // trim, split on commas, re‐join, lowercase
    let cleaned = line
        .trim()
        .split(',')
        .map(str::trim)
        .filter(|s| !s.is_empty())
        .collect::<Vec<_>>()
        .join(",")
        .to_lowercase();
    (cleaned, indent)
}

// ... inside attach_orphan_specifiers ...
if lang_present.is_empty() {
    // back up over blank lines
    let mut idx = out.len();
    while idx > 0 && out[idx - 1].trim().is_empty() {
        idx -= 1;
    }
    if idx > 0 {
        let (candidate_clean, candidate_indent) = normalize_specifier(&out[idx - 1]);
        if ORPHAN_LANG_RE.is_match(&candidate_clean)
           && (idx == 1 || out[idx - 2].trim().is_empty())
        {
            let final_indent = if indent.is_empty() {
                &candidate_indent
            } else {
                indent
            };
            out.truncate(idx - 1);
            out.push(format!("{final_indent}```{}", candidate_clean));
            in_fence = true;
            continue;
        }
    }
}
```

This keeps identical behavior (split/trim/filter/join, indent fallback) but moves all the peeling logic into `normalize_specifier`, making the main flow more readable.
</issue_to_address>

### Comment 3
<location> `docs/architecture.md:24` </location>
<code_context>

 - `fences::compress_fences` and `attach_orphan_specifiers` normalize code block
-  delimiters.
+  delimiters. `attach_orphan_specifiers` keeps indentation from the language
+  line when the fence lacks it and tolerates spaces between comma-separated
+  languages.
</code_context>

<issue_to_address>
Bullet point text exceeds 80 columns and should be wrapped accordingly.

Please wrap the bullet point text so that no line exceeds 80 columns, as per the documentation guidelines.
</issue_to_address>

### Comment 4
<location> `docs/architecture.md:25` </location>
<code_context>
 - `fences::compress_fences` and `attach_orphan_specifiers` normalize code block
-  delimiters.
+  delimiters. `attach_orphan_specifiers` keeps indentation from the language
+  line when the fence lacks it and tolerates spaces between comma-separated
+  languages.
 - `html::convert_html_tables` transforms basic HTML tables into Markdown so \
</code_context>

<issue_to_address>
Bullet point text exceeds 80 columns and should be wrapped accordingly.

Please ensure that each line in the bullet point does not exceed 80 columns for readability and consistency.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread tests/fences.rs
Comment thread src/fences.rs Outdated
Comment thread docs/architecture.md Outdated
Comment thread docs/architecture.md Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
tests/fences.rs (1)

191-196: Good test for mismatched indentation handling.

This test correctly verifies that when the orphan specifier and fence lines have different indentation styles (spaces vs tabs), the fence line retains its original indentation whilst still attaching the specifier. This addresses the past review comment about testing mixed indentation scenarios.

docs/architecture.md (1)

24-26: Wrap the bullet point text to meet the 80-column requirement.

The bullet point text exceeds 80 columns and must be wrapped according to the documentation guidelines.

-- `fences::compress_fences` and `attach_orphan_specifiers` normalize code block
-  delimiters. The latter keeps indentation from the language line when the
-  fence lacks it. It also tolerates spaces within comma-separated specifiers,
-  e.g. `TOML, Ini` becomes `toml,ini`.
+- `fences::compress_fences` and `attach_orphan_specifiers` normalize code block
+  delimiters. The latter keeps indentation from the language line when the
+  fence lacks it. It also tolerates spaces within comma-separated
+  specifiers, e.g. `TOML, Ini` becomes `toml,ini`.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8088bf2 and 8046355.

📒 Files selected for processing (3)
  • docs/architecture.md (1 hunks)
  • src/fences.rs (3 hunks)
  • tests/fences.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
docs/**/*.md

📄 CodeRabbit Inference Engine (AGENTS.md)

docs/**/*.md: Reference: Use the markdown files within the docs/ directory as a knowledge base and source of truth for project requirements, dependency choices, and architectural decisions.
Update: When new decisions are made, requirements change, libraries are added/removed, or architectural patterns evolve, proactively update the relevant file(s) in the docs/ directory to reflect the latest state.
Documentation must use en-GB-oxendict spelling and grammar (with the exception of "license" which is to be left unchanged for community consistency).

Files:

  • docs/architecture.md
**/*.md

📄 CodeRabbit Inference Engine (AGENTS.md)

**/*.md: Validate Markdown files using make markdownlint.
Run make fmt after any documentation changes to format all Markdown files and fix table markup.
Validate Mermaid diagrams in Markdown files by running make nixie.
Markdown paragraphs and bullet points must be wrapped at 80 columns.
Code blocks must be wrapped at 120 columns.
Tables and headings must not be wrapped.
Use dashes (-) for list bullets.
Use GitHub-flavoured Markdown footnotes ([^1]) for references.

Files:

  • docs/architecture.md

⚙️ CodeRabbit Configuration File

**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")

  • Use en-GB-oxendict (-ize / -our) spelling and grammar
  • Paragraphs and bullets must be wrapped to 80 columns, except where a long URL would prevent this (in which case, silence MD013 for that line)
  • Code blocks should be wrapped to 120 columns.
  • Headings must not be wrapped.
  • Documents must start with a level 1 heading
  • Headings must correctly increase or decrease by no more than one level at a time
  • Use GitHub-flavoured Markdown style for footnotes and endnotes.
  • Numbered footnotes must be numbered by order of appearance in the document.

Files:

  • docs/architecture.md
**/*.rs

📄 CodeRabbit Inference Engine (AGENTS.md)

**/*.rs: Comments must use en-GB-oxendict spelling and grammar.
Function documentation must include clear examples.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not use return in single-line functions.
Prefer immutable data and avoid unnecessary mut bindings.
Handle errors with the Result type instead of panicking where feasible.
Avoid unsafe code unless absolutely necessary and document any usage clearly.
Clippy warnings MUST be disallowed.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Prefer expect over allow.
Prefer .expect() over .unwrap().
Use concat!() to combine long string literals rather than escaping newlines with a backslash.
Use predicate functions for conditional criteria with more than two branches.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider using Arc to reduce the amount of data returned.
Comment why, not what. Explain assumptions, edge cases, trade-offs, or complexity. Don't echo the obvious.
Use functions and composition. Avoid repetition by extracting reusable logic. Prefer generators or comprehensions, and declarative code to imperative repetition when readable.
Small, meaningful functions. Functions must be small, clear in purpose, single responsibility, and obey command/query segregation.
Name things precisely. Use clear, descriptive variable and function names. For booleans, prefer names with is, has, or should.
Structure log...

Files:

  • src/fences.rs
  • tests/fences.rs

⚙️ CodeRabbit Configuration File

**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.

  • Adhere to single responsibility and CQRS

  • Place function attributes after doc comments.

  • Do not use return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless absolutely necessary.

  • Every module must begin with a //! doc comment that explains the module's purpose and utility.

  • Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar

  • Lints must not be silenced except as a last resort.

    • #[allow] is forbidden.
    • Only narrowly scoped #[expect(lint, reason = "...")] is allowed.
    • No lint groups, no blanket or file-wide suppression.
    • Include FIXME: with link if a fix is expected.
  • Use rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for mocks/stubs.

  • Prefer .expect() over .unwrap()

  • Ensure that any API or behavioural changes are reflected in the documentation in docs/

  • Ensure that any completed roadmap steps are recorded in the appropriate roadmap in docs/

  • Files must not exceed 400 lines in length

    • Large modules must be decomposed
    • Long match statements or dispatch tables should be decomposed by domain and collocated with targets
    • Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.

Files:

  • src/fences.rs
  • tests/fences.rs
🧬 Code Graph Analysis (1)
tests/fences.rs (1)
src/fences.rs (2)
  • attach_orphan_specifiers (97-142)
  • compress_fences (56-73)
🪛 GitHub Actions: CI
src/fences.rs

[error] 25-27: Rust compiler error E0603: function normalize_specifier is private but used in doctest at line 25. The function is defined at line 31 but not public, causing doctest compilation failure.

🔇 Additional comments (5)
src/fences.rs (3)

31-42: Excellent implementation of the specifier normalisation logic.

The function correctly extracts leading indentation and normalises the specifier by splitting on commas, trimming whitespace, filtering empty strings, rejoining, and converting to lowercase. This addresses the past review comment about extracting this logic into a helper function.


117-127: Good use of the helper function with proper indentation handling.

The logic correctly uses normalize_specifier to process the candidate line and applies the appropriate indentation rules: using the candidate's indentation when the fence is unindented, otherwise preserving the fence's original indentation.


79-81: Documentation accurately reflects the enhanced behaviour.

The updated documentation correctly describes that indentation from the specifier line is preserved when the fence lacks indentation, and that specifiers containing spaces are accepted and normalised.

tests/fences.rs (2)

184-189: Excellent test for candidate indentation behaviour.

This test properly validates that when a fence line is unindented but the orphan specifier line has indentation, the specifier's indentation is applied to the fence line after attachment.


198-203: Proper test for space-separated specifier normalisation.

This test validates that orphan specifiers containing spaces and multiple comma-separated identifiers are correctly normalised by removing spaces and converting to lowercase when attached to the fence line.

Comment thread src/fences.rs
@leynos leynos merged commit eec930e into main Jul 26, 2025
2 checks passed
@leynos leynos deleted the codex/fix-code-fence-indentation-issues branch July 26, 2025 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant