Godot Engine – Multi-platform 2D and 3D game engine
make_rst.py: Escape `[` if it precedes a closing tag
Cyril Bissey76941b141d05
diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xmlindex 5126ad5cada..cab37b3b3c7 100644--- a/doc/classes/@GlobalScope.xml+++ b/doc/classes/@GlobalScope.xml@@ -2341,13 +2341,13 @@Z key.</constant><constant name="KEY_BRACKETLEFT" value="91" enum="Key" keywords="open square bracket">- Left bracket ([code][lb][/code]) key.+ Left bracket ([code skip-lint][[/code]) key.</constant><constant name="KEY_BACKSLASH" value="92" enum="Key">Backslash ([code]\[/code]) key.</constant><constant name="KEY_BRACKETRIGHT" value="93" enum="Key" keywords="close square bracket">- Right bracket ([code][rb][/code]) key.+ Right bracket ([code]][/code]) key.</constant><constant name="KEY_ASCIICIRCUM" value="94" enum="Key" keywords="caret">Caret ([code]^[/code]) key.diff --git a/doc/tools/make_rst.py b/doc/tools/make_rst.pyindex f784720f053..df0bdced2d2 100755--- a/doc/tools/make_rst.py+++ b/doc/tools/make_rst.py@@ -1960,7 +1960,16 @@ def format_text_block(if inside_code:# Exiting codeblocks and inline code tags.- if tag_state.closing and tag_state.name == inside_code_tag:+ # Escape opening square bracket if it immediately precedes a closing tag+ if tag_text and tag_text.startswith("[/"):+ if not ignore_code_warnings:+ print_warning(+ f'{state.current_class}.xml: Found possibly misformatted tag "[{tag_state.raw}]" in {context_name}. {code_warning_if_intended_string}',+ state,+ )+ tag_text = "["+ post_text = text[pos + 1 :]+ elif tag_state.closing and tag_state.name == inside_code_tag:if is_in_tagset(tag_state.name, RESERVED_CODEBLOCK_TAGS):tag_text = ""state.reserved_tag_check.add_closing_tag(tag_state.name)@@ -2048,7 +2057,9 @@ def format_text_block(ignore_code_warnings = "skip-lint" in tag_state.arguments.split(" ")elif is_in_tagset(tag_state.name, ["code"]):- tag_text = "``"+ # Escape formatting which can break rST, e.g. "(``)``".+ # This cannot be done with an f-string because Python < 3.12 doesn't allow \ escapes.+ tag_text = ("\\ " if pre_text.endswith("(") else "") + "``"state.reserved_tag_check.add_opening_tag(tag_state.name)inside_code = True