Skip to content

Add indent code - #68

Open
argonism wants to merge 1 commit into
gfmfrom
gfm-inline-code
Open

Add indent code#68
argonism wants to merge 1 commit into
gfmfrom
gfm-inline-code

Conversation

@argonism

@argonism argonism commented Oct 31, 2025

Copy link
Copy Markdown
Collaborator

#57

Copilot AI review requested due to automatic review settings October 31, 2025 00:35
@argonism
argonism changed the base branch from main to gfm October 31, 2025 00:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for Markdown indented code blocks (code blocks created by indenting lines with 4+ spaces) through a new MdIndentCode class. This complements the existing MdCode class which handles fenced code blocks and inline code.

  • Implements MdIndentCode class that indents each line with 4 spaces (configurable)
  • Validates indent parameter (minimum 4 spaces per Markdown spec)
  • Provides comprehensive test coverage for edge cases

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
mdfy/elements/indent_code.py New element class for indented code blocks with validation and configurable indentation
tests/elements/indent_code_test.py Comprehensive test suite covering single/multi-line code, empty lines, whitespace preservation, and special characters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"""

if code is None:
raise ValueError("Code content cannot be None.")

Copilot AI Oct 31, 2025

Copy link

Choose a reason for hiding this comment

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

This validation is inconsistent with the existing MdCode class, which logs a warning and sets None to an empty string instead of raising an exception. Consider using the same pattern (warning + default) for consistency across the codebase.

Suggested change
raise ValueError("Code content cannot be None.")
logger.warning("Code content is None; setting code to empty string.")
code = ""

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +62
str: String representation of the indented code with 4-space indentation.

The method:
- Adds 4 spaces indentation to each line

Copilot AI Oct 31, 2025

Copy link

Choose a reason for hiding this comment

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

The docstring hardcodes '4-space indentation' but the method uses self.indent which is configurable. Update to reflect that the indentation uses the configured value (e.g., 'String representation of the indented code with configured indentation').

Suggested change
str: String representation of the indented code with 4-space indentation.
The method:
- Adds 4 spaces indentation to each line
str: String representation of the indented code with configured indentation.
The method:
- Adds configured indentation (self.indent spaces) to each line

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +62
str: String representation of the indented code with 4-space indentation.

The method:
- Adds 4 spaces indentation to each line

Copilot AI Oct 31, 2025

Copy link

Choose a reason for hiding this comment

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

The documentation hardcodes '4 spaces' but the method uses self.indent which is configurable. Update to reflect that the indentation uses the configured value (e.g., 'Adds configured indentation to each line').

Suggested change
str: String representation of the indented code with 4-space indentation.
The method:
- Adds 4 spaces indentation to each line
str: String representation of the indented code with configured indentation.
The method:
- Adds configured indentation to each line

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants