public void Xtn_parse(
     Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
   Xox_xnde_.Xatr__set(wiki, this, xatrs_hash, src, xnde);
   this.html =
       Xop_parser_.Parse_text_to_html(
           wiki,
           ctx,
           ctx.Page(),
           ctx.Page().Ttl(),
           Bry_.Mid(src, xnde.Tag_open_end(), xnde.Tag_close_bgn()),
           false);
   Indicator_html_bldr html_bldr = ctx.Page().Html_data().Indicators();
   if (this.name != null)
     html_bldr.Add(this); // NOTE: must do null-check b/c Add will use Name as key for hashtable
 }
 private Xop_list_tkn PopTil(
     Xop_ctx ctx,
     Xop_tkn_mkr tkn_mkr,
     Xop_root_tkn root,
     byte[] src,
     int src_len,
     int bgn_pos,
     int cur_pos,
     byte subLast) {
   int acs_pos = ctx.Stack_idx_find_but_stop_at_tbl(Xop_tkn_itm_.Tid_list);
   if (acs_pos == -1) return null;
   Xop_list_tkn rv =
       (Xop_list_tkn)
           ctx.Stack_pop_til(root, src, acs_pos, false, bgn_pos, cur_pos, Xop_tkn_itm_.Tid_list);
   MakeTkn_end(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos, rv, subLast);
   return rv;
 }
 public void MakeTkn_end(
     Xop_ctx ctx,
     Xop_tkn_mkr tkn_mkr,
     Xop_root_tkn root,
     byte[] src,
     int src_len,
     int bgn_pos,
     int cur_pos,
     Xop_list_tkn bgn,
     byte sub_last) {
   // boolean empty_ignored = ctx.Empty_ignored(); // commented; see below; DATE:2014-06-24
   Xop_tkn_itm end_tkn =
       tkn_mkr.List_end(bgn_pos, bgn.List_itmTyp())
           .List_path_(bgn.List_path())
           .List_uid_(listId)
           .List_sub_last_(sub_last);
   ctx.Subs_add(root, end_tkn);
   // if (empty_ignored) ctx.Empty_ignore(root, bgn.Tkn_sub_idx());	// commented; code was
   // incorrectly deactivating "*a" when "<li>" encountered; PAGE:en.w:Bristol_Bullfinch
   // DATE:2014-06-24
   ctx.Para().Process_block__bgn_n__end_y(Xop_xnde_tag_.Tag__ul);
 }
 public void AutoClose(
     Xop_ctx ctx,
     Xop_tkn_mkr tkn_mkr,
     Xop_root_tkn root,
     byte[] src,
     int src_len,
     int bgn_pos,
     int cur_pos,
     Xop_tkn_itm tkn) {
   // NOTE: list_tkns can not be explicitly closed, so auto-close will happen for all items
   MakeTkn_end(
       ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos, (Xop_list_tkn) tkn, Bool_.Y_byte);
   Reset(listId + 1);
   ctx.Para().Process_block__bgn_n__end_y(Xop_xnde_tag_.Tag__ul);
 }
  public int MakeTkn_bgn(
      Xop_ctx ctx,
      Xop_tkn_mkr tkn_mkr,
      Xop_root_tkn root,
      byte[] src,
      int src_len,
      int bgn_pos,
      int cur_pos) { // REF.MW: Parser|doBlockLevels
    if (bgn_pos == Xop_parser_.Doc_bgn_bos) bgn_pos = 0; // do not allow -1 pos

    // pop hdr if exists; EX: \n== a ==\n*b; \n* needs to close hdr
    int acsPos = ctx.Stack_idx_typ(Xop_tkn_itm_.Tid_hdr);
    if (acsPos != -1)
      ctx.Stack_pop_til(root, src, acsPos, true, bgn_pos, cur_pos, Xop_tkn_itm_.Tid_list);

    // close apos
    ctx.Apos().End_frame(ctx, root, src, bgn_pos, false);
    byte symByt =
        src[
            cur_pos
                - 1]; // -1 b/c symByt is byte before curByt; EX: \n*a; cur_pos is at a; want to get
    // *
    int prvSymLen = curSymLen;
    cur_pos = SymAry_fill(src, cur_pos, src_len, symByt);
    symByt =
        src[
            cur_pos
                - 1]; // NOTE: get symByt again b/c cur_pos may have changed; EX: "#*"; # may have
    // triggered list, but last symByt should be *
    if (SymAry_fill_overflow) return ctx.Lxr_make_txt_(cur_pos);
    PrvItm_compare();
    ctx.Para()
        .Process_block__bgn__nl_w_symbol(
            ctx,
            root,
            src,
            bgn_pos,
            cur_pos - 1,
            Xop_xnde_tag_
                .Tag__li); // -1 b/c cur_pos includes sym_byte; EX: \n*; pass li; should pass
    // correct tag, but for purposes of para_wkr, <li> doesn't matter
    if (prvSymMatch) {
      PopTil(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos, Bool_.N_byte);
      posBldr.MoveNext();
      prvSymAry = Xop_list_wkr_.MakeSymAry(curSymAry, curSymLen);
      Xop_list_tkn prvItm =
          tkn_mkr.List_bgn(bgn_pos, cur_pos, curSymAry[curSymLen - 1], curSymLen)
              .List_path_(posBldr.XtoIntAry())
              .List_uid_(listId);
      ctx.Subs_add_and_stack(root, prvItm);
      ctx.Empty_ignored_y_();
    } else {
      for (int i = prvSymLen; i > commonSymLen; i--) { // close all discontinued itms: EX: ##\n#\n
        PopTil(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos, Bool_.Y_byte);
        posBldr.MoveUp();
      }
      if (commonSymLen == 0 && prvSymLen != 0) { // nothing in common; reset list
        listId++;
        posBldr.Init();
      }
      if (curSymLen == commonSymLen) { // add another itm if continuing; EX: #\n#\n
        PopTil(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos, Bool_.N_byte);
        if ((prvSymLen - curSymLen)
                > 0 // moving up many levels; do not open new list; just MoveNext; EX: #1\n###3\n##2
            && curSymLen
                != 1) { // do not moveNext if at level 1; this has to do with strange incrementing
          // logic in posBldr at rootLvl
          posBldr.MoveNext();
        } else {
          posBldr.MoveUp();
          posBldr.MoveDown();
        }
        prvSymAry = Xop_list_wkr_.MakeSymAry(curSymAry, curSymLen);
        symByt = src[cur_pos - 1];
        Xop_list_tkn prvItm =
            tkn_mkr.List_bgn(bgn_pos, cur_pos, symByt, curSymLen)
                .List_path_(posBldr.XtoIntAry())
                .List_uid_(listId);
        ctx.Subs_add_and_stack(root, prvItm);
        ctx.Empty_ignored_y_();
      }
      for (int i = commonSymLen; i < curSymLen; i++) { // open new itms; EX: #\n##\n
        posBldr.MoveDown();
        symByt = curSymAry[i];
        prvSymAry = Xop_list_wkr_.MakeSymAry(curSymAry, curSymLen);
        Xop_list_tkn prvItm =
            tkn_mkr.List_bgn(bgn_pos, cur_pos, symByt, i + List_adp_.Base1)
                .List_path_(posBldr.XtoIntAry())
                .List_uid_(listId);
        ctx.Subs_add_and_stack(root, prvItm);
        ctx.Empty_ignored_y_();
      }
    }
    if (allDd
        && cur_pos < src_len - 2
        && src[cur_pos] == '{'
        && src[cur_pos + 1] == '|') // NOTE: if indent && next == {| then invoke table; EX: ":::{|"
    return ctx.Tblw()
          .Make_tkn_bgn(
              ctx,
              tkn_mkr,
              root,
              src,
              src_len,
              cur_pos,
              cur_pos + 2,
              false,
              Xop_tblw_wkr.Tblw_type_tb,
              Xop_tblw_wkr.Called_from_list,
              -1,
              -1); // NOTE: ws_enabled must be set to true; see test for Adinkras; Cato the Elder
    else {
      dd_chk = symByt == Xop_list_tkn_.List_itmTyp_dt;
      return cur_pos;
    }
  }
