예제 #1
0
        void ProcNote(Match m, XTag tag)
        {
            string note_id = "", ref_id;

            //Link tag solve
            {
                var a = tag.GetClassNames();
                if (!Contains(a, "duokan-footnote"))
                {
                    string added = "duokan-footnote";
                    if (a.Length != 0)
                    {
                        added = " " + added;
                    }
                    tag.SetAttribute("class", tag.GetAttribute("class") + added);
                }
            }

            if (tag.GetAttribute("epub:type") != "noteref")
            {
                tag.SetAttribute("epub:type", "noteref");
            }
            {
                string href = tag.GetAttribute("href");
                int    pt   = href.IndexOf('#');
                if (pt < 0)
                {
                    Log.log("Error:Not a valid link :" + href + ""); return;
                }
                if (pt != 0)
                {
                    Log.log("Warn: href=\":" + href + "\"");
                }
                note_id = href.Substring(pt + 1);
            }

            ref_id = note_id + "_ref";
            tag.SetAttribute("id", ref_id);

            text = text.Remove(m.Index, m.Length);
            text = text.Insert(m.Index, tag.ToString());


            //Note content
            ProcNoteContent(note_id, ref_id);
        }
예제 #2
0
        void CheckFootnotes()
        {
            Regex reg_link = new Regex("<a .*?>");
            int   pos      = 0;
            Match link     = reg_link.Match(text);

            while (link.Success)
            {
                XTag tag = new XTag(link.Value);
                if (Contains(tag.GetClassNames(), "duokan-footnote") ||
                    tag.GetAttribute("epub:type") == "noteref")
                {
                    ProcNote(link, tag);
                }
                pos  = link.Index + 1;//假定注释本体都在链接后面
                link = reg_link.Match(text, pos);
            }
        }