コード例 #1
0
        public virtual void Check(Lexer lexer, Node node)
        {
            AttVal attval;
            Attribute attribute;
            bool hasAlt = false;
            bool hasHref = false;

            node.CheckUniqueAttributes(lexer);

            for (attval = node.Attributes; attval != null; attval = attval.Next)
            {
                attribute = attval.CheckAttribute(lexer, node);

                if (attribute == AttributeTable.AttrAlt)
                {
                    hasAlt = true;
                }
                else if (attribute == AttributeTable.AttrHref)
                {
                    hasHref = true;
                }
            }

            if (!hasAlt)
            {
                lexer.badAccess |= Report.MISSING_LINK_ALT;
                Report.AttrError(lexer, node, "alt", Report.MISSING_ATTRIBUTE);
            }
            if (!hasHref)
            {
                Report.AttrError(lexer, node, "href", Report.MISSING_ATTRIBUTE);
            }
        }
コード例 #2
0
        public virtual void Check(Lexer lexer, Node node)
        {
            node.CheckUniqueAttributes(lexer);

            AttVal lang = node.GetAttrByName("language");
            AttVal type = node.GetAttrByName("type");
            if (type == null)
            {
                Report.AttrError(lexer, node, "type", Report.MISSING_ATTRIBUTE);

                /* check for javascript */
                if (lang != null)
                {
                    string str = lang.Val;
                    if (str.Length > 10)
                    {
                        str = str.Substring(0, 10);
                    }

                    if ((String.Compare(str, "javascript") == 0) || (String.Compare(str, "jscript") == 0))
                    {
                        node.AddAttribute("type", "text/javascript");
                    }
                }
                else
                {
                    node.AddAttribute("type", "text/javascript");
                }
            }
        }
コード例 #3
0
        public virtual void Check(Lexer lexer, Node node)
        {
            AttVal attval;
            string val = null;

            node.CheckUniqueAttributes(lexer);

            for (attval = node.Attributes; attval != null; attval = attval.Next)
            {
                if (String.Compare(attval.Attribute, "align") == 0)
                {
                    val = attval.Val;
                    break;
                }
            }

            if (val != null)
            {
                if (String.Compare(val, "left") == 0 || String.Compare(val, "right") == 0)
                {
                    lexer.versions &= HtmlVersion.Html40Loose | HtmlVersion.Frames;
                }
                else if (String.Compare(val, "top") == 0 || String.Compare(val, "bottom") == 0)
                {
                    lexer.versions &= HtmlVersion.From32;
                }
                else
                {
                    Report.AttrError(lexer, node, val, Report.BAD_ATTRIBUTE_VALUE);
                }
            }
        }
コード例 #4
0
 public virtual void Check(Lexer lexer, Node node)
 {
     if (node.GetAttrByName("src") != null)
     {
         Report.AttrError(lexer, node, "src", Report.PROPRIETARY_ATTR_VALUE);
     }
 }
コード例 #5
0
ファイル: ValignAttrCheck.cs プロジェクト: AlfieJ/TidyNet
        public virtual void Check(Lexer lexer, Node node, AttVal attval)
        {
            string val = attval.Val;

            if (val == null)
            {
                Report.AttrError(lexer, node, attval.Attribute, Report.MISSING_ATTR_VALUE);
            }
            else if (String.Compare(val, "top") == 0 || String.Compare(val, "middle") == 0 || String.Compare(val, "bottom") == 0 || String.Compare(val, "baseline") == 0)
            {
                /* all is fine */
            }
            else if (String.Compare(val, "left") == 0 || String.Compare(val, "right") == 0)
            {
                if (!(node.Tag != null && ((node.Tag.Model & ContentModel.Img) != 0)))
                {
                    Report.AttrError(lexer, node, val, Report.BAD_ATTRIBUTE_VALUE);
                }
            }
            else if (String.Compare(val, "texttop") == 0 || String.Compare(val, "absmiddle") == 0 || String.Compare(val, "absbottom") == 0 || String.Compare(val, "textbottom") == 0)
            {
                lexer.versions &= HtmlVersion.Proprietary;
                Report.AttrError(lexer, node, val, Report.PROPRIETARY_ATTR_VALUE);
            }
            else
            {
                Report.AttrError(lexer, node, val, Report.BAD_ATTRIBUTE_VALUE);
            }
        }
コード例 #6
0
ファイル: TidyMessage.cs プロジェクト: AlfieJ/TidyNet
 internal TidyMessage(Lexer lexer, string message, MessageLevel level)
 {
     _filename = String.Empty;
     _line = lexer.lines;
     _column = lexer.columns;
     _message = message;
     _level = level;
 }
コード例 #7
0
ファイル: UrlAttrCheck.cs プロジェクト: AlfieJ/TidyNet
 public virtual void Check(Lexer lexer, Node node, AttVal attval)
 {
     if (attval.Val == null)
     {
         Report.AttrError(lexer, node, attval.Attribute, Report.MISSING_ATTR_VALUE);
     }
     else if (lexer.Options.FixBackslash)
     {
         attval.Val = attval.Val.Replace('\\', '/');
     }
 }
コード例 #8
0
        public virtual void Check(Lexer lexer, Node node)
        {
            node.CheckUniqueAttributes(lexer);

            /*
                HTML4 strict doesn't allow mixed content for
                elements with %block; as their content model
                */
            if (node.GetAttrByName("width") != null || node.GetAttrByName("height") != null)
            {
                lexer.versions &= ~ HtmlVersion.Html40Strict;
            }
        }
コード例 #9
0
        public virtual void Check(Lexer lexer, Node node)
        {
            AttVal type = node.GetAttrByName("type");

            node.CheckUniqueAttributes(lexer);

            if (type == null)
            {
                Report.AttrError(lexer, node, "type", Report.MISSING_ATTRIBUTE);

                node.AddAttribute("type", "text/css");
            }
        }
コード例 #10
0
        public virtual void Check(Lexer lexer, Node node)
        {
            AttVal attval;

            node.CheckUniqueAttributes(lexer);

            for (attval = node.Attributes; attval != null; attval = attval.Next)
            {
                Attribute attribute = attval.CheckAttribute(lexer, node);
                if (attribute == AttributeTable.AttrXmlns)
                {
                    lexer.isvoyager = true;
                }
            }
        }
コード例 #11
0
        public virtual void Check(Lexer lexer, Node node)
        {
            AttVal rel = node.GetAttrByName("rel");

            node.CheckUniqueAttributes(lexer);

            if (rel != null && rel.Val != null && rel.Val.Equals("stylesheet"))
            {
                AttVal type = node.GetAttrByName("type");

                if (type == null)
                {
                    Report.AttrError(lexer, node, "type", Report.MISSING_ATTRIBUTE);

                    node.AddAttribute("type", "text/css");
                }
            }
        }
コード例 #12
0
        public virtual void Check(Lexer lexer, Node node, AttVal attval)
        {
            string val;

            /* IMG, OBJECT, APPLET and EMBED use align for vertical position */
            if (node.Tag != null && ((node.Tag.Model & ContentModel.Img) != 0))
            {
                TidyNet.AttrCheckImpl.CheckValign.Check(lexer, node, attval);
                return;
            }

            val = attval.Val;

            if (val == null)
            {
                Report.AttrError(lexer, node, attval.Attribute, Report.MISSING_ATTR_VALUE);
            }
            else if (!(String.Compare(val, "left") == 0 || String.Compare(val, "center") == 0 || String.Compare(val, "right") == 0 || String.Compare(val, "justify") == 0))
            {
                Report.AttrError(lexer, node, attval.Val, Report.BAD_ATTRIBUTE_VALUE);
            }
        }
コード例 #13
0
        public virtual void Check(Lexer lexer, Node node)
        {
            AttVal attval;
            Attribute attribute;
            bool hasSummary = false;

            node.CheckUniqueAttributes(lexer);

            for (attval = node.Attributes; attval != null; attval = attval.Next)
            {
                attribute = attval.CheckAttribute(lexer, node);

                if (attribute == AttributeTable.AttrSummary)
                {
                    hasSummary = true;
                }
            }

            /* suppress warning for missing summary for HTML 2.0 and HTML 3.2 */
            if (!hasSummary && lexer.doctype != HtmlVersion.Html20 && lexer.doctype != HtmlVersion.Html32)
            {
                lexer.badAccess |= Report.MISSING_SUMMARY;
                Report.AttrError(lexer, node, "summary", Report.MISSING_ATTRIBUTE);
            }

            /* convert <table border> to <table border="1"> */
            if (lexer.Options.XmlOut)
            {
                attval = node.GetAttrByName("border");
                if (attval != null)
                {
                    if (attval.Val == null)
                    {
                        attval.Val = "1";
                    }
                }
            }
        }
コード例 #14
0
ファイル: Report.cs プロジェクト: bgarrels/betterpoeditor
 public static void MissingBody(Lexer lexer)
 {
     AddMessage(lexer, GetMessage("missing_body"), MessageLevel.Info);
 }
コード例 #15
0
ファイル: Report.cs プロジェクト: bgarrels/betterpoeditor
        public static void ErrorSummary(Lexer lexer)
        {
            /* adjust badAccess to that its null if frames are ok */
            if ((lexer.badAccess & (USING_FRAMES | USING_NOFRAMES)) != 0)
            {
                if (!(((lexer.badAccess & USING_FRAMES) != 0) && ((lexer.badAccess & USING_NOFRAMES) == 0)))
                {
                    lexer.badAccess &= ~(USING_FRAMES | USING_NOFRAMES);
                }
            }

            if (lexer.badChars != 0)
            {
                if ((lexer.badChars & WINDOWS_CHARS) != 0)
                {
                    AddMessage(lexer, GetMessage("badchars_summary"), MessageLevel.Info);
                }
            }

            if (lexer.badForm != 0)
            {
                AddMessage(lexer, GetMessage("badform_summary"), MessageLevel.Info);
            }

            if (lexer.badAccess != 0)
            {
                if ((lexer.badAccess & MISSING_SUMMARY) != 0)
                {
                    AddMessage(lexer, GetMessage("badaccess_missing_summary"), MessageLevel.Info);
                }

                if ((lexer.badAccess & MISSING_IMAGE_ALT) != 0)
                {
                    AddMessage(lexer, GetMessage("badaccess_missing_image_alt"), MessageLevel.Info);
                }

                if ((lexer.badAccess & MISSING_IMAGE_MAP) != 0)
                {
                    AddMessage(lexer, GetMessage("badaccess_missing_image_map"), MessageLevel.Info);
                }

                if ((lexer.badAccess & MISSING_LINK_ALT) != 0)
                {
                    AddMessage(lexer, GetMessage("badaccess_missing_link_alt"), MessageLevel.Info);
                }

                if (((lexer.badAccess & USING_FRAMES) != 0) && ((lexer.badAccess & USING_NOFRAMES) == 0))
                {
                    AddMessage(lexer, GetMessage("badaccess_frames"), MessageLevel.Info);
                }

                TidyMessage msg2 = new TidyMessage(lexer, String.Format(GetMessage("badaccess_summary"), ACCESS_URL), MessageLevel.Info);
                lexer.messages.Add(msg2);
            }

            if (lexer.badLayout != 0)
            {
                if ((lexer.badLayout & USING_LAYER) != 0)
                {
                    AddMessage(lexer, GetMessage("badlayout_using_layer"), MessageLevel.Info);
                }

                if ((lexer.badLayout & USING_SPACER) != 0)
                {
                    AddMessage(lexer, GetMessage("badlayout_using_spacer"), MessageLevel.Info);
                }

                if ((lexer.badLayout & USING_FONT) != 0)
                {
                    AddMessage(lexer, GetMessage("badlayout_using_font"), MessageLevel.Info);
                }

                if ((lexer.badLayout & USING_NOBR) != 0)
                {
                    AddMessage(lexer, GetMessage("badlayout_using_nobr"), MessageLevel.Info);
                }

                if ((lexer.badLayout & USING_BODY) != 0)
                {
                    AddMessage(lexer, GetMessage("badlayout_using_body"), MessageLevel.Info);
                }
            }
        }
