コード例 #1
0
        private string CreateNodeAnnotationContent(OpenNodeAnnotationEventArgs e)
        {
            var writer = new StringWriter();

            try
            {
                writer.WriteLine(DocumentationBrowserUtils.GetContentFromEmbeddedResource(STYLE_RESOURCE));

                // Get the Node info section
                var nodeDocumentation = NodeDocumentationHtmlGenerator.FromAnnotationEventArgs(e);
                writer.WriteLine(nodeDocumentation);

                // Convert the markdown file to html
                MarkdownHandlerInstance.ParseToHtml(ref writer, e.MinimumQualifiedName, e.PackageName);

                writer.Flush();
                var output = writer.ToString();

                // Sanitize html and warn if any changes where made
                if (MarkdownHandlerInstance.SanitizeHtml(ref output))
                {
                    LogWarning(Resources.ScriptTagsRemovalWarning, WarningLevel.Mild);
                }

                // inject the syntax highlighting script at the bottom at the document.
                output += DocumentationBrowserUtils.GetDPIScript();
                output += DocumentationBrowserUtils.GetSyntaxHighlighting();

                return(output);
            }
            finally
            {
                writer?.Dispose();
            }
        }
コード例 #2
0
        private string CreateNodeAnnotationContent(OpenNodeAnnotationEventArgs e)
        {
            var writer = new StringWriter();

            try
            {
                writer.WriteLine(DocumentationBrowserUtils.GetContentFromEmbeddedResource(STYLE_RESOURCE));

                // Get the Node info section and remove script tags if any
                var nodeDocumentation = NodeDocumentationHtmlGenerator.FromAnnotationEventArgs(e);
                if (MarkdownHandlerInstance.SanitizeHtml(ref nodeDocumentation))
                {
                    LogWarning(Resources.ScriptTagsRemovalWarning, WarningLevel.Mild);
                }

                writer.WriteLine(nodeDocumentation);

                // Convert the markdown file to html and remove script tags if any
                if (MarkdownHandlerInstance.ParseToHtml(ref writer, e.MinimumQualifiedName))
                {
                    LogWarning(Resources.ScriptTagsRemovalWarning, WarningLevel.Mild);
                }

                writer.Flush();
                return(writer.ToString());
            }
            finally
            {
                writer?.Dispose();
            }
        }