public override void ExitAssignedAttr(HTMLParser.AssignedAttrContext ctx) { var attrNameCtx = ctx.htmlAttributeName(); if (attrNameCtx == null) { return; } var attrValueCtx = ctx.htmlAttributeValue(); if (attrValueCtx == null) { return; } var attrNameText = MyTreeProperty.Get(attrNameCtx); if (string.IsNullOrEmpty(attrNameText)) { return; } var attrValueText = MyTreeProperty.Get(attrValueCtx); if (string.IsNullOrEmpty(attrValueText)) { return; } //TODO swap attributes name & values here if (attrValueText.Length <= 2) { FilteredPut(ctx, attrNameText + "=" + attrValueText); } else { var openQuot = attrValueText.Substring(0, 1); var closeQuot = attrValueText.Substring(attrValueText.Length - 1, 1); var attrInnerValue = attrValueText.Substring(1, attrValueText.Length - 2); FilteredPut(ctx, attrNameText + "=" + openQuot + attrInnerValue + closeQuot); } }
/// <summary> /// Exit a parse tree produced by the <c>assignedAttr</c> /// labeled alternative in <see cref="HTMLParser.htmlAttribute"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitAssignedAttr([NotNull] HTMLParser.AssignedAttrContext context) { }