コード例 #16
0
ファイル: Report.cs プロジェクト: bgarrels/betterpoeditor
        public static void Error(Lexer lexer, Node element, Node node, short code)
        {
            /* keep quiet after 6 errors */
            if (lexer.messages.Errors > 6)
            {
                return;
            }

            if (code == SUSPECTED_MISSING_QUOTE)
            {
                AddMessage(lexer, GetMessage("suspected_missing_quote"), MessageLevel.Error);
            }
            else if (code == DUPLICATE_FRAMESET)
            {
                AddMessage(lexer, GetMessage("duplicate_frameset"), MessageLevel.Error);
            }
            else if (code == UNKNOWN_ELEMENT)
            {
                AddMessage(lexer, String.Format(GetMessage("unknown_element"), Tag(lexer, node)), MessageLevel.Error);
            }
            else if (code == UNEXPECTED_ENDTAG)
            {
                string message;
                if (element != null)
                {
                    message = String.Format(GetMessage("unexpected_endtag_suffix"), element.Element);
                }
                else
                {
                    message = String.Format(GetMessage("unexpected_endtag"), node.Element, element.Element);
                }

                AddMessage(lexer, message, MessageLevel.Error);
            }
        }
コード例 #17
0
ファイル: Report.cs プロジェクト: bgarrels/betterpoeditor
 public static void EntityError(Lexer lexer, short code, string entity, int c)
 {
     if (code == MISSING_SEMICOLON)
     {
         AddMessage(lexer, String.Format(GetMessage("missing_semicolon"), entity), MessageLevel.Warning);
     }
     else if (code == UNKNOWN_ENTITY)
     {
         AddMessage(lexer, String.Format(GetMessage("unknown_entity"), entity), MessageLevel.Warning);
     }
     else if (code == UNESCAPED_AMPERSAND)
     {
         AddMessage(lexer, GetMessage("unescaped_ampersand"), MessageLevel.Warning);
     }
 }
コード例 #18
0
ファイル: Report.cs プロジェクト: bgarrels/betterpoeditor
 public static void EncodingError(Lexer lexer, short code, int c)
 {
     if (code == WINDOWS_CHARS)
     {
         lexer.badChars |= WINDOWS_CHARS;
         AddMessage(lexer, String.Format(GetMessage("illegal_char"), c), MessageLevel.Warning);
     }
 }
コード例 #19
0
ファイル: Report.cs プロジェクト: bgarrels/betterpoeditor
 public static void BadTree(Lexer lexer)
 {
     throw new InvalidOperationException(GetMessage("bad_tree"));
 }
