public void CanUseMultiplyInputStrings() { MarkdownParser markdownParser = new MarkdownParser(); DocumentNode documentNode = markdownParser.ParseString(new string[] { @"# Hello ", // TODO: bug: if there is no new-line after header, it fails to parse it. @"This is new line", @"```powershell Code snippet ```" }); Assert.Equal(3, documentNode.Children.Count()); HeadingNode node1 = this.AssertNodeType <HeadingNode>( documentNode.Children.ElementAtOrDefault(0), MarkdownNodeType.Heading); ParagraphNode node2 = this.AssertNodeType <ParagraphNode>( documentNode.Children.ElementAtOrDefault(1), MarkdownNodeType.Paragraph); CodeBlockNode node3 = this.AssertNodeType <CodeBlockNode>( documentNode.Children.ElementAtOrDefault(2), MarkdownNodeType.CodeBlock); }
public void ParseEscapingSameWayAsGithub() { MarkdownParser markdownParser = new MarkdownParser(); DocumentNode documentNode = MarkdownStringToDocumentNode(@" \< \\< \\\< \\\\< \\\\\< \\\\[ \ \\ \\\ \\\\ ( ) [ ] \( \) \[ \\[ \] \` "); ParagraphNode paragraphNode = this.AssertNodeType <ParagraphNode>( documentNode.Children.ElementAtOrDefault(0), MarkdownNodeType.Paragraph); // NOTE: to update this example, create a gist on github to check out how it's parsed. Assert.Equal(@"< \< \< \\< \\< \\[ \ \ \\ \\ ( ) [ ] ( ) [ \[ ] `", paragraphNode.Spans.First().Text); }
public virtual void Convert(HtmlNode node, XmlWriter writer) { foreach (var currentNode in node.ChildNodes) { // special case, we don't want free form text in the body. if (currentNode.Name == "#text") { if (IsBody) { // surround text in a paragraph var paragraph = new ParagraphNode(); paragraph.Convert(currentNode, writer); continue; } } IDocumentNode handler; if (Nodes.TryGetValue(currentNode.Name, out handler)) { handler.Convert(currentNode, writer); } else if (currentNode.ChildNodes.Count != 0) { var innerText = new InnerTextNode(); innerText.Convert(currentNode, writer); } } }
private void HandleParagraphs(BlogContext db, BlogEntry entry, string text) { var paras = text.Split('\n'); var iter = paras.Cast <string>().GetEnumerator(); while (iter.MoveNext()) { var sectionSplit = iter.Current.IndexOf(' '); var index = iter.Current.Substring(0, sectionSplit); var heading = iter.Current.Substring(sectionSplit); ParagraphNode node = new ParagraphNode { Entry = entry, Index = index, Heading = heading }; var sb = new System.Text.StringBuilder(); while (iter.MoveNext() && char.IsNumber(iter.Current[0]) && iter.Current[1] == '.') { sb.AppendLine(iter.Current); } node.Text = sb.ToString(); db.Paragraphs.Add(node); } }
public void ParsesDocumentWithMultipleNodes() { string documentText = string.Format( @" # {0} {2} ``` {1} ``` ## {0} {2} [{3}]({4}) ", headingText, codeBlockText, paragraphText, hyperlinkText, hyperlinkUri); MarkdownParser markdownParser = new MarkdownParser(); DocumentNode documentNode = markdownParser.ParseString( documentText); HeadingNode headingNode = this.AssertNodeType <HeadingNode>( documentNode.Children.ElementAtOrDefault(0), MarkdownNodeType.Heading); Assert.Equal(headingText, headingNode.Text); Assert.Equal(1, headingNode.HeadingLevel); CodeBlockNode codeBlockNode = this.AssertNodeType <CodeBlockNode>( documentNode.Children.ElementAtOrDefault(2), MarkdownNodeType.CodeBlock); Assert.Equal(codeBlockText, codeBlockNode.Text); headingNode = this.AssertNodeType <HeadingNode>( documentNode.Children.ElementAtOrDefault(3), MarkdownNodeType.Heading); Assert.Equal(headingText, headingNode.Text); Assert.Equal(2, headingNode.HeadingLevel); ParagraphNode paragraphNode = this.AssertNodeType <ParagraphNode>( documentNode.Children.ElementAtOrDefault(4), MarkdownNodeType.Paragraph); Assert.Equal(paragraphText.Replace("\r\n", " "), paragraphNode.Spans.First().Text); HyperlinkSpan hyperlinkSpan = Assert.IsType <HyperlinkSpan>( paragraphNode.Spans.ElementAt(1)); Assert.Equal(hyperlinkText, hyperlinkSpan.Text); Assert.Equal(hyperlinkUri, hyperlinkSpan.Uri); }
void IAstVisitor <ResolveContext> .Visit(ParagraphNode node, ResolveContext context) { context.Parent = node; foreach (var item in node.Children) { node.Accept(this, context); } }
protected string GetTextFromParagraphNode(ParagraphNode node) { if (node == null) { return(""); } return(GetTextFromParagraphSpans(node.Spans)); }
protected override void Write(AdfRenderer renderer, ParagraphBlock obj) { var paragraph = new ParagraphNode(); renderer.Push(paragraph); renderer.WriteLeafInline(obj); renderer.Pop(); }
public void ParsesParagraph() { ParagraphNode paragraphNode = this.ParseAndGetExpectedChild <ParagraphNode>( paragraphText, MarkdownNodeType.Paragraph); Assert.Equal(paragraphText.Replace("\r\n", " "), paragraphNode.Spans.First().Text); }
public Render Visit(ParagraphNode node) { recursionLevel += 1; var render = new Render(recursionLevel, "paragraph"); var childrens = node.Children.Select(i => i.Accept(this)); render.Children.AddRange(childrens); recursionLevel -= 1; return(render); }
void IAstVisitor <ParsingContext> .Visit(ParagraphNode node, ParsingContext context) { context.Stack.Push(new Paragraph()); foreach (var item in node.Children) { item.Accept(this, context); } var c = context.Stack.Pop(); context.Blocks.Add(c); }
public override void VisitParagraph(ParagraphNode node) { Write("<p"); if (node.Class != null) { Write(" class=\"", ToIdentifier(node.Class), "\""); } Write(">"); JoinChildren(node, "<br />" + NewLine); Write("</p>"); }
public void ParsesParagraphWithFormattedSpans() { ParagraphNode paragraphNode = this.ParseAndGetExpectedChild <ParagraphNode>( "Normal\r\n\r\nText *Italic* \r\n\r\n**Bold**\r\n### New header!\r\nBoooo\r\n----\r\n", MarkdownNodeType.Paragraph); ParagraphSpan[] spans = paragraphNode.Spans.ToArray(); Assert.Equal("Normal\r\nText", spans[0].Text); Assert.Equal("Italic", spans[1].Text); Assert.IsType <HardBreakSpan>(spans[2]); Assert.Equal("Bold", spans[3].Text); }
public void ParsesParagraphWithSupportedCharacters() { const string allCharacterString = "This is a \"test\" string; it's very helpful. Success: yes!?"; ParagraphNode paragraphNode = this.ParseAndGetExpectedChild <ParagraphNode>( allCharacterString, MarkdownNodeType.Paragraph); ParagraphSpan[] spans = paragraphNode.Spans.ToArray(); Assert.Equal(allCharacterString, spans[0].Text); }
public void ParsesEscapedLessAndMoreCorrectly() { const string allCharacterString = @"\<port-number\>"; ParagraphNode paragraphNode = this.ParseAndGetExpectedChild <ParagraphNode>( allCharacterString, MarkdownNodeType.Paragraph); ParagraphSpan[] spans = paragraphNode.Spans.ToArray(); Assert.Equal("<port-number>", spans[0].Text); }
public void ParsesHyperlinkWithoutLink() { ParagraphNode paragraphNode = this.ParseAndGetExpectedChild <ParagraphNode>( string.Format( "[{0}]()", hyperlinkText), MarkdownNodeType.Paragraph); HyperlinkSpan hyperlinkSpan = Assert.IsType <HyperlinkSpan>( paragraphNode.Spans.FirstOrDefault()); Assert.Equal(hyperlinkText, hyperlinkSpan.Text); Assert.Equal("", hyperlinkSpan.Uri); }
protected SourceExtent GetExtent(MarkdownNode node) { TextNode textNode = node as TextNode; if (textNode != null) { return(textNode.SourceExtent); } ParagraphNode paragraphNode = node as ParagraphNode; if (paragraphNode != null && paragraphNode.Spans.Any()) { return(paragraphNode.Spans.First().SourceExtent); } return(new SourceExtent("", 0, 0, 0, 0)); }
public void PostParagraph(ParagraphAddModel addmodel) { using (var unitOfWork = new UnitOfWork()) { var entity = _mapper.Map <Paragraph>(addmodel); ParagraphNode paragraphNode = new ParagraphNode(); if (entity != null) { var Parentity = Save(entity); paragraphNode.NodeId = Parentity.NodeId; paragraphNode.ParagraphId = Parentity.Id; paragraphNode.CreateTime = DateTime.Now; _paragrphNodeServer.Save(paragraphNode); unitOfWork.Dispose(); } } }
public void UnderstandsOneLineBreakVsTwoLineBreaks() { MarkdownParser markdownParser = new MarkdownParser(); DocumentNode documentNode = MarkdownStringToDocumentNode(@" 1 2 3 "); ParagraphNode paragraphNode = this.AssertNodeType <ParagraphNode>( documentNode.Children.ElementAtOrDefault(0), MarkdownNodeType.Paragraph); Assert.Equal("1 2\r\n3", paragraphNode.Spans.First().Text); }
public void PreserveLineEndingsInLists2() { DocumentNode documentNode = MarkdownStringToDocumentNode( @" Valid values are: -- Block: When the output buffer is full, execution is suspended until the buffer is clear. -- Drop: When the output buffer is full, execution continues. As new output is saved, the oldest output is discarded. -- None: No output buffering mode is specified. The value of the OutputBufferingMode property of the session configuration is used for the disconnected session."); ParagraphNode text = this.AssertNodeType <ParagraphNode>( documentNode.Children.ElementAtOrDefault(0), MarkdownNodeType.Paragraph); Common.AssertMultilineEqual(@"Valid values are: -- Block: When the output buffer is full, execution is suspended until the buffer is clear. -- Drop: When the output buffer is full, execution continues. As new output is saved, the oldest output is discarded. -- None: No output buffering mode is specified. The value of the OutputBufferingMode property of the session configuration is used for the disconnected session.", text.Spans.First().Text); }
public string AboutMarkdownToString(DocumentNode document) { //ensure that all node types in the about topic are handeled. var acceptableNodeTypes = new List <MarkdownNodeType> { MarkdownNodeType.Heading, MarkdownNodeType.Paragraph, MarkdownNodeType.CodeBlock }; if (document.Children.Any(c => (!acceptableNodeTypes.Contains(c.NodeType)))) { throw new NotSupportedException("About Topics can only have heading, parapgrah or code block nodes in their Markdown Model."); } //processes all nodes in order foreach (var currentNode in document.Children) { switch (currentNode.NodeType) { case MarkdownNodeType.Paragraph: ParagraphNode paragraphNode = currentNode as ParagraphNode; AddAboutParagraph(paragraphNode); break; case MarkdownNodeType.Heading: HeadingNode headingNode = currentNode as HeadingNode; AddAboutHeading(headingNode, document); break; case MarkdownNodeType.CodeBlock: CodeBlockNode codeblockNode = currentNode as CodeBlockNode; AddAboutCodeBlock(codeblockNode); break; default: throw new ArgumentOutOfRangeException(); } } return(RenderCleaner.FullNormalization(_stringBuilder.ToString())); }
/// <summary> /// /// </summary> public void HtmlPackPostParagraph() { HtmlPackHelp htmlPackHelp = new HtmlPackHelp(); var htmlPackInfo = _htmlPack.GetAll(); foreach (var item in htmlPackInfo) { var results = htmlPackHelp.PostPackHtmlData(item.HtmlUrl); foreach (var result in results) { result.CreateTime = DateTime.Now.Date; result.NodeId = item.NodeId.GetValueOrDefault(); result.LastUpdateTime = DateTime.Now.Date; result.Type = (int)ParagraphType.Hot; result.ThumbsupCount = 0; ParagraphNode paragraphNode = new ParagraphNode(); PostParagraph(result); } } }
public static void MergeParagraphs(InkAnalyzer inkAnalyzer) { foreach (ContextNode writingRegion in inkAnalyzer.RootNode.SubNodes) { List <ParagraphAnalysisEntry> paragraphs = new List <ParagraphAnalysisEntry>(); foreach (ContextNode node in writingRegion.SubNodes) { if (node is ParagraphNode) { ParagraphNode paragraph = node as ParagraphNode; ContextNode firstLine = paragraph.SubNodes[0]; Point paragraphReference = firstLine.Strokes.GetBounds().TopLeft; ParagraphAnalysisEntry entry = new ParagraphAnalysisEntry(); entry.paragraph = paragraph; entry.point = paragraphReference; paragraphs.Add(entry); } } paragraphs.Sort(delegate(ParagraphAnalysisEntry a, ParagraphAnalysisEntry b) { return(a.point.Y.CompareTo(b.point.Y)); }); for (int i = 0; i < paragraphs.Count - 1; i++) { ParagraphAnalysisEntry entry = paragraphs[i]; ParagraphAnalysisEntry next = paragraphs[i + 1]; bool closeto = entry.closeTo(next); if (closeto) { foreach (ContextNode node in next.paragraph.SubNodes) { node.Reparent(entry.paragraph); } writingRegion.DeleteSubNode(next.paragraph); paragraphs[i + 1] = entry; } } } }
public void PreserveLineEndingsInLists() { DocumentNode documentNode = MarkdownStringToDocumentNode( @" -- This is a list -- Yes, with double-dashes -- Because that's how it happens a lot in PS docs - This is a regular list - Item2 - Item3 * Item1 * Item1 * Item3 And this is not a list. So it's fine to drop this linebreak. New paragraph "); ParagraphNode text = this.AssertNodeType <ParagraphNode>( documentNode.Children.ElementAtOrDefault(0), MarkdownNodeType.Paragraph); Common.AssertMultilineEqual(@"-- This is a list -- Yes, with double-dashes -- Because that's how it happens a lot in PS docs - This is a regular list - Item2 - Item3 * Item1 * Item1 * Item3 And this is not a list. So it's fine to drop this linebreak. New paragraph", text.Spans.First().Text); }
private void AddAboutParagraph(ParagraphNode paragraphNode) { foreach (var lineContent in paragraphNode.Spans.Select(span => span.Text)) { //handles all paragraph lines over 80 characters long and not headers if (lineContent.Length > _maxLineWidth - 4) { WrapAndAppendLines(lineContent, _stringBuilder); _stringBuilder.AppendLine(); } else if (StringComparer.OrdinalIgnoreCase.Equals(lineContent, "\n")) { _stringBuilder.AppendLine(); } else { _stringBuilder.AppendFormat("{0}{1}{2}", AboutIndentation, lineContent, NewLine); } } _stringBuilder.AppendLine(); }
public override void VisitParagraph(ParagraphNode node) { StartDump(); AggregateChildren(node); string content = StopDump(); if (!string.IsNullOrEmpty(node.Class)) { Write("< ", node.Class, " >"); if (content.HasMultipleLine() || content.Length > RecommendedLineSize) { WriteLine(); } else { Write(" "); } } Write(content); }
public void PreserveTextAsIsInFormattingPreserveMode() { string text = @"Hello: -- Block: aaa. Foo Bar [this](hyperlink) -- Drop: <When the> output buffer is full * None: specified. It's up To authors To format text "; DocumentNode documentNode = MarkdownStringToDocumentNodePreserveFormatting(text); ParagraphNode outText = this.AssertNodeType <ParagraphNode>( documentNode.Children.ElementAtOrDefault(0), MarkdownNodeType.Paragraph); Common.AssertMultilineEqual(text, outText.Spans.First().Text); }
private void reflowParagraph(ParagraphNode node, InkAnalyzer inkAnalyzer, InkCanvas inkCanvas) { ContextNodeCollection lines = node.SubNodes; Rect bounds = node.Strokes.GetBounds(); List<InkWordNode> resultWords = new List<InkWordNode>(); double lineHeight = 0; double spacing = 30; //Collect all strokes foreach (ContextNode line in lines) { ContextNodeCollection words = line.SubNodes; foreach (ContextNode word in words) { lineHeight += word.Strokes.GetBounds().Height; InkWordNode wordNode = word as InkWordNode; resultWords.Add(wordNode); } } lineHeight /= resultWords.Count; List<List<InkWordNode>> resultLines = new List<List<InkWordNode>>(); List<double> lineMaxBaseline = new List<double>(); //Reflow strokes double x = 0; double maxX = inkCanvas.ActualWidth - bounds.X; resultLines.Add(new List<InkWordNode>()); lineMaxBaseline.Add(0); foreach (InkWordNode word in resultWords) { //Does word fit? Rect wordBound = word.Strokes.GetBounds(); if (x + wordBound.Width + spacing > maxX && multiline) { //Not fitting! Newline x = 0; resultLines.Add(new List<InkWordNode>()); lineMaxBaseline.Add(0); } x += spacing + wordBound.Width; PointCollection baseline = word.GetBaseline(); if (baseline != null && baseline.Count > 0) { double baselineFromTop = baseline[0].Y - wordBound.Y; resultLines[resultLines.Count - 1].Add(word); if (baselineFromTop > lineMaxBaseline[resultLines.Count - 1]) { lineMaxBaseline[resultLines.Count - 1] = baselineFromTop; } } } double y = 0; int lineNumber = 0; foreach (List<InkWordNode> line in resultLines) { double lineBaseline = lineMaxBaseline[lineNumber]; x = 0; foreach (InkWordNode word in line) { Rect wordBound = word.Strokes.GetBounds(); PointCollection baseline = word.GetBaseline(); double baselineFromTop = baseline[0].Y - wordBound.Y; double destX = (x + bounds.X); double dx = destX - (wordBound.X); //Match mid double dy = (y + lineBaseline + bounds.Y) - (wordBound.Y + baselineFromTop); InkUtils.transposeStrokes(inkAnalyzer, word.Strokes, dx, dy); x += spacing + wordBound.Width; } y += lineHeight + spacing; lineNumber++; } }
/// <summary> /// InkAnalysis results form a tree, this method is called recursively /// to render each node in the tree. /// </summary> private void DrawFeedback(DrawingContext drawingContext, ContextNode contextNode) { //see what type of ContextNode this is by casting it Rect nodeBounds = contextNode.Strokes.GetBounds(); InkWordNode inkWordNode = contextNode as InkWordNode; if (inkWordNode != null) { drawingContext.DrawRoundedRectangle(null, new Pen(Brushes.Blue, 1.0d), nodeBounds, 1d, 1d); drawingContext.DrawText(new FormattedText(inkWordNode.GetRecognizedString(), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 9.0d, Brushes.Black), nodeBounds.BottomLeft); goto recurse; } InkDrawingNode inkDrawingNode = contextNode as InkDrawingNode; if (inkDrawingNode != null) { drawingContext.DrawRoundedRectangle(null, new Pen(Brushes.Purple, 1.0d), nodeBounds, 1d, 1d); drawingContext.DrawText(new FormattedText("Drawing: " + inkDrawingNode.GetShapeName(), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 9.0d, Brushes.Black), nodeBounds.BottomLeft); goto recurse; } InkBulletNode inkBulletNode = contextNode as InkBulletNode; if (inkBulletNode != null) { drawingContext.DrawRoundedRectangle(null, new Pen(Brushes.Green, 1.0d), nodeBounds, 1d, 1d); drawingContext.DrawText(new FormattedText(inkBulletNode.GetRecognizedString(), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 9.0d, Brushes.Black), nodeBounds.BottomLeft); goto recurse; } WritingRegionNode writingRegionNode = contextNode as WritingRegionNode; if (writingRegionNode != null) { nodeBounds.Inflate(3d, 3d); drawingContext.DrawRoundedRectangle(null, new Pen(Brushes.Black, 1.0d), nodeBounds, 1d, 1d); drawingContext.DrawText(new FormattedText("Writing Region", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 9.0d, Brushes.Black), nodeBounds.BottomLeft + new Vector(0, 3)); goto recurse; } ParagraphNode paragraphNode = contextNode as ParagraphNode; if (paragraphNode != null) { nodeBounds.Inflate(2d, 2d); //inflate so this will be visible outside the line node drawingContext.DrawRoundedRectangle(null, new Pen(Brushes.Red, 1.0d), nodeBounds, 1d, 1d); goto recurse; } LineNode lineNode = contextNode as LineNode; if (lineNode != null) { nodeBounds.Inflate(1d, 1d); //inflate so this will be visible outside the word node drawingContext.DrawRoundedRectangle(null, new Pen(Brushes.Orange, 1.0d), nodeBounds, 1d, 1d); goto recurse; } recurse: foreach (ContextNode subNode in contextNode.SubNodes) { DrawFeedback(drawingContext, subNode); } }
/// <summary> /// /// </summary> /// <param name="command"></param> /// <returns>true if Parameter was found</returns> private bool ParameterRule(MamlCommand command) { // grammar: // #### Name [TypeName] - mandatory // ```powershell - optional // [Parameter(...)] // ``` // Description - optional var node = GetNextNode(); var headingNode = GetHeadingWithExpectedLevel(node, PARAMETER_NAME_HEADING_LEVEL); if (headingNode == null) { return(false); } var name = headingNode.Text.Split()[0]; MamlParameter parameter = new MamlParameter() { Name = name, Extent = headingNode.SourceExtent }; int equalIndex = headingNode.Text.IndexOf('='); string headingNodeText; if (equalIndex >= 0) { parameter.DefaultValue = headingNode.Text.Substring(equalIndex + 1).Trim(); // trim it for this case from PSReadLine: // #### WordDelimiters [Int32] = ;:,.[]{}()/\|^&*-=+ // We need to make sure that closing ] corresponds to [Int32], so it's the last ] before first = sign. headingNodeText = headingNode.Text.Substring(0, equalIndex); } else { headingNodeText = headingNode.Text; } int typeBeginIndex = headingNodeText.IndexOf('['); int typeEndIndex = headingNodeText.LastIndexOf(']'); if (typeBeginIndex >= 0 && typeEndIndex > 0) { parameter.Type = headingNodeText.Substring(typeBeginIndex + 1, typeEndIndex - typeBeginIndex - 1); } node = GetNextNode(); ParagraphNode descriptionNode = null; CodeBlockNode attributesNode = null; // it can be the end if (node != null) { switch (node.NodeType) { case MarkdownNodeType.Unknown: break; case MarkdownNodeType.Document: break; case MarkdownNodeType.Paragraph: descriptionNode = node as ParagraphNode; break; case MarkdownNodeType.Heading: // next parameter started UngetNode(node); break; case MarkdownNodeType.CodeBlock: attributesNode = node as CodeBlockNode; break; default: throw new ArgumentOutOfRangeException(); } if (descriptionNode == null) { descriptionNode = ParagraphNodeRule(); } } parameter.Description = GetTextFromParagraphNode(descriptionNode); parameter.AttributesText = attributesNode != null ? attributesNode.Text : string.Empty; if (parameter.AttributesText.Contains(@"[SupportsWildCards()]")) { parameter.Globbing = true; } command.Parameters.Add(parameter); return(true); }
public void ParsesExample3FromGetPSSnapin() { string codeblockText = @"The first command gets snap-ins that have been added to the current session, including the snap-ins that are installed with Windows PowerShell. In this example, ManagementFeatures is not returned. This indicates that it has not been added to the session. PS C:\>get-pssnapin The second command gets snap-ins that have been registered on your system (including those that have already been added to the session). It does not include the snap-ins that are installed with Windows PowerShell.In this case, the command does not return any snap-ins. This indicates that the ManagementFeatures snapin has not been registered on the system. PS C:\>get-pssnapin -registered The third command creates an alias, ""installutil"", for the path to the InstallUtil tool in .NET Framework. PS C:\>set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\installutil.exe The fourth command uses the InstallUtil tool to register the snap-in. The command specifies the path to ManagementCmdlets.dll, the file name or ""module name"" of the snap-in. PS C:\>installutil C:\Dev\Management\ManagementCmdlets.dll The fifth command is the same as the second command. This time, you use it to verify that the ManagementCmdlets snap-in is registered. PS C:\>get-pssnapin -registered The sixth command uses the Add-PSSnapin cmdlet to add the ManagementFeatures snap-in to the session. It specifies the name of the snap-in, ManagementFeatures, not the file name. PS C:\>add-pssnapin ManagementFeatures To verify that the snap-in is added to the session, the seventh command uses the Module parameter of the Get-Command cmdlet. It displays the items that were added to the session by a snap-in or module. PS C:\>get-command -module ManagementFeatures You can also use the PSSnapin property of the object that the Get-Command cmdlet returns to find the snap-in or module in which a cmdlet originated. The eighth command uses dot notation to find the value of the PSSnapin property of the Set-Alias cmdlet. PS C:\>(get-command set-alias).pssnapin"; string descriptionText = @"This example demonstrates the process of registering a snap-in on your system and then adding it to your session. It uses ManagementFeatures, a fictitious snap-in implemented in a file called ManagementCmdlets.dll."; string documentText = string.Format(@" #### -------------------------- EXAMPLE 3 -------------------------- ```powershell {0} ``` {1} ### RELATED LINKS [Online Version:](https://go.microsoft.com/fwlink/p/?linkid=289570) [Get-PSSnapin]() [Remove-PSSnapin]() [about_Profiles]() [about_PSSnapins]() ## Clear-History ### SYNOPSIS Deletes entries from the command history. ### DESCRIPTION The Clear-History cmdlet deletes commands from the command history, that is, the list of commands entered during the current session. Without parameters, Clear-History deletes all commands from the session history, but you can use the parameters of Clear-History to delete selected commands. ### PARAMETERS #### CommandLine [String[]] ```powershell [Parameter(ParameterSetName = 'Set 2')] ``` Deletes commands with the specified text strings. If you enter more than one string, Clear-History deletes commands with any of the strings. ", codeblockText, descriptionText); DocumentNode documentNode = MarkdownStringToDocumentNode(documentText); HeadingNode headingNode = this.AssertNodeType <HeadingNode>( documentNode.Children.ElementAtOrDefault(0), MarkdownNodeType.Heading); Assert.Equal(4, headingNode.HeadingLevel); CodeBlockNode codeBlockNode = this.AssertNodeType <CodeBlockNode>( documentNode.Children.ElementAtOrDefault(1), MarkdownNodeType.CodeBlock); Common.AssertMultilineEqual(codeblockText, codeBlockNode.Text); ParagraphNode paragraphNode = this.AssertNodeType <ParagraphNode>( documentNode.Children.ElementAtOrDefault(2), MarkdownNodeType.Paragraph); Common.AssertMultilineEqual(descriptionText, paragraphNode.Spans.First().Text); }