コード例 #1
0
    @Override
    public void emit() {
      String pageName = group(1);
      String altText = group(2);
      String href =
          ((MediaWikiLanguage) getMarkupLanguage()).toInternalHref(pageName.replace(' ', '_'));

      // category references start with ':' but are not referenced that way in the text
      if (pageName.startsWith(":")) { // $NON-NLS-1$
        pageName = pageName.substring(1);
      }
      if (altText == null || altText.trim().length() == 0) {
        altText = pageName;
        if (altText.startsWith("#")) { // $NON-NLS-1$
          altText = altText.substring(1);
        }
      }
      if (pageName.startsWith("#")) { // $NON-NLS-1$
        builder.link(href, altText);
      } else {
        Attributes attributes = new LinkAttributes();
        attributes.setTitle(pageName);
        builder.link(attributes, href, altText);
      }
    }
コード例 #2
0
    @Override
    public void emit() {
      String imageUrl = createImageUrl();
      String imageOptions = group(OPTIONS_GROUP);

      final ImageAttributes attributes = new ImageAttributes();
      if (imageOptions != null) {
        Options.parseOptions(
            imageOptions,
            new Handler() {
              public void setOption(String key, String value) {
                if ("alt".equalsIgnoreCase(key)) { // $NON-NLS-1$
                  attributes.setAlt(value);
                } else if ("align".equalsIgnoreCase(key)) { // $NON-NLS-1$
                  if ("middle".equalsIgnoreCase(value)) { // $NON-NLS-1$
                    attributes.setAlign(Align.Middle);
                  } else if ("left".equalsIgnoreCase(value)) { // $NON-NLS-1$
                    attributes.setAlign(Align.Left);
                  } else if ("right".equalsIgnoreCase(value)) { // $NON-NLS-1$
                    attributes.setAlign(Align.Right);
                  } else if ("center".equalsIgnoreCase(value)) { // $NON-NLS-1$
                    attributes.setAlign(Align.Center);
                  }
                } else {
                  try {
                    if ("border".equalsIgnoreCase(key)) { // $NON-NLS-1$
                      attributes.setBorder(Integer.parseInt(value));
                    } else if ("height".equalsIgnoreCase(key)) { // $NON-NLS-1$
                      attributes.setHeight(Integer.parseInt(value));
                    } else if ("width".equalsIgnoreCase(key)) { // $NON-NLS-1$
                      attributes.setWidth(Integer.parseInt(value));
                    }
                  } catch (NumberFormatException e) {
                    // ignore
                  }
                }
              }

              public void setOption(String option) {
                // ignore
              }
            });
      }
      if (attributes.getAlign() == Align.Center) {
        // bug 293573: confluence centers images using div
        Attributes divAttributes = new Attributes();
        divAttributes.setCssStyle("text-align: center;"); // $NON-NLS-1$
        builder.beginBlock(BlockType.DIV, divAttributes);
        attributes.setAlign(null);
        builder.image(attributes, imageUrl);
        builder.endBlock();
      } else {
        builder.image(attributes, imageUrl);
      }
    }
コード例 #3
0
ファイル: Textile.java プロジェクト: RncLsn/wimmp_ms
 private static void appendStyles(Attributes attributes, String cssStyles) {
   if (cssStyles == null || cssStyles.length() == 0) {
     return;
   }
   String styles = attributes.getCssStyle();
   if (styles == null) {
     attributes.setCssStyle(cssStyles);
   } else {
     if (styles.endsWith(";")) { // $NON-NLS-1$
       styles += " "; // $NON-NLS-1$
     } else {
       styles += "; "; // $NON-NLS-1$
     }
     styles += cssStyles;
     attributes.setCssStyle(styles);
   }
 }
コード例 #4
0
ファイル: ListBlock.java プロジェクト: eclipse/mylyn.docs
 private void computeAttributes(Attributes attributes, BlockType type, String typeSpec) {
   if (type == BlockType.NUMERIC_LIST) {
     switch (typeSpec.charAt(0)) {
       case 'a':
         attributes.setCssStyle("list-style: lower-alpha;"); // $NON-NLS-1$
         break;
       case 'A':
         attributes.setCssStyle("list-style: upper-alpha;"); // $NON-NLS-1$
         break;
       case 'i':
         attributes.setCssStyle("list-style: lower-roman;"); // $NON-NLS-1$
         break;
       case 'I':
         attributes.setCssStyle("list-style: upper-roman;"); // $NON-NLS-1$
         break;
     }
   }
 }
コード例 #5
0
ファイル: Textile.java プロジェクト: RncLsn/wimmp_ms
  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;
  }