コード例 #20
0
ファイル: Report.cs プロジェクト: bgarrels/betterpoeditor
        public static void AttrError(Lexer lexer, Node node, string attr, short code)
        {
            /* keep quiet after 6 errors */
            if (lexer.messages.Errors > 6)
            {
                return;
            }

            /* on end of file adjust reported position to end of input */
            if (code == UNEXPECTED_END_OF_FILE)
            {
                lexer.lines = lexer.input.curline;
                lexer.columns = lexer.input.curcol;
            }

            if (code == UNKNOWN_ATTRIBUTE)
            {
                AddMessage(lexer, String.Format(GetMessage("unknown_attribute"), attr), MessageLevel.Warning);
            }
            else if (code == MISSING_ATTRIBUTE)
            {
                AddMessage(lexer, String.Format(GetMessage("missing_attribute"), Tag(lexer, node), attr), MessageLevel.Warning);
            }
            else if (code == MISSING_ATTR_VALUE)
            {
                AddMessage(lexer, String.Format(GetMessage("missing_attr_value"), Tag(lexer, node), attr), MessageLevel.Warning);
            }
            else if (code == MISSING_IMAGEMAP)
            {
                AddMessage(lexer, String.Format(GetMessage("missing_imagemap"), Tag(lexer, node)), MessageLevel.Warning);

                lexer.badAccess |= MISSING_IMAGE_MAP;
            }
            else if (code == BAD_ATTRIBUTE_VALUE)
            {
                AddMessage(lexer, String.Format(GetMessage("bad_attribute_value"), Tag(lexer, node), attr), MessageLevel.Warning);
            }
            else if (code == XML_ATTRIBUTE_VALUE)
            {
                AddMessage(lexer, String.Format(GetMessage("xml_attribute_value"), Tag(lexer, node), attr), MessageLevel.Warning);
            }
            else if (code == UNEXPECTED_GT)
            {
                AddMessage(lexer, String.Format(GetMessage("unexpected_gt"), Tag(lexer, node)), MessageLevel.Error);
            }
            else if (code == UNEXPECTED_QUOTEMARK)
            {
                AddMessage(lexer, String.Format(GetMessage("unexpected_quotemark"), Tag(lexer, node)), MessageLevel.Warning);
            }
            else if (code == REPEATED_ATTRIBUTE)
            {
                AddMessage(lexer, String.Format(GetMessage("repeated_attribute"), Tag(lexer, node)), MessageLevel.Warning);
            }
            else if (code == PROPRIETARY_ATTR_VALUE)
            {
                AddMessage(lexer, String.Format(GetMessage("proprietary_attr_value"), Tag(lexer, node), attr), MessageLevel.Warning);
            }
            else if (code == UNEXPECTED_END_OF_FILE)
            {
                AddMessage(lexer, GetMessage("unexpected_end_of_file"), MessageLevel.Error);
            }
            else if (code == ID_NAME_MISMATCH)
            {
                AddMessage(lexer, String.Format(GetMessage("id_name_mismatch"), Tag(lexer, node)), MessageLevel.Warning);
            }

            if (code == UNEXPECTED_GT)
            {
                AddMessage(lexer, String.Format(GetMessage("unexpected_gt"), Tag(lexer, node)), MessageLevel.Error);
            }
        }
コード例 #21
0
ファイル: Report.cs プロジェクト: bgarrels/betterpoeditor
 public static void AddMessage(Lexer lexer, string message, MessageLevel level)
 {
     lexer.messages.Add(new TidyMessage(lexer, message, level));
 }
