/// <summary> /// Checks whether it is possible to remove the attribute quotes /// </summary> /// <param name="tagFlags">HTML tag flags</param> /// <param name="attributeValue">Attribute value</param> /// <param name="attributeQuotesRemovalMode">Removal mode of HTML attribute quotes</param> /// <returns>Result of check (true - can remove; false - cannot remove)</returns> private static bool CanRemoveAttributeQuotes(HtmlTagFlags tagFlags, string attributeValue, HtmlAttributeQuotesRemovalMode attributeQuotesRemovalMode) { bool result = false; if (!tagFlags.Xml && attributeQuotesRemovalMode != HtmlAttributeQuotesRemovalMode.KeepQuotes) { if (!attributeValue.EndsWith("/")) { if (attributeQuotesRemovalMode == HtmlAttributeQuotesRemovalMode.Html4) { result = _html4AttributeValueNotRequireQuotesRegex.IsMatch(attributeValue); } else if (attributeQuotesRemovalMode == HtmlAttributeQuotesRemovalMode.Html5) { result = _html5AttributeValueNotRequireQuotesRegex.IsMatch(attributeValue); } } } return result; }
/// <summary> /// Checks whether it is possible to remove the attribute quotes /// </summary> /// <param name="attribute">Attribute</param> /// <param name="attributeQuotesRemovalMode">Removal mode of HTML attribute quotes</param> /// <returns>Result of check (true - can remove; false - cannot remove)</returns> private static bool CanRemoveAttributeQuotes(HtmlAttribute attribute, HtmlAttributeQuotesRemovalMode attributeQuotesRemovalMode) { string attributeValue = attribute.Value; bool result = false; if (attributeQuotesRemovalMode != HtmlAttributeQuotesRemovalMode.KeepQuotes) { if (!attributeValue.EndsWith("/")) { if (attributeQuotesRemovalMode == HtmlAttributeQuotesRemovalMode.Html4) { result = _html4AttributeValueNotRequireQuotesRegex.IsMatch(attributeValue); } else if (attributeQuotesRemovalMode == HtmlAttributeQuotesRemovalMode.Html5) { result = CommonRegExps.Html5AttributeValueNotRequireQuotes.IsMatch(attributeValue); } } } return result; }