Beispiel #6
0
 public void Xtn_write(
     Bry_bfr bfr,
     Xoae_app app,
     Xop_ctx ctx,
     Xoh_html_wtr html_wtr,
     Xoh_wtr_ctx hctx,
     Xoae_page wpg,
     Xop_xnde_tkn xnde,
     byte[] src) {
   Xowe_wiki wiki = ctx.Wiki();
   Dpl_html_data html_mode = Dpl_html_data.new_(Dpl_itm_keys.Key_unordered);
   int itms_len = pages.Count();
   if (itms_len == 0) {
     if (!itm.Suppress_errors()) bfr.Add_str_a7("No pages meet these criteria.");
     return;
   }
   int itms_bgn = 0;
   if (itm.Offset() != Int_.Min_value) {
     itms_bgn = itm.Offset();
   }
   if (itm.Count() != Int_.Min_value && itms_bgn + itm.Count() < itms_len) {
     itms_len = itms_bgn + itm.Count();
   }
   boolean show_ns = itm.Show_ns();
   Bry_bfr tmp_bfr = Bry_bfr_.Get();
   Xop_amp_mgr amp_mgr = wiki.Appe().Parser_amp_mgr();
   try {
     bfr.Add(html_mode.Grp_bgn()).Add_byte_nl();
     for (int i = itms_bgn; i < itms_len; i++) {
       Xowd_page_itm page = (Xowd_page_itm) pages.Get_at(i);
       Xoa_ttl ttl = Xoa_ttl.Parse(wiki, page.Ns_id(), page.Ttl_page_db());
       byte[] ttl_page_txt = show_ns ? ttl.Full_txt_w_ttl_case() : ttl.Page_txt();
       if (ttl_page_txt == null)
         continue; // NOTE: apparently DynamicPageList allows null pages; DATE:2013-07-22
       switch (html_mode.Tid()) {
         case Dpl_html_data.Tid_list_ul:
         case Dpl_html_data.Tid_list_ol:
           bfr.Add(Xoh_consts.Space_2).Add(html_mode.Itm_bgn()).Add(Gfh_bldr_.Bry__a_lhs_w_href);
           bfr.Add_str_a7("/wiki/")
               .Add(Gfo_url_encoder_.Href.Encode(ttl.Full_db()))
               .Add_byte_quote(); // NOTE: Full_db to encode spaces as underscores;
                                  // PAGE:en.q:Wikiquote:Speedy_deletions DATE:2016-01-19
           Gfh_atr_.Add(
               bfr,
               Gfh_atr_.Bry__title,
               Xoh_html_wtr_escaper.Escape(
                   amp_mgr,
                   tmp_bfr,
                   ttl
                       .Full_txt_w_ttl_case())); // NOTE: Full_txt b/c title always includes ns,
                                                 // even if show_ns is off;
                                                 // PAGE:en.b:Wikibooks:WikiProject DATE:2016-01-20
           if (itm.No_follow()) bfr.Add(Bry_nofollow);
           bfr.Add_byte(Byte_ascii.Gt);
           Xoh_html_wtr_escaper.Escape(
               amp_mgr, bfr, ttl_page_txt, 0, ttl_page_txt.length, false, false);
           bfr.Add(Gfh_bldr_.Bry__a_rhs).Add(html_mode.Itm_end()).Add_byte_nl();
           // TODO_OLD:
           // lnki_wtr.Clear().Href_wiki_(ttl).Title_(ttl).Nofollow_().Write_head(bfr).Write_text(bfr).Write_tail(bfr)
           break;
         default:
           break;
       }
     }
     bfr.Add(html_mode.Grp_end()).Add_byte_nl();
   } finally {
     tmp_bfr.Mkr_rls();
   }
 }
Beispiel #7
0
 public void Xtn_parse(
     Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
   itm.Parse(wiki, ctx, ctx.Page().Ttl().Full_txt_w_ttl_case(), src, xnde);
   Dpl_page_finder.Find_pages(pages, wiki, itm);
   if (itm.Sort_ascending() != Bool_.__byte) pages.Sort_by(new Dpl_page_sorter(itm));
 }