コード例 #22
0
ファイル: Report.cs プロジェクト: bgarrels/betterpoeditor
        public static void Warning(Lexer lexer, Node element, Node node, short code)
        {
            TagTable tt = lexer.Options.tt;

            /* keep quiet after 6 errors */
            if (lexer.messages.Errors > 6)
            {
                return;
            }

            /* on end of file adjust reported position to end of input */
            if (code == UNEXPECTED_END_OF_FILE)
            {
                lexer.lines = lexer.input.curline;
                lexer.columns = lexer.input.curcol;
            }

            if (code == MISSING_ENDTAG_FOR)
            {
                AddMessage(lexer, String.Format(GetMessage("missing_endtag_for"), element.Element), MessageLevel.Warning);
            }
            else if (code == MISSING_ENDTAG_BEFORE)
            {
                AddMessage(lexer, String.Format(GetMessage("missing_endtag_before"), element.Element, Tag(lexer, node)), MessageLevel.Warning);
            }
            else if (code == DISCARDING_UNEXPECTED)
            {
                AddMessage(lexer, String.Format(GetMessage("discarding_unexpected"), Tag(lexer, node)), MessageLevel.Warning);
            }
            else if (code == NESTED_EMPHASIS)
            {
                AddMessage(lexer, String.Format(GetMessage("nested_emphasis"), Tag(lexer, node)), MessageLevel.Warning);
            }
            else if (code == COERCE_TO_ENDTAG)
            {
                AddMessage(lexer, String.Format(GetMessage("coerce_to_endtag"), element.Element), MessageLevel.Warning);
            }
            else if (code == NON_MATCHING_ENDTAG)
            {
                AddMessage(lexer, String.Format(GetMessage("non_matching_endtag_1"), Tag(lexer, node), element.Element), MessageLevel.Warning);
            }
            else if (code == TAG_NOT_ALLOWED_IN)
            {
                AddMessage(lexer, String.Format(GetMessage("tag_not_allowed_in"), Tag(lexer, node), element.Element), MessageLevel.Warning);
            }
            else if (code == DOCTYPE_AFTER_TAGS)
            {
                AddMessage(lexer, GetMessage("doctype_after_tags"), MessageLevel.Warning);
            }
            else if (code == MISSING_STARTTAG)
            {
                AddMessage(lexer, String.Format(GetMessage("missing_starttag"), node.Element), MessageLevel.Warning);
            }
            else if (code == UNEXPECTED_ENDTAG)
            {
                string message;
                if (element != null)
                {
                    message = String.Format(GetMessage("unexpected_endtag_suffix"), node.Element, element.Element);
                }
                else
                {
                    message = String.Format(GetMessage("unexpected_endtag"), node.Element);
                }

                AddMessage(lexer, message, MessageLevel.Warning);
            }
            else if (code == TOO_MANY_ELEMENTS)
            {
                string message;
                if (element != null)
                {
                    message = String.Format(GetMessage("too_many_elements_suffix"), node.Element, element.Element);
                }
                else
                {
                    message = String.Format(GetMessage("too_many_elements"), node.Element);
                }

                AddMessage(lexer, message, MessageLevel.Warning);
            }
            else if (code == USING_BR_INPLACE_OF)
            {
                AddMessage(lexer, GetMessage("using_br_inplace_of") + Tag(lexer, node), MessageLevel.Warning);
            }
            else if (code == INSERTING_TAG)
            {
                AddMessage(lexer, String.Format(GetMessage("inserting_tag"), node.Element), MessageLevel.Warning);
            }
            else if (code == CANT_BE_NESTED)
            {
                AddMessage(lexer, String.Format(GetMessage("cant_be_nested"), Tag(lexer, node)), MessageLevel.Warning);
            }
            else if (code == PROPRIETARY_ELEMENT)
            {
                AddMessage(lexer, String.Format(GetMessage("proprietary_element"), Tag(lexer, node)), MessageLevel.Warning);

                if (node.Tag == tt.TagLayer)
                {
                    lexer.badLayout |= USING_LAYER;
                }
                else if (node.Tag == tt.TagSpacer)
                {
                    lexer.badLayout |= USING_SPACER;
                }
                else if (node.Tag == tt.TagNobr)
                {
                    lexer.badLayout |= USING_NOBR;
                }
            }
            else if (code == OBSOLETE_ELEMENT)
            {
                string message;
                if (element.Tag != null && (element.Tag.Model & ContentModel.Obsolete) != 0)
                {
                    message = String.Format(GetMessage("obsolete_element"), Tag(lexer, node), Tag(lexer, node));
                }
                else
                {
                    message = String.Format(GetMessage("replacing_element"), Tag(lexer, node), Tag(lexer, node));
                }

                AddMessage(lexer, message, MessageLevel.Warning);
            }
            else if (code == TRIM_EMPTY_ELEMENT)
            {
                AddMessage(lexer, String.Format(GetMessage("trim_empty_element"), Tag(lexer, node)), MessageLevel.Warning);
            }
            else if (code == MISSING_TITLE_ELEMENT)
            {
                AddMessage(lexer, GetMessage("missing_title_element"), MessageLevel.Warning);
            }
            else if (code == ILLEGAL_NESTING)
            {
                AddMessage(lexer, String.Format(GetMessage("illegal_nesting"), Tag(lexer, node)), MessageLevel.Warning);
            }
            else if (code == NOFRAMES_CONTENT)
            {
                AddMessage(lexer, String.Format(GetMessage("noframes_content"), Tag(lexer, node)), MessageLevel.Warning);
            }
            else if (code == INCONSISTENT_VERSION)
            {
                AddMessage(lexer, GetMessage("inconsistent_version"), MessageLevel.Warning);
            }
            else if (code == MALFORMED_DOCTYPE)
            {
                AddMessage(lexer, GetMessage("malformed_doctype"), MessageLevel.Warning);
            }
            else if (code == CONTENT_AFTER_BODY)
            {
                AddMessage(lexer, GetMessage("content_after_body"), MessageLevel.Warning);
            }
            else if (code == MALFORMED_COMMENT)
            {
                AddMessage(lexer, GetMessage("malformed_comment"), MessageLevel.Warning);
            }
            else if (code == BAD_COMMENT_CHARS)
            {
                AddMessage(lexer, GetMessage("bad_comment_chars"), MessageLevel.Warning);
            }
            else if (code == BAD_XML_COMMENT)
            {
                AddMessage(lexer, GetMessage("bad_xml_comment"), MessageLevel.Warning);
            }
            else if (code == BAD_CDATA_CONTENT)
            {
                AddMessage(lexer, GetMessage("bad_cdata_content"), MessageLevel.Warning);
            }
            else if (code == INCONSISTENT_NAMESPACE)
            {
                AddMessage(lexer, GetMessage("inconsistent_namespace"), MessageLevel.Warning);
            }
            else if (code == DTYPE_NOT_UPPER_CASE)
            {
                AddMessage(lexer, GetMessage("dtype_not_upper_case"), MessageLevel.Warning);
            }
            else if (code == UNEXPECTED_END_OF_FILE)
            {
                AddMessage(lexer, GetMessage("unexpected_end_of_file") + Tag(lexer, node), MessageLevel.Warning);
            }
        }
