@@ -1219,19 +1219,24 @@ def _static_extract_serialized_html_deps(
12191219        # HTMLdependency.get_tag_representation() 
12201220        pattern  =  r'<script type="application/json" data-html-dependency="">((?:.|\r|\n)*?)</script>' 
12211221        dep_strs  =  re .findall (pattern , html )
1222-         # Deduplicate dependencies. htmltools normally would dedupe dependencies, but 
1223-         # with HTMLTextDocuments, the input HTML would usually have been generated by 
1224-         # something else (like Quarto) and may not have the dependencies deduped. 
1225-         dep_strs  =  list (set (dep_strs ))
12261222
12271223        # Remove the serialized HTML dependencies from the HTML string 
12281224        html  =  re .sub (pattern , "" , html )
12291225
1226+         # Reconstitute the HTMLDependency objects 
1227+         # 
1228+         # Note: htmltools normally would dedupe dependencies, but 
1229+         # with HTMLTextDocuments, the input HTML would usually have been generated by 
1230+         # something else (like Quarto) and may not have the dependencies deduped. 
1231+         seen_deps : set [str ] =  set ()
12301232        deps : list [HTMLDependency ] =  []
12311233        for  dep_str  in  dep_strs :
1234+             if  dep_str  in  seen_deps :
1235+                 continue 
12321236            args  =  json .loads (dep_str )
12331237            dep  =  HTMLDependency (** args )
12341238            deps .append (dep )
1239+             seen_deps .add (dep_str )
12351240
12361241        return  (html , deps )
12371242
@@ -1554,13 +1559,7 @@ def as_html_tags(
15541559        Render the dependency as a ``TagList()``. 
15551560        """ 
15561561        d  =  self .as_dict (lib_prefix = lib_prefix , include_version = include_version )
1557-         metas  =  [
1558-             Tag (
1559-                 "meta" ,
1560-                 ** m ,  # pyright: ignore[reportArgumentType] 
1561-             )
1562-             for  m  in  self .meta 
1563-         ]
1562+         metas  =  [Tag ("meta" , ** m ) for  m  in  d ["meta" ]]
15641563        links  =  [Tag ("link" , ** s ) for  s  in  d ["stylesheet" ]]
15651564        scripts  =  [Tag ("script" , ** s ) for  s  in  d ["script" ]]
15661565        return  TagList (* metas , * links , * scripts , self .head )
0 commit comments