File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 14
14
from pathlib import Path
15
15
from sphinx .application import Sphinx
16
16
from dataclasses import dataclass
17
+ from sphinx .directives .code import CodeBlock
17
18
18
19
19
20
LINK_CORE = r"""
@@ -73,7 +74,15 @@ def replace(match: re.Match) -> str:
73
74
74
75
for line in code .splitlines (keepends = True ):
75
76
if line .strip ().startswith (":" ) and not firstCode :
76
- ret += cindent + line
77
+ colon_start = line .find (":" )
78
+ colon_end = line .rfind (":" )
79
+ if colon_start != - 1 and colon_end != - 1 and colon_start < colon_end :
80
+ option = line [colon_start + 1 :colon_end ].strip ()
81
+ if option in CodeBlock .option_spec :
82
+ ret += cindent + line
83
+ else :
84
+ ret += "\n " + cindent + line
85
+ firstCode = True
77
86
elif line .strip () == "" :
78
87
if not firstCode :
79
88
firstCode = True
You can’t perform that action at this time.
0 commit comments