コード例 #23
0
ファイル: Report.cs プロジェクト: bgarrels/betterpoeditor
 public static void ReportNumWarnings(Lexer lexer)
 {
     if ((lexer.messages.Warnings > 0) && (lexer.messages.Errors > 0))
     {
         lexer.messages.Add(new TidyMessage(lexer, String.Format(GetMessage("num_warnings_errors"), lexer.messages.Warnings, lexer.messages.Errors), MessageLevel.Info));
     }
     else if (lexer.messages.Errors > 0)
     {
         lexer.messages.Add(new TidyMessage(lexer, String.Format(GetMessage("num_errors"), lexer.messages.Errors), MessageLevel.Info));
     }
     else if (lexer.messages.Warnings > 0)
     {
         lexer.messages.Add(new TidyMessage(lexer, String.Format(GetMessage("num_warnings"), lexer.messages.Warnings), MessageLevel.Info));
     }
     else
     {
         lexer.messages.Add(new TidyMessage(lexer, GetMessage("no_warnings"), MessageLevel.Info));
     }
 }
コード例 #24
0
ファイル: Report.cs プロジェクト: bgarrels/betterpoeditor
 public static void NeedsAuthorIntervention(Lexer lexer)
 {
     AddMessage(lexer, GetMessage("needs_author_intervention"), MessageLevel.Info);
 }
コード例 #25
0
ファイル: Report.cs プロジェクト: bgarrels/betterpoeditor
 public static void ReportNumberOfSlides(Lexer lexer, int count)
 {
     AddMessage(lexer, String.Format(GetMessage("slides_found"), count), MessageLevel.Info);
 }
コード例 #26
0
ファイル: Clean.cs プロジェクト: AlfieJ/TidyNet
        /*
        Applies all matching rules to a node.
        */
        private Node CleanNode(Lexer lexer, Node node)
        {
            Node next = null;
            MutableObject o = new MutableObject();
            bool b = false;

            for (next = node; node.IsElement; node = next)
            {
                o.Object = next;

                b = Dir2Div(lexer, node, o);
                next = (Node) o.Object;
                if (b)
                {
                    continue;
                }

                b = NestedList(lexer, node, o);
                next = (Node) o.Object;
                if (b)
                {
                    continue;
                }

                b = Center2Div(lexer, node, o);
                next = (Node) o.Object;
                if (b)
                {
                    continue;
                }

                b = MergeDivs(lexer, node, o);
                next = (Node) o.Object;
                if (b)
                {
                    continue;
                }

                b = BlockStyle(lexer, node, o);
                next = (Node) o.Object;
                if (b)
                {
                    continue;
                }

                b = InlineStyle(lexer, node, o);
                next = (Node) o.Object;
                if (b)
                {
                    continue;
                }

                b = Font2Span(lexer, node, o);
                next = (Node) o.Object;
                if (b)
                {
                    continue;
                }

                break;
            }

            return next;
        }
