private void HandleEscSeq1(PegNode node, StyleContext context, StructuralGlyph parent) { int posBeg = node.match_.posBeg_; var childNode = node.child_; if (childNode == null) throw new ArgumentNullException("childNode"); string escHeader = _sourceText.Substring(posBeg, childNode.match_.posBeg_ - posBeg); switch (escHeader.ToLowerInvariant()) { case @"\id(": { const string DefPropertyHead = "$Property[\""; const string DefPropertyTail = "\"]"; string s = GetText(childNode).Trim(); if (s == "$DI") { parent.Add(new DocumentIdentifier(context)); } else if (s.StartsWith(DefPropertyHead) && s.EndsWith(DefPropertyTail)) { string propertyName = s.Substring(DefPropertyHead.Length, s.Length - DefPropertyHead.Length - DefPropertyTail.Length); if (!string.IsNullOrEmpty(propertyName)) parent.Add(new ValueOfProperty(context, propertyName)); } } break; case @"\g(": { var newContext = context.Clone(); newContext.SetFont(context.FontId.WithFamily("Symbol")); VisitNode(childNode, newContext, parent); } break; case @"\i(": { var newContext = context.Clone(); newContext.MergeFontStyle(FontXStyle.Italic); VisitNode(childNode, newContext, parent); } break; case @"\b(": { var newContext = context.Clone(); newContext.MergeFontStyle(FontXStyle.Bold); VisitNode(childNode, newContext, parent); } break; case @"\u(": { var newContext = context.Clone(); newContext.MergeFontStyle(FontXStyle.Underline); VisitNode(childNode, newContext, parent); } break; case @"\s(": { var newContext = context.Clone(); newContext.MergeFontStyle(FontXStyle.Strikeout); VisitNode(childNode, newContext, parent); } break; case @"\n(": { var newContext = context.Clone(); newContext.SetFontStyle(FontXStyle.Regular); VisitNode(childNode, newContext, parent); } break; case @"\+(": { var newParent = new Superscript(); newParent.Style = context; parent.Add(newParent); var newContext = context.Clone(); newContext.ScaleFont(0.65); VisitNode(childNode, newContext, newParent); } break; case @"\-(": { var newParent = new Subscript(); newParent.Style = context; parent.Add(newParent); var newContext = context.Clone(); newContext.ScaleFont(0.65); VisitNode(childNode, newContext, newParent); } break; case @"\l(": { string s = GetText(childNode); int plotNumber; if (int.TryParse(s, out plotNumber)) { parent.Add(new PlotSymbol(context, plotNumber)); } } break; case @"\%(": { string s = GetText(childNode); int plotNumber; if (int.TryParse(s, out plotNumber)) { parent.Add(new PlotName(context, plotNumber)); } } break; case @"\ad(": { var newParent = new DotOverGlyph(); newParent.Style = context; parent.Add(newParent); VisitNode(childNode, context, newParent); } break; case @"\ab(": { var newParent = new BarOverGlyph(); newParent.Style = context; parent.Add(newParent); VisitNode(childNode, context, newParent); } break; } }
private void HandleEscSeq1(PegNode node, StyleContext context, StructuralGlyph parent) { int posBeg = node.match_.posBeg_; var childNode = node.child_; if (childNode == null) { throw new ArgumentNullException("childNode"); } string escHeader = _sourceText.Substring(posBeg, childNode.match_.posBeg_ - posBeg); switch (escHeader.ToLowerInvariant()) { case @"\id(": { const string DefPropertyHead = "$Property[\""; const string DefPropertyTail = "\"]"; string s = GetText(childNode).Trim(); if (s == "$DI") { parent.Add(new DocumentIdentifier(context)); } else if (s.StartsWith(DefPropertyHead) && s.EndsWith(DefPropertyTail)) { string propertyName = s.Substring(DefPropertyHead.Length, s.Length - DefPropertyHead.Length - DefPropertyTail.Length); if (!string.IsNullOrEmpty(propertyName)) { parent.Add(new ValueOfProperty(context, propertyName)); } } } break; case @"\g(": { var newContext = context.Clone(); newContext.SetFont(context.FontId.WithFamily("Symbol")); VisitNode(childNode, newContext, parent); } break; case @"\i(": { var newContext = context.Clone(); newContext.MergeFontStyle(FontXStyle.Italic); VisitNode(childNode, newContext, parent); } break; case @"\b(": { var newContext = context.Clone(); newContext.MergeFontStyle(FontXStyle.Bold); VisitNode(childNode, newContext, parent); } break; case @"\u(": { var newContext = context.Clone(); newContext.MergeFontStyle(FontXStyle.Underline); VisitNode(childNode, newContext, parent); } break; case @"\s(": { var newContext = context.Clone(); newContext.MergeFontStyle(FontXStyle.Strikeout); VisitNode(childNode, newContext, parent); } break; case @"\n(": { var newContext = context.Clone(); newContext.SetFontStyle(FontXStyle.Regular); VisitNode(childNode, newContext, parent); } break; case @"\+(": { var newParent = new Superscript { Style = context }; parent.Add(newParent); var newContext = context.Clone(); newContext.ScaleFont(0.65); VisitNode(childNode, newContext, newParent); } break; case @"\-(": { var newParent = new Subscript { Style = context }; parent.Add(newParent); var newContext = context.Clone(); newContext.ScaleFont(0.65); VisitNode(childNode, newContext, newParent); } break; case @"\l(": { string s = GetText(childNode); if (int.TryParse(s, out var plotNumber)) { parent.Add(new PlotSymbol(context, plotNumber)); } } break; case @"\%(": { string s = GetText(childNode); if (int.TryParse(s, out var plotNumber)) { parent.Add(new PlotName(context, plotNumber)); } } break; case @"\ad(": { var newParent = new DotOverGlyph { Style = context }; parent.Add(newParent); VisitNode(childNode, context, newParent); } break; case @"\ab(": { var newParent = new BarOverGlyph { Style = context }; parent.Add(newParent); VisitNode(childNode, context, newParent); } break; } }