55corresponding sanitization rules for server-side HTML cleaning.
66"""
77
8+ import warnings
89from typing import Any
910
1011from django .conf import settings
@@ -246,8 +247,9 @@ def process_node_class(config, shared_config):
246247 "Placeholder" : html_tags ([]),
247248}
248249
249- # Automatic dependencies (extensions that require other extensions)
250- EXTENSION_DEPENDENCIES = {
250+ # DEPRECATED: This dictionary is no longer used for automatic dependency management
251+ # but kept for backwards compatibility checking
252+ LEGACY_EXTENSION_DEPENDENCIES = {
251253 "BulletList" : ["ListItem" ],
252254 "OrderedList" : ["ListItem" ],
253255 "Table" : ["TableRow" , "TableHeader" , "TableCell" ],
@@ -260,7 +262,7 @@ def process_node_class(config, shared_config):
260262
261263def expand_extensions (extensions : dict [str , Any ]) -> dict [str , Any ]:
262264 """
263- Expand extension configuration by applying defaults and resolving dependencies .
265+ Expand extension configuration by applying defaults.
264266
265267 Args:
266268 extensions: Dictionary of extension configurations
@@ -292,16 +294,52 @@ def expand_extensions(extensions: dict[str, Any]) -> dict[str, Any]:
292294 if config is not False
293295 }
294296
295- # Resolve dependencies
296- for extension , deps in EXTENSION_DEPENDENCIES .items ():
297- if extension in expanded :
298- for dep in deps :
299- if dep not in expanded :
300- expanded [dep ] = True
297+ # Check for legacy dependency issues and warn
298+ dependency_warnings = check_legacy_dependencies (extensions )
299+ for warning_msg in dependency_warnings :
300+ warnings .warn (
301+ warning_msg ,
302+ UserWarning ,
303+ stacklevel = 3 , # Point to the calling code, not this function
304+ )
301305
302306 return expanded
303307
304308
309+ def check_legacy_dependencies (extensions : dict [str , Any ]) -> list [str ]:
310+ """
311+ Check if the extension configuration relies on legacy automatic dependency management.
312+
313+ This function identifies configurations that would have worked with automatic
314+ dependency resolution but may now be incomplete.
315+
316+ Args:
317+ extensions: Dictionary of extension configurations (raw, not expanded)
318+
319+ Returns:
320+ List of warning messages about missing dependencies
321+ """
322+ warnings = []
323+
324+ # Filter enabled extensions (don't call expand_extensions to avoid recursion)
325+ enabled_extensions = {
326+ extension : config
327+ for extension , config in extensions .items ()
328+ if config is not False
329+ }
330+
331+ for extension , deps in LEGACY_EXTENSION_DEPENDENCIES .items ():
332+ if extension in enabled_extensions :
333+ for dep in deps :
334+ if dep not in enabled_extensions :
335+ warnings .append (
336+ f"Extension '{ extension } ' typically requires '{ dep } ' to function properly. "
337+ f"Consider adding '{ dep } ': True to your configuration."
338+ )
339+
340+ return warnings
341+
342+
305343def js_from_extensions (
306344 extensions : dict [str , Any ],
307345) -> list [str ]:
0 commit comments