コード例 #27
0
ファイル: Report.cs プロジェクト: bgarrels/betterpoeditor
        public static void ReportVersion(Lexer lexer, Node doctype)
        {
            int i, c;
            int state = 0;
            string vers = lexer.HtmlVersionName();
            MutableInteger cc = new MutableInteger();
            StringBuilder message = new StringBuilder();

            if (doctype != null)
            {
                StringBuilder docTypeStr = new StringBuilder();

                for (i = doctype.Start; i < doctype.End; ++i)
                {
                    c = (int) doctype.Textarray[i];

                    /* look for UTF-8 multibyte character */
                    if (c < 0)
                    {
                        i += PPrint.GetUTF8(doctype.Textarray, i, cc);
                        c = cc.Val;
                    }

                    if (c == (char) '"')
                    {
                        ++state;
                    }
                    else if (state == 1)
                    {
                        docTypeStr.Append((char)c);
                    }
                }

                lexer.messages.Add(new TidyMessage(lexer, String.Format(GetMessage("doctype_given"), docTypeStr), MessageLevel.Info));
            }

            lexer.messages.Add(new TidyMessage(lexer, String.Format(GetMessage("report_version"), (vers != null ? vers : "HTML proprietary")), MessageLevel.Info));
        }
コード例 #28
0
ファイル: AttVal.cs プロジェクト: bgarrels/betterpoeditor
        /* ignore unknown attributes for proprietary elements */
        public virtual Attribute CheckAttribute(Lexer lexer, Node node)
        {
            TagTable tt = lexer.Options.tt;

            if (Asp == null && Php == null)
            {
                CheckUniqueAttribute(lexer, node);
            }

            Attribute attribute = Dict;
            if (attribute != null)
            {
                /* title is vers 2.0 for A and LINK otherwise vers 4.0 */
                if (attribute == AttributeTable.AttrTitle && (node.Tag == tt.TagA || node.Tag == tt.TagLink))
                {
                    lexer.versions &= HtmlVersion.All;
                }
                else if ((attribute.Versions & HtmlVersion.Xml) != 0)
                {
                    if (!(lexer.Options.XmlTags || lexer.Options.XmlOut))
                    {
                        Report.AttrError(lexer, node, Attribute, Report.XML_ATTRIBUTE_VALUE);
                    }
                }
                else
                {
                    lexer.versions &= attribute.Versions;
                }

                if (attribute.AttrCheck != null)
                {
                    attribute.AttrCheck.Check(lexer, node, this);
                }
            }
            else if (!lexer.Options.XmlTags && !(node.Tag == null) && _asp == null && !(node.Tag != null && ((node.Tag.Versions & HtmlVersion.Proprietary) != HtmlVersion.Unknown)))
            {
                Report.AttrError(lexer, node, Attribute, Report.UNKNOWN_ATTRIBUTE);
            }

            return attribute;
        }
コード例 #29
0
ファイル: Report.cs プロジェクト: bgarrels/betterpoeditor
 private static string Tag(Lexer lexer, Node tag)
 {
     if (tag != null)
     {
         if (tag.Type == Node.StartTag)
         {
             return "<" + tag.Element + ">";
         }
         else if (tag.Type == Node.EndTag)
         {
             return "</" + tag.Element + ">";
         }
         else if (tag.Type == Node.DocTypeTag)
         {
             return "<!DOCTYPE>";
         }
         else if (tag.Type == Node.TextNode)
         {
             return "plain text";
         }
         else
         {
             return tag.Element;
         }
     }
     else
     {
         return String.Empty;
     }
 }
コード例 #30
0
ファイル: AttVal.cs プロジェクト: bgarrels/betterpoeditor
        /*
        the same attribute name can't be used
        more than once in each element
        */
        public virtual void CheckUniqueAttribute(Lexer lexer, Node node)
        {
            AttVal attr;
            int count = 0;

            for (attr = Next; attr != null; attr = attr.Next)
            {
                if (Attribute != null && attr.Attribute != null && attr.Asp == null && attr.Php == null && String.Compare(Attribute, attr.Attribute) == 0)
                {
                    ++count;
                }
            }

            if (count > 0)
            {
                Report.AttrError(lexer, node, Attribute, Report.REPEATED_ATTRIBUTE);
            }
        }