@@ -122,13 +122,29 @@ def _render_cross_reference(node: RenderTreeNode, context: RenderContext) -> str
122
122
return _render_with_default_renderer (node , context , "link" )
123
123
124
124
125
+ def add_extra_admon_newline (node : RenderTreeNode , context : RenderContext ) -> str :
126
+ """Return admonition with additional newline after the title.
127
+
128
+ See: https://github.com/KyleKing/mdformat-admon/pull/22
129
+
130
+ """
131
+ result = ADMON_RENDERS ["admonition" ](node , context )
132
+ if "\n " not in result :
133
+ return result
134
+ title , * content = result .split ("\n " , maxsplit = 1 )
135
+ return f"{ title } \n \n { '' .join (content )} "
136
+
137
+
125
138
# A mapping from syntax tree node type to a function that renders it.
126
139
# This can be used to overwrite renderer functions of existing syntax
127
140
# or add support for new syntax.
128
141
RENDERERS : Mapping [str , Render ] = {
129
- "admonition_mkdocs" : ADMON_RENDERS ["admonition" ],
142
+ # TODO: address conflict with mdformat-admon because mkdocs needs to override
143
+ "admonition" : add_extra_admon_newline ,
144
+ "admonition_title" : ADMON_RENDERS ["admonition_title" ],
145
+ "admonition_mkdocs" : add_extra_admon_newline ,
130
146
"admonition_mkdocs_title" : ADMON_RENDERS ["admonition_title" ],
131
- "content_tab_mkdocs" : ADMON_RENDERS [ "admonition" ] ,
147
+ "content_tab_mkdocs" : add_extra_admon_newline ,
132
148
"content_tab_mkdocs_title" : ADMON_RENDERS ["admonition_title" ],
133
149
MKDOCSTRINGS_AUTOREFS_PREFIX : _render_meta_content ,
134
150
MKDOCSTRINGS_HEADING_AUTOREFS_PREFIX : _render_heading_autoref ,
0 commit comments