@@ -656,11 +656,11 @@ def _setclass_html(ont__, obj__, back_onts__, ns__, fids__):
656
656
"""Makes lists of (union) 'ClassX or Class Y or ClassZ' or
657
657
(intersection) 'ClassX and Class Y and ClassZ'"""
658
658
if (obj__ , OWL .unionOf , None ) in ont__ :
659
- joining_word = ' < span class ="cardinality">or</span> '
659
+ joining_word = span ( "or" , _class = "cardinality" )
660
660
elif (obj__ , OWL .intersectionOf , None ) in ont__ :
661
- joining_word = ' < span class ="cardinality">and</span> '
661
+ joining_word = span ( "and" , _class = "cardinality" )
662
662
else :
663
- joining_word = ' < span class ="cardinality">,</span> '
663
+ joining_word = span ( "," , _class = "cardinality" )
664
664
665
665
class_set = set ()
666
666
for o in ont__ .objects (obj__ , OWL .unionOf | OWL .intersectionOf ):
@@ -671,7 +671,7 @@ def _setclass_html(ont__, obj__, back_onts__, ns__, fids__):
671
671
)
672
672
)
673
673
674
- return raw ( joining_word . join ([ mem . render () for mem in class_set ]) )
674
+ return intersperse ( class_set , joining_word )
675
675
676
676
def _bn_html (ont__ , back_onts__ , ns__ , fids__ , obj__ : BNode ):
677
677
# TODO: remove back_onts and fids if not needed by subfunctions
@@ -871,6 +871,11 @@ def _element_html(
871
871
return elems
872
872
873
873
874
+ def intersperse (lst , sep ):
875
+ result = [sep ] * (len (lst ) * 2 - 1 )
876
+ result [0 ::2 ] = lst
877
+ return result
878
+
874
879
def de_space_html (html ):
875
880
# s = "".join([l_.strip().replace("\n", " ") for l_ in html.split("\n")])
876
881
# return re.sub(" +", " ", s)
0 commit comments