Esempio n. 1
0
  private void Parse_capt(Gfh_tag_rdr tag_rdr, Gfh_tag anch_head) {
    this.capt_bgn = anch_head.Src_end(); // capt starts after <a>
    Gfh_tag anch_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__a); // </a>
    this.capt_end = anch_tail.Src_bgn(); // get capt between "<a>" and "</a>
    this.src_end = anch_tail.Src_end();

    // skip ns in href / capt
    if (href_ns_id != Xow_ns_.Tid__main) { // not main; try to remove template name;		
      int capt_bgn_wo_ns = capt_bgn + href_ns_name_len;
      href_bgn +=
          href_ns_name_len; // skip ns_name for href; EX: "Help:A" -> "A"; "Help" will be saved as
      // encoded number
      if (Bry_.Match(
          capt_src,
          capt_bgn,
          capt_bgn_wo_ns,
          href_ns_name)) { // capt matches ns_name; EX: <a href='/wiki/Help:A'>Help:A</a> ->
        // "Help:A" matches "Help:"
        capt_bgn = capt_bgn_wo_ns; // skip ns; "Help:"
        capt_has_ns = true;
      }
    }

    // get text splits
    this.text_tid =
        href_itm.Tid() == Xoh_anch_href_data.Tid__anch
            ? Xoh_anch_capt_itm.Tid__diff
            : capt_itm.Parse(
                rdr, capt_has_ns, href_src, href_bgn, href_end, src, capt_bgn, capt_end);
    int split_pos = capt_itm.Split_pos();
    this.text_0_src = href_src;
    this.text_0_bgn = href_bgn;
    this.text_0_end = href_end;
    this.text_1_src = capt_src;
    this.text_1_bgn = capt_bgn;
    this.text_1_end = capt_end;
    switch (text_tid) {
      case Xoh_anch_capt_itm.Tid__same:
        // case Xoh_anch_capt_itm.Tid__href_pipe:
      case Xoh_anch_capt_itm.Tid__diff: // nothing to do; href / capt already set above
        break;
      case Xoh_anch_capt_itm.Tid__more:
        this.text_1_bgn = split_pos;
        break;
      case Xoh_anch_capt_itm.Tid__less:
        this.text_0_end = split_pos;
        this.text_1_src = href_src;
        this.text_1_bgn = split_pos;
        this.text_1_end = href_end;
        break;
    }
  }
Esempio n. 2
0
 private void Parse_href(Xoh_hdoc_ctx hctx, Gfh_tag anch_head) {
   href_itm.Parse(rdr.Err_wkr(), hctx, src, anch_head);
   this.href_bgn = href_itm.Ttl_bgn();
   this.href_end = href_itm.Ttl_end();
   switch (href_itm.Tid()) {
     case Xoh_anch_href_data.Tid__wiki:
     case Xoh_anch_href_data.Tid__site:
       this.href_ns_id = href_itm.Ttl_ns_id();
       this.href_src = href_itm.Ttl_full_txt();
       this.href_bgn = 0;
       this.href_end = href_src.length;
       if (href_ns_id != Xow_ns_.Tid__main) { // not main; try to remove template name;		
         int colon_pos = Bry_find_.Find_fwd(href_src, Byte_ascii.Colon, href_bgn, href_end);
         this.href_ns_name =
             Xoa_ttl.Replace_unders(
                 Bry_.Mid(href_src, href_bgn, colon_pos + 1)); // EX: 11="Template talk:"
         this.href_ns_name_len = href_ns_name.length;
       }
       break;
   }
 }