@@ -419,14 +419,11 @@ def format_history_text(text, trunc_words=25):
419419def format_snippet (text , trunc_words = 25 ):
420420 # urlize if there aren't already links present
421421 if not 'href=' in text :
422- # django's urlize() cannot handle adjacent parentheszised
423- # expressions, for instance [REF](http://example.com/foo)
424- # Use bleach.linkify instead
425- text = bleach .linkify (text )
422+ text = bleach .linkify (text , parse_email = True )
426423 full = keep_spacing (collapsebr (linebreaksbr (mark_safe (sanitize_fragment (text )))))
427424 snippet = truncatewords_html (full , trunc_words )
428425 if snippet != full :
429- return mark_safe ('<div class="snippet">%s<button class="btn btn-sm btn-primary show-all"><i class="bi bi-caret-down"></i></button></div><div class="hidden full">%s</div>' % (snippet , full ))
426+ return mark_safe ('<div class="snippet">%s<button class="btn btn-sm btn-primary show-all"><i class="bi bi-caret-down"></i></button></div><div class="visually- hidden full">%s</div>' % (snippet , full ))
430427 return full
431428
432429@register .simple_tag
@@ -493,18 +490,32 @@ def consensus(doc):
493490 return "Unknown"
494491
495492@register .filter
496- def pos_to_label (text ):
497- """Return a valid Bootstrap label type for a ballot position."""
493+ def pos_to_label_format (text ):
494+ """Returns valid Bootstrap classes to label a ballot position."""
498495 return {
499- 'Yes' : 'success' ,
500- 'No Objection' : 'info' ,
501- 'Abstain' : 'warning' ,
502- 'Discuss' : 'danger' ,
503- 'Block' : 'danger' ,
504- 'Recuse' : 'primary' ,
505- 'Not Ready' : 'danger' ,
506- 'Need More Time' : 'danger' ,
507- }.get (str (text ), 'secondary' )
496+ 'Yes' : 'bg-yes text-light' ,
497+ 'No Objection' : 'bg-noobj text-dark' ,
498+ 'Abstain' : 'bg-abstain text-light' ,
499+ 'Discuss' : 'bg-discuss text-light' ,
500+ 'Block' : 'bg-discuss text-light' ,
501+ 'Recuse' : 'bg-recuse text-light' ,
502+ 'Not Ready' : 'bg-discuss text-light' ,
503+ 'Need More Time' : 'bg-discuss text-light' ,
504+ }.get (str (text ), 'bg-norecord text-dark' )
505+
506+ @register .filter
507+ def pos_to_border_format (text ):
508+ """Returns valid Bootstrap classes to label a ballot position border."""
509+ return {
510+ 'Yes' : 'border-yes' ,
511+ 'No Objection' : 'border-noobj' ,
512+ 'Abstain' : 'border-abstain' ,
513+ 'Discuss' : 'border-discuss' ,
514+ 'Block' : 'border-discuss' ,
515+ 'Recuse' : 'border-recuse' ,
516+ 'Not Ready' : 'border-discuss' ,
517+ 'Need More Time' : 'border-discuss' ,
518+ }.get (str (text ), 'border-norecord' )
508519
509520@register .filter
510521def capfirst_allcaps (text ):
0 commit comments