Skip to content

Commit 806bbfe

Browse files
Fix [Sphinx] [Automation] Issue -> PR conversion of code blocks | Closes #211 (#227)
* Fix Issue -> PR conversion of code blocks - Dedent before adding indentation - Add correct indentation * Fix: Normalize Markdown links and formatting - Convert inline-code links like [`text`](url) to standard [text](url) - Correct mixed bold/code formatting: - **`code`** → `code` - `**code**` → `code` This prevents Markdown parser errors in issue bodies and ensures consistent formatting. * Fix: address CI failure by updating snapshot-ci.yml * Fix: address CI failure by updating Pandoc installation * Fix import order in auto-pr-helper.py (ruff I001) Resolve ruff lint error I001 that was preventing the build. * Keep Pandoc installation out of this PR.
1 parent 8ddb34e commit 806bbfe

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

scripts/auto-pr-helper.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import re
55
import sys
6-
from textwrap import indent
6+
from textwrap import dedent, indent
77

88
from m2r import convert
99

@@ -113,9 +113,15 @@ def format_code_block(code: str, lang: str = "rust") -> str:
113113
lines = lines[1:]
114114
if lines and lines[-1].strip() == "```":
115115
lines = lines[:-1]
116+
117+
# Dedent before adding indentation
118+
dedented_code = dedent("\n".join(lines))
119+
120+
# Add required indentation
116121
indented_code = "\n".join(
117-
f" {line}" for line in lines
118-
) # Adds the required indentation
122+
f" {line}" for line in dedented_code.splitlines()
123+
)
124+
119125
return f"\n\n{indented_code}\n"
120126

121127
amplification_text = indent(md_to_rst(get("amplification")), " " * 12)

0 commit comments

Comments
 (0)