protected override void WriteMarkdownDeclaration(TextWriter tw, bool writeDeclaringAssembly) { //tw.WriteLine($"<!-- [Member] {GetType().Name} - {ToString()} -->"); // Write the markdown in multiple lines, with the declaration inside a code block. // ASSUMPTION: code is always C# if (writeDeclaringAssembly) { tw.WriteLine(MarkdownUtility.ToInlineCode(DeclaringAssembly.Location)); tw.WriteLine(); } if (this.Status == Status.Present) { tw.WriteLine("```csharp"); tw.WriteLine(GetMarkdownDeclaration()); tw.WriteLine("```"); } else { tw.WriteLine("*Not Defined*"); } tw.WriteLine(); }
public void WriteMarkdownDescription(TextWriter tw) { tw.WriteLine($"# {_name}"); tw.WriteLine(); if (_hasErrors) { tw.WriteLine("```"); if (string.IsNullOrEmpty(_errorDetail)) { tw.WriteLine("Failed to load one or more versions of this assembly. Examine the log messages pane for detailed error information."); } else { tw.WriteLine("Failed to load one or more versions of this assembly:"); tw.WriteLine(_errorDetail); } tw.WriteLine("```"); } else { if (_change == ChangeType.None) { if (_assemblies.Count == 1) { tw.WriteLine("Only one version of this assembly was found (nothing to compare to!)"); tw.WriteLine(); } else { tw.WriteLine("No changes were found across all versions of this assembly."); tw.WriteLine(); } } else if (ChangeTypeUtil.HasBreaking(_change)) { tw.WriteLine("**Breaking changes were found between versions of this assembly.**"); tw.WriteLine(); } else if (ChangeTypeUtil.HasNonBreaking(_change)) { tw.WriteLine("Non-breaking changes were found between versions of this assembly."); tw.WriteLine(); } tw.WriteLine("The following files have been compared in this set:"); tw.WriteLine(); foreach (AssemblyDetail detail in _assemblies) { tw.WriteLine($"* {MarkdownUtility.ToInlineCode(detail.Location)}"); } tw.WriteLine(); } }
protected override void Write(HtmlRenderer renderer, CodeBlock codeBlock) { renderer.EnsureLine(); var fencedCodeBlock = codeBlock as FencedCodeBlock; if (codeBlock.Column > 0 || fencedCodeBlock?.Info == null) { if (codeBlock.Span.Length > 0) { var text = new string(' ', codeBlock.Column) + _documentText.Substring(codeBlock.Span.Start, codeBlock.Span.Length); renderer.Write(GetCodeHtml(text)); } return; } // For R blocks indent count must be zero (no whitespace before ```{r} if (MarkdownUtility.GetRCodeBlockSeparatorLength(fencedCodeBlock.Info, out var start)) { var text = fencedCodeBlock.GetText(); var rCodeBlock = new RCodeBlock(_blockNumber, text, fencedCodeBlock.Arguments); var result = GetCachedResult(_blockNumber, rCodeBlock.Hash, fencedCodeBlock); if (result != null) { renderer.Write(result); } else { var elementId = rCodeBlock.HtmlElementId; _blocks.Add(rCodeBlock); // Write placeholder first. We will insert actual data when the evaluation is done. var renderText = rCodeBlock.Eval ? GetBlockPlaceholder(elementId, text) : GetCodeHtml(text); renderer.Write(renderText); } _blockNumber++; } }
public override CommandResult Invoke(Guid group, int id, object inputArg, ref object outputArg) { if (!TextView.Caret.InVirtualSpace) { var caretPosition = TextView.Caret.Position.BufferPosition; var document = MdEditorDocument.FindInProjectedBuffers(TextView.TextBuffer); var handler = document?.ContainedLanguageHandler; var codeRange = handler?.GetCodeBlockOfLocation(caretPosition); if (codeRange != null) { var code = TextView.TextBuffer.CurrentSnapshot.GetText(new Span(codeRange.Start, codeRange.Length)); code = MarkdownUtility.GetRContentFromMarkdownCodeBlock(code).Trim(); if (!string.IsNullOrWhiteSpace(code)) { try { _interactiveWorkflow.Operations.ExecuteExpression(code); } catch (RException) { } catch (OperationCanceledException) { } } } } return(CommandResult.Executed); }
protected virtual void WriteMarkdownDeclaration(TextWriter tw, bool writeDeclaringAssembly) { //tw.WriteLine($"<!-- [Root] {GetType().Name} - {ToString()} -->"); // Write the markdown on a single line. if (writeDeclaringAssembly) { // Escape the declaring assembly location with backticks because Markdown will interpret assembly names that end in a TLD as a URL. // Even some of Microsoft's own assemblies (System.Net, System.Web) are affected by this. tw.Write($"{MarkdownUtility.ToInlineCode(DeclaringAssembly.Location)}: "); } if (this.Status == Status.Present) { tw.WriteLine($"`{GetMarkdownDeclaration()}`"); } else { tw.WriteLine(" *Not Defined*"); } tw.WriteLine(); }
public void RCode(string markdown, string rCode) { MarkdownUtility.GetRContentFromMarkdownCodeBlock(markdown).TrimEnd().Should().Be(rCode); }
public static string EscapeMarkdown(this string value) { return(MarkdownUtility.Escape(value)); }