@@ -743,6 +743,13 @@ def render_fence(self, token: SyntaxTreeNode) -> None:
743743 return self .render_restructuredtext (token )
744744 if name .startswith ("{" ) and name .endswith ("}" ):
745745 return self .render_directive (token , name [1 :- 1 ], arguments )
746+ if name in self .md_config .fence_as_directive :
747+ options = {k : str (v ) for k , v in token .attrs .items ()}
748+ if "id" in options :
749+ options ["name" ] = options .pop ("id" )
750+ return self .render_directive (
751+ token , name , arguments , additional_options = options
752+ )
746753
747754 if not name and self .sphinx_env is not None :
748755 # use the current highlight setting, via the ``highlight`` directive,
@@ -1664,7 +1671,12 @@ def render_restructuredtext(self, token: SyntaxTreeNode) -> None:
16641671 self .current_node .extend (newdoc .children )
16651672
16661673 def render_directive (
1667- self , token : SyntaxTreeNode , name : str , arguments : str
1674+ self ,
1675+ token : SyntaxTreeNode ,
1676+ name : str ,
1677+ arguments : str ,
1678+ * ,
1679+ additional_options : dict [str , str ] | None = None ,
16681680 ) -> None :
16691681 """Render special fenced code blocks as directives.
16701682
@@ -1673,7 +1685,13 @@ def render_directive(
16731685 :param arguments: The remaining text on the same line as the directive name.
16741686 """
16751687 position = token_line (token )
1676- nodes_list = self .run_directive (name , arguments , token .content , position )
1688+ nodes_list = self .run_directive (
1689+ name ,
1690+ arguments ,
1691+ token .content ,
1692+ position ,
1693+ additional_options = additional_options ,
1694+ )
16771695 self .current_node += nodes_list
16781696
16791697 def run_directive (
0 commit comments