public static FencedAttributes FencedAttrsFromNode(Node node) { Nodes.Attribute attribute = null; FencedAttributes attributes = null; try { if (node.attrs == null) { return attributes; } node.attrs.Reset(); for (attribute = node.attrs.Next(); attribute != null; attribute = node.attrs.Next()) { string s = attribute.val.Trim(); if (attributes == null) { attributes = new FencedAttributes(); } if (attribute.name == "open") { if (s.Length > 0) { attributes.open = s; } else { attributes.open = "NONE"; } } else if (attribute.name == "close") { if (s.Length > 0) { attributes.close = s; } else { attributes.close = "NONE"; } } else if (attribute.name == "separators") { if (s.Length > 0) { attributes.separators = s; } else { attributes.separators = "NONE"; } } } node.attrs.Reset(); } catch { } return attributes; }
public static void ApplyAttrs(Node node, FencedAttributes fencedAttributes) { if (((node != null) && (node.type_ != null)) && ((node.type_.type == ElementType.Mfenced) && (fencedAttributes != null))) { if (fencedAttributes.separators.Length > 0) { if (fencedAttributes.separators == ",") { if (node.attrs != null) { Nodes.Attribute attribute = node.attrs.Get("separators"); if (attribute != null) { node.attrs.Remove(attribute); } } } else { if (node.attrs == null) { node.attrs = new AttributeList(); } if (fencedAttributes.separators == "NONE") { node.attrs.Add("separators", ""); } else { node.attrs.Add("separators", fencedAttributes.separators); } } } if (fencedAttributes.open.Length > 0) { if ((((fencedAttributes.open == "{") || (fencedAttributes.open == "[")) || ((fencedAttributes.open == "|") || (fencedAttributes.open == "<"))) || ((fencedAttributes.open[0] == '\u2329') || (fencedAttributes.open[0] == '<'))) { if (node.attrs == null) { node.attrs = new AttributeList(); } node.attrs.Add("open", fencedAttributes.open); } else if (fencedAttributes.open == "NONE") { if (node.attrs == null) { node.attrs = new AttributeList(); } node.attrs.Add("open", ""); } else if ((fencedAttributes.open == "(") && (node.attrs != null)) { Nodes.Attribute attribute = node.attrs.Get("open"); if (attribute != null) { node.attrs.Remove(attribute); } } } if (fencedAttributes.close.Length > 0) { if ((((fencedAttributes.close == "}") || (fencedAttributes.close == "]")) || ((fencedAttributes.close == "|") || (fencedAttributes.close == ">"))) || ((fencedAttributes.close[0] == '\u232a') || (fencedAttributes.close[0] == '>'))) { if (node.attrs == null) { node.attrs = new AttributeList(); } node.attrs.Add("close", fencedAttributes.close); } else if (fencedAttributes.close == "NONE") { if (node.attrs == null) { node.attrs = new AttributeList(); } node.attrs.Add("close", ""); } else if ((fencedAttributes.close == ")") && (node.attrs != null)) { Nodes.Attribute attribute = node.attrs.Get("close"); if (attribute != null) { node.attrs.Remove(attribute); } } } } }
// public bool ApplyFencedAttributes (Node node, FencedAttributes FencedAttributes) { try { this.OnInsert (false); AttributeBuilder.ApplyAttrs (node, FencedAttributes); } catch { } return true; }