示例#1
0
  public static Attributes configureAttributes(
      org.eclipse.mylyn.wikitext.core.parser.util.Matcher matcher,
      Attributes attributes,
      int offset,
      boolean block) {
    if (offset < 1) {
      throw new IllegalArgumentException();
    }
    if (block) {
      // padding (left)
      {
        String padding = matcher.group(offset);
        if (padding != null) {
          appendStyles(
              attributes, "padding-left: " + padding.length() + "em;"); // $NON-NLS-1$ //$NON-NLS-2$
        }
        ++offset;
      }

      // padding (right)
      {
        String padding = matcher.group(offset);
        if (padding != null) {
          appendStyles(
              attributes,
              "padding-right: " + padding.length() + "em;"); // $NON-NLS-1$ //$NON-NLS-2$
        }
        ++offset;
      }

      // alignment
      {
        String alignment = matcher.group(offset);
        if (alignment != null) {
          appendStyles(attributes, alignmentToStyle.get(alignment));
        }
        ++offset;
      }
    }

    String cssClass2 = matcher.group(offset);
    String id = matcher.group(offset + 1);
    String cssStyles2 = matcher.group(offset + 2);
    String language = matcher.group(offset + 3);

    if (id != null && attributes.getId() == null) {
      attributes.setId(id);
    }

    if (attributes.getCssClass() != null || cssClass2 != null) {
      attributes.setCssClass(
          attributes.getCssClass() == null
              ? cssClass2
              : cssClass2 == null
                  ? attributes.getCssClass()
                  : attributes.getCssClass() + ' ' + cssClass2);
    }
    appendStyles(attributes, cssStyles2);

    attributes.setLanguage(language);

    return attributes;
  }