private static @NotNull HtmlChunk.Element createHtmlSpanBlockStyledAsTextAttributes(
    @NotNull TextAttributes attributes,
    float saturationFactor
  ) {
    StringBuilder style = new StringBuilder();

    Color foregroundColor = attributes.getForegroundColor();
    Color backgroundColor = attributes.getBackgroundColor();
    Color effectTypeColor = attributes.getEffectColor();

    if (foregroundColor != null) foregroundColor = tuneSaturationEspeciallyGrey(foregroundColor, 1, saturationFactor);
    if (backgroundColor != null) backgroundColor = tuneSaturationEspeciallyGrey(backgroundColor, 1, saturationFactor);
    if (effectTypeColor != null) effectTypeColor = tuneSaturationEspeciallyGrey(effectTypeColor, 1, saturationFactor);

    if (foregroundColor != null) appendProperty(style, "color", ColorUtil.toHtmlColor(foregroundColor));
    if (backgroundColor != null) appendProperty(style, "background-color", ColorUtil.toHtmlColor(backgroundColor));

    switch (attributes.getFontType()) {
      case Font.BOLD -> appendProperty(style, "font-weight", "bold");
      case Font.ITALIC -> appendProperty(style, "font-style", "italic");
    }

    EffectType effectType = attributes.getEffectType();
    if (attributes.hasEffects() && effectType != null) {
      switch (effectType) {
        case LINE_UNDERSCORE -> appendProperty(style, "text-decoration-line", "underline");
        case WAVE_UNDERSCORE -> {
          appendProperty(style, "text-decoration-line", "underline");
          appendProperty(style, "text-decoration-style", "wavy");
        }
        case BOLD_LINE_UNDERSCORE -> {
          appendProperty(style, "text-decoration-line", "underline");
          appendProperty(style, "text-decoration-thickness", "2px");
        }
        case BOLD_DOTTED_LINE -> {
          appendProperty(style, "text-decoration-line", "underline");
          appendProperty(style, "text-decoration-thickness", "2px");
          appendProperty(style, "text-decoration-style", "dotted");
        }
        case STRIKEOUT -> appendProperty(style, "text-decoration-line", "line-through");
        case BOXED, SLIGHTLY_WIDER_BOX, SEARCH_MATCH -> appendProperty(style, "border", "1px solid");
        case ROUNDED_BOX -> {
          appendProperty(style, "border", "1px solid");
          appendProperty(style, "border-radius", "2px");
        }
      }
    }

    if (attributes.hasEffects() && effectType != null && effectTypeColor != null) {
      switch (effectType) {
        case LINE_UNDERSCORE, WAVE_UNDERSCORE, BOLD_LINE_UNDERSCORE, BOLD_DOTTED_LINE, STRIKEOUT ->
          appendProperty(style, "text-decoration-color", ColorUtil.toHtmlColor(effectTypeColor));
        case BOXED, ROUNDED_BOX, SEARCH_MATCH, SLIGHTLY_WIDER_BOX ->
          appendProperty(style, "border-color", ColorUtil.toHtmlColor(effectTypeColor));
      }
    }

    return HtmlChunk.span().style(style.toString());
  }
private static @NotNull HtmlChunk.Element createHtmlSpanBlockStyledAsTextAttributes(
    @NotNull TextAttributes attributes,
    float saturationFactor
  )