docs: MDX leftover fixes (#3536)

# What does this PR do?

- Fixes Docusaurus build errors

<!-- Provide a short summary of what this PR does and why. Link to relevant issues if applicable. -->

<!-- If resolving an issue, uncomment and update the line below -->

<!-- Closes #[issue-number] -->

## Test Plan

- `npm run build`​ compiles the build properly
- Broken links expected and will be fixed in a follow-on PR

<!-- Describe the tests you ran to verify your changes with result summaries. *Provide clear instructions so the plan can be easily re-executed.* -->
This commit is contained in:
Alexey Rybak 2025-09-24 14:14:32 -07:00 committed by GitHub
parent aebd728c81
commit 8537ada11b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 96 additions and 110 deletions

View file

@ -229,17 +229,33 @@ def generate_provider_docs(progress, provider_spec: Any, api_name: str) -> str:
# Handle multiline default values and escape problematic characters for MDX
if "\n" in default:
default = (
default.replace("\n", "<br/>")
.replace("<", "&lt;")
.replace(">", "&gt;")
.replace("{", "&#123;")
.replace("}", "&#125;")
)
# For multiline defaults, escape angle brackets and use <br/> for line breaks
lines = default.split("\n")
escaped_lines = []
for line in lines:
if line.strip():
# Escape angle brackets and wrap template tokens in backticks
escaped_line = line.strip().replace("<", "&lt;").replace(">", "&gt;")
if ("{" in escaped_line and "}" in escaped_line) or (
"&lt;|" in escaped_line and "|&gt;" in escaped_line
):
escaped_lines.append(f"`{escaped_line}`")
else:
escaped_lines.append(escaped_line)
else:
escaped_lines.append("")
default = "<br/>".join(escaped_lines)
else:
default = (
default.replace("<", "&lt;").replace(">", "&gt;").replace("{", "&#123;").replace("}", "&#125;")
)
# For single line defaults, escape angle brackets first
escaped_default = default.replace("<", "&lt;").replace(">", "&gt;")
# Then wrap template tokens in backticks
if ("{" in escaped_default and "}" in escaped_default) or (
"&lt;|" in escaped_default and "|&gt;" in escaped_default
):
default = f"`{escaped_default}`"
else:
# Apply additional escaping for curly braces
default = escaped_default.replace("{", "&#123;").replace("}", "&#125;")
description_text = field_info["description"] or ""
# Escape curly braces in description text for MDX compatibility