コード例 #1
0
ファイル: InclusionTest.cs プロジェクト: xuan2261/docfx
        public void TestInclusion_InlineLevel()
        {
            // 1. Prepare data
            var root = @"
Inline [!include[ref1](ref1.md ""This is root"")]
Inline [!include[ref3](ref3.md ""This is root"")]
";

            var ref1 = @"[!include[ref2](ref2.md ""This is root"")]";
            var ref2 = @"## Inline inclusion do not parse header [!include[root](root.md ""This is root"")]";
            var ref3 = @"**Hello**  ";

            File.WriteAllText("root.md", root);
            File.WriteAllText("ref1.md", ref1);
            File.WriteAllText("ref2.md", ref2);
            File.WriteAllText("ref3.md", ref3);

            var marked     = TestUtility.MarkupWithoutSourceInfo(root, "root.md");
            var dependency = marked.Dependency;
            var expected   = "<p>Inline ## Inline inclusion do not parse header [!include[root](root.md)]\nInline <strong>Hello</strong></p>\n";

            Assert.Equal(expected, marked.Html);
            Assert.Equal(
                new[] { "ref1.md", "ref2.md", "ref3.md", "root.md" },
                dependency.OrderBy(x => x).ToArray());
        }
コード例 #2
0
ファイル: InclusionTest.cs プロジェクト: xuan2261/docfx
        public void TestInlineLevelInclusion_General()
        {
            var root = @"
# Hello World

Test Inline Included File: \\[!include[refa](~/r/a.md)].

Test Escaped Inline Included File: \[!include[refa](~/r/a.md)].
";

            var refa = "This is a **included** token";

            TestUtility.WriteToFile("r/root.md", root);
            TestUtility.WriteToFile("r/a.md", refa);

            var result   = TestUtility.MarkupWithoutSourceInfo(root, "r/root.md");;
            var expected = @"<h1 id=""hello-world"">Hello World</h1>
<p>Test Inline Included File: \This is a <strong>included</strong> token.</p>
<p>Test Escaped Inline Included File: [!include<a href=""%7E/r/a.md"">refa</a>].</p>
";

            Assert.Equal(expected.Replace("\r\n", "\n"), result.Html);

            var dependency         = result.Dependency;
            var expectedDependency = new List <string> {
                "a.md"
            };

            Assert.Equal(expectedDependency.ToImmutableList(), dependency);
        }
コード例 #3
0
ファイル: InclusionTest.cs プロジェクト: xuan2261/docfx
        public void TestBlockInclude_ShouldExcludeBracketInRegex()
        {
            // 1. Prepare data
            var root = @"[!INCLUDE [azure-probe-intro-include](inc1.md)].

[!INCLUDE [azure-arm-classic-important-include](inc2.md)] [Resource Manager model](inc1.md).


[!INCLUDE [azure-ps-prerequisites-include.md](inc3.md)]";

            var expected = @"<p>inc1.</p>
<p>inc2 <a href=""inc1.md"">Resource Manager model</a>.</p>
<p>inc3</p>
";

            var inc1 = @"inc1";
            var inc2 = @"inc2";
            var inc3 = @"inc3";

            File.WriteAllText("root.md", root);
            File.WriteAllText("inc1.md", inc1);
            File.WriteAllText("inc2.md", inc2);
            File.WriteAllText("inc3.md", inc3);

            var marked     = TestUtility.MarkupWithoutSourceInfo(root, "root.md");
            var dependency = marked.Dependency;

            Assert.Equal(expected.Replace("\r\n", "\n"), marked.Html);
            Assert.Equal(
                new[] { "inc1.md", "inc2.md", "inc3.md" },
                dependency.OrderBy(x => x).ToArray());
        }
コード例 #4
0
ファイル: YamlHeaderTest.cs プロジェクト: zyj0021/docfx
        public void TestDfmYamlHeader_General()
        {
            //arange
            var content = @"---
title: ""如何使用 Visual C++ 工具集报告问题 | Microsoft Docs""
ms.custom: 
ms.date: 11/04/2016
ms.reviewer: 
ms.suite: 
ms.technology:
- cpp
ms.tgt_pltfrm: 
ms.topic: article
dev_langs:
- C++
ms.assetid: ec24a49c-411d-47ce-aa4b-8398b6d3e8f6
caps.latest.revision: 8
author: corob-msft
ms.author: corob
manager: ghogen
translation.priority.mt:
- cs-cz
- pl-pl
- pt-br
- tr-tr
translationtype: Human Translation
ms.sourcegitcommit: 5c6fbfc8699d7d66c40b0458972d8b6ef0dcc705
ms.openlocfilehash: 2ea129ac94cb1ddc7486ba69280dc0390896e088
---";
            // act
            var marked = TestUtility.MarkupWithoutSourceInfo(content, "Topic.md");

            // assert
            var expected = @"<yamlheader start=""1"" end=""26"">title: &quot;如何使用 Visual C++ 工具集报告问题 | Microsoft Docs&quot;
ms.custom: 
ms.date: 11/04/2016
ms.reviewer: 
ms.suite: 
ms.technology:
- cpp
ms.tgt_pltfrm: 
ms.topic: article
dev_langs:
- C++
ms.assetid: ec24a49c-411d-47ce-aa4b-8398b6d3e8f6
caps.latest.revision: 8
author: corob-msft
ms.author: corob
manager: ghogen
translation.priority.mt:
- cs-cz
- pl-pl
- pt-br
- tr-tr
translationtype: Human Translation
ms.sourcegitcommit: 5c6fbfc8699d7d66c40b0458972d8b6ef0dcc705
ms.openlocfilehash: 2ea129ac94cb1ddc7486ba69280dc0390896e088</yamlheader>";

            Assert.Equal(expected.Replace("\r\n", "\n"), marked.Html);
        }
コード例 #5
0
ファイル: InclusionTest.cs プロジェクト: xuan2261/docfx
        public void TestComplexImageBlockSrcResolveInToken()
        {
            // -r
            //  |- r.md
            //  |- b
            //  |  |- token.md
            //  |  |- img.jpg
            var r     = @"
[!include[](b/token.md)]
";
            var token = @"
:::image source=""example.jpg"" type=""complex"" alt-text=""example"":::
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
:::image-end:::
";

            TestUtility.WriteToFile("r/r.md", r);
            TestUtility.WriteToFile("r/b/token.md", token);
            var marked = TestUtility.MarkupWithoutSourceInfo(r, "r/r.md");

            var expected = @"<p class=""mx-imgBorder"">
<img src=""~/r/b/example.jpg"" alt=""example"" aria-describedby=""1-0"">
<div id=""1-0"" class=""visually-hidden"">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
</p>
";

            Assert.Equal(expected.Replace("\r\n", "\n"), marked.Html);
        }
コード例 #6
0
ファイル: CodeSnippetTest.cs プロジェクト: zikunfan/docfx
        public void CodeSnippetTagsShouldSucceedWhenReferencedFileContainsRegionWithoutName()
        {
            // arrange
            var content = @"#region
public class MyClass
#region
{
    #region main
    static void Main()
    {
    }
    #endregion
}
#endregion
#endregion";

            File.WriteAllText("Program.cs", content.Replace("\r\n", "\n"));

            var marked = TestUtility.MarkupWithoutSourceInfo("[!code[MyClass](Program.cs#main)]", "Topic.md");

            // assert
            var expected = @"<pre><code name=""MyClass"">static void Main()
{
}
</code></pre>";

            Assert.Equal(expected.Replace("\r\n", "\n"), marked.Html);
        }
コード例 #7
0
        public void XrefTestGeneral()
        {
            //arange
            var content = @"<xref:Microsoft.Build.Tasks>
@Microsoft.Build.Tasks
""@""a[test](link)
@hehe
@""Microsoft.Build.Tasks?text=Tasks""
[link_text](xref:Microsoft.Build.Tasks)
<xref:Microsoft.Build.Tasks#Anchor_1>
<xref href=""Microsoft.Build.Tasks?alt=ImmutableArray""/>
<xref:""Microsoft.Build.Tasks?alt=ImmutableArray"">
<a href=""xref:Microsoft.Build.Tasks?displayProperty=fullName""/>
";
            // act
            var marked = TestUtility.MarkupWithoutSourceInfo(content, "Topic.md");

            // assert
            var expected = @"<p><xref href=""Microsoft.Build.Tasks"" data-throw-if-not-resolved=""True""></xref>
<xref href=""Microsoft.Build.Tasks"" data-throw-if-not-resolved=""False"" data-raw-source=""@Microsoft.Build.Tasks""></xref>
&quot;@&quot;a<a href=""link"">test</a>
<xref href=""hehe"" data-throw-if-not-resolved=""False"" data-raw-source=""@hehe""></xref>
<xref href=""Microsoft.Build.Tasks?text=Tasks"" data-throw-if-not-resolved=""False"" data-raw-source=""@&quot;Microsoft.Build.Tasks?text=Tasks&quot;""></xref>
<a href=""xref:Microsoft.Build.Tasks"">link_text</a>
<xref href=""Microsoft.Build.Tasks#Anchor_1"" data-throw-if-not-resolved=""True""></xref>
<xref href=""Microsoft.Build.Tasks?alt=ImmutableArray""/>
<xref href=""Microsoft.Build.Tasks?alt=ImmutableArray"" data-throw-if-not-resolved=""True""></xref>
<a href=""xref:Microsoft.Build.Tasks?displayProperty=fullName""/></p>
";

            Assert.Equal(expected.Replace("\r\n", "\n"), marked.Html);
        }
コード例 #8
0
ファイル: InclusionTest.cs プロジェクト: xuan2261/docfx
        public void TestInlineLevelInclusion_Block()
        {
            var root = @"
# Hello World

Test Inline Included File: [!include[refa](~/r/a.md)].

";

            var refa = @"## This is a included token

block content in Inline Inclusion.";

            TestUtility.WriteToFile("r/root.md", root);
            TestUtility.WriteToFile("r/a.md", refa);

            var result   = TestUtility.MarkupWithoutSourceInfo(root, "r/root.md");
            var expected = @"<h1 id=""hello-world"">Hello World</h1>
<p>Test Inline Included File: ## This is a included tokenblock content in Inline Inclusion..</p>
";

            Assert.Equal(expected.Replace("\r\n", "\n"), result.Html);

            var dependency         = result.Dependency;
            var expectedDependency = new List <string> {
                "a.md"
            };

            Assert.Equal(expectedDependency.ToImmutableList(), dependency);
        }
コード例 #9
0
ファイル: InclusionTest.cs プロジェクト: smindinvern/docfx
        public void TestImageWithIconTypeBlockSrcResolveInToken()
        {
            // -r
            //  |- r.md
            //  |- b
            //  |  |- token.md
            //  |  |- img.jpg
            var r     = @"
[!include[](b/token.md)]
";
            var token = @"
:::image source=""example.svg"" type=""icon"" alt-text=""example"":::
";

            TestUtility.WriteToFile("r/r.md", r);
            TestUtility.WriteToFile("r/b/token.md", token);
            var marked = TestUtility.MarkupWithoutSourceInfo(r, "r/r.md");

            var expected = @"<div class=""mx-imgBorder""><p>
<img role=""presentation"" src=""~/r/b/example.svg"">
</p></div>
";

            Assert.Equal(expected.Replace("\r\n", "\n"), marked.Html);
        }
コード例 #10
0
ファイル: CodeSnippetTest.cs プロジェクト: DavidSilwal/docfx
        public void TestCodeFenceWithSpaceInFileName()
        {
            var source = @"  [!code-csharp  [  Test Space  ] ( test space in\) link.cs#abc ""title test"" ) ]  ";

            var marked = TestUtility.MarkupWithoutSourceInfo(source, "Topic.md");

            Assert.Equal(@"<!-- BEGIN ERROR CODESNIPPET: Unable to find test space in) link.cs -->[!code-csharp  [  Test Space  ] ( test space in\) link.cs#abc &quot;title test&quot; ) ]<!--END ERROR CODESNIPPET -->", marked.Html);
        }
コード例 #11
0
ファイル: CodeSnippetTest.cs プロジェクト: zikunfan/docfx
        public void TestCodeFenceWithSpaceInFileName()
        {
            var source = @"  [!code-csharp  [  Test Space  ] ( test space in\) link.cs#abc ""title test"" ) ]  ";

            var marked = TestUtility.MarkupWithoutSourceInfo(source, "Topic.md");

            Assert.Equal(@"[!code-csharp  [  Test Space  ] ( test space in\) link.cs#abc &quot;title test&quot; ) ]", marked.Html);
        }
コード例 #12
0
ファイル: CodeSnippetTest.cs プロジェクト: DavidSilwal/docfx
        public void TestCode_ParentFolderNotExist()
        {
            var source   = @"[!code-cs[not exist](not_exist_folder/file.cs)]";
            var expected = "<!-- BEGIN ERROR CODESNIPPET: Unable to find not_exist_folder/file.cs -->[!code-cs[not exist](not_exist_folder/file.cs)]<!--END ERROR CODESNIPPET -->";

            var marked = TestUtility.MarkupWithoutSourceInfo(source, "Topic.md");

            Assert.Equal(expected.Replace("\r\n", "\n"), marked.Html);
        }
コード例 #13
0
ファイル: CodeSnippetTest.cs プロジェクト: zikunfan/docfx
        public void TestCode_ParentFolderNotExist()
        {
            var source   = @"[!code-cs[not exist](not_exist_folder/file.cs)]";
            var expected = "[!code-cs[not exist](not_exist_folder/file.cs)]";

            var marked = TestUtility.MarkupWithoutSourceInfo(source, "Topic.md");

            Assert.Equal(expected.Replace("\r\n", "\n"), marked.Html);
        }
コード例 #14
0
        public void TestInteractiveCode_CodeSnippetSimple()
        {
            var source = @"[!code-azurecli-interactive[](InteractiveCode/sample.code)]";
            var marked = TestUtility.MarkupWithoutSourceInfo(source, "Topic.md");

            Assert.Equal(
                @"<pre><code class=""lang-azurecli"" data-interactive=""azurecli"">hello world!
</code></pre>".Replace("\r\n", "\n"), marked.Html);
        }
コード例 #15
0
ファイル: GeneralTest.cs プロジェクト: wibjorn/docfx
        public void TestDfmTagValidate()
        {
            var result = TestUtility.MarkupWithoutSourceInfo(@"<div><i>x</i><EM>y</EM><h1>z<pre><code>a*b*c</code></pre></h1></div>

<script>alert(1);</script>");

            Assert.Equal(@"<div><i>x</i><EM>y</EM><h1>z<pre><code>a*b*c</code></pre></h1></div>
<script>alert(1);</script>
".Replace("\r\n", "\n"), result.Html);
        }
コード例 #16
0
ファイル: CodeSnippetTest.cs プロジェクト: zikunfan/docfx
        public void CodeSnippetShouldNotWorkInParagragh()
        {
            var marked = TestUtility.MarkupWithoutSourceInfo("text [!code[test](CodeSnippet.cs)]", "Topic.md");

            // assert
            var expected = @"<p>text [!code<a href=""CodeSnippet.cs"">test</a>]</p>
";

            Assert.Equal(expected.Replace("\r\n", "\n"), marked.Html);
        }
コード例 #17
0
ファイル: InclusionTest.cs プロジェクト: xuan2261/docfx
        public void TestBlockLevelInclusion_General()
        {
            var root = @"
# Hello World

Test Include File

[!include[refa](a.md)]

[!include[refa](a.md) ]

";

            var refa = @"---
title: include file
description: include file
---

# Hello Include File A

This is a file A included by another file. [!include[refb](b.md)] [!include[refb](b.md) ]

";

            var refb = @"---
title: include file
description: include file
---

# Hello Include File B
";

            TestUtility.WriteToFile("r/root.md", root);
            TestUtility.WriteToFile("r/a.md", refa);
            TestUtility.WriteToFile("r/b.md", refb);

            var result   = TestUtility.MarkupWithoutSourceInfo(root, "r/root.md");
            var expected = @"<h1 id=""hello-world"">Hello World</h1>
<p>Test Include File</p>
<h1 id=""hello-include-file-a"">Hello Include File A</h1>
<p>This is a file A included by another file. # Hello Include File B [!include<a href=""%7E/r/b.md"">refb</a> ]</p>

<p>[!include<a href=""a.md"">refa</a> ]</p>
";

            Assert.Equal(expected.Replace("\r\n", "\n"), result.Html);

            var dependency         = result.Dependency;
            var expectedDependency = new List <string> {
                "a.md", "b.md"
            };

            Assert.Equal(expectedDependency.ToImmutableList(), dependency);
        }
コード例 #18
0
        public void TestInteractiveCode_FencedCodeSimple()
        {
            var source = @"```csharp-interactive
test
```";
            var marked = TestUtility.MarkupWithoutSourceInfo(source, "Topic.md");

            Assert.Equal(
                @"<pre><code class=""lang-csharp"" data-interactive=""csharp"">test
</code></pre>
".Replace("\r\n", "\n"), marked.Html);
        }
コード例 #19
0
ファイル: CodeSnippetTest.cs プロジェクト: zikunfan/docfx
        public void CodeSnippetTagsShouldMatchCaseInsensitive()
        {
            //arange
            var content = "\t// <tag1>\t\nline1\n// <tag2>\nline2\n// </tag2>\nline3\n// </TAG1>\n// <unmatched>\n";

            File.WriteAllText("Program.cs", content.Replace("\r\n", "\n"));

            var marked = TestUtility.MarkupWithoutSourceInfo("[!code[tag1](Program.cs#Tag1)]", "Topic.md");

            // assert
            var expected = "<pre><code name=\"tag1\">line1\nline2\nline3\n</code></pre>";

            Assert.Equal(expected.Replace("\r\n", "\n"), marked.Html);
        }
コード例 #20
0
ファイル: InclusionTest.cs プロジェクト: xuan2261/docfx
        public void TestBlockLevelInclusion_CycleInclude()
        {
            var root = @"
# Hello World

Test Include File

[!include[refa](a.md)]

";

            var refa = @"
# Hello Include File A

This is a file A included by another file.

[!include[refb](b.md)]

";

            var refb = @"
# Hello Include File B

[!include[refa](a.md)]
";

            TestUtility.WriteToFile("r/root.md", root);
            TestUtility.WriteToFile("r/a.md", refa);
            TestUtility.WriteToFile("r/b.md", refb);

            var listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter("CircularReferenceTest");

            Logger.RegisterListener(listener);
            using (new LoggerPhaseScope("CircularReferenceTest"))
            {
                var result   = TestUtility.MarkupWithoutSourceInfo(root, "r/root.md");
                var expected = @"<h1 id=""hello-world"">Hello World</h1>
<p>Test Include File</p>
<h1 id=""hello-include-file-a"">Hello Include File A</h1>
<p>This is a file A included by another file.</p>
<h1 id=""hello-include-file-b"">Hello Include File B</h1>
[!include[refa](a.md)]";

                Assert.Equal(expected.Replace("\r\n", "\n"), result.Html);
            }
            Logger.UnregisterListener(listener);
            Assert.Collection(listener.Items, log => Assert.Equal(
                                  "Build has identified file(s) referencing each other: 'r/root.md' --> '~/r/a.md' --> '~/r/b.md' --> '~/r/a.md'",
                                  log.Message));
        }
コード例 #21
0
        public void ChromelessFormsAttributeValueRequired()
        {
            var content  = @"::: form submitText :::";
            var listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter(LoggerPhase);

            Logger.RegisterListener(listener);
            using (new LoggerPhaseScope(LoggerPhase))
            {
                TestUtility.MarkupWithoutSourceInfo(content);
            }
            Logger.UnregisterListener(listener);

            // Listener should have an error message and not output.
            Assert.NotEmpty(listener.Items.Where(x => x.Code == "invalid-form"));
        }
コード例 #22
0
ファイル: InclusionTest.cs プロジェクト: xuan2261/docfx
        public void TestBlockLevelInclusionWithWorkingFolder()
        {
            // -r
            //  |- root.md
            //  |- b
            //  |  |- linkAndRefRoot.md
            var root           = @"[!include[linkAndRefRoot](~/r/b/linkAndRefRoot.md)]";
            var linkAndRefRoot = @"Paragraph1";

            TestUtility.WriteToFile("r/root.md", root);
            TestUtility.WriteToFile("r/b/linkAndRefRoot.md", linkAndRefRoot);
            var marked   = TestUtility.MarkupWithoutSourceInfo(root, "r/root.md");
            var expected = @"<p>Paragraph1</p>" + "\n";

            Assert.Equal(expected, marked.Html);
        }
コード例 #23
0
ファイル: XrefTest.cs プロジェクト: carolinesena/docfx-1
        public void XrefTestGeneral()
        {
            //arange
            var content = @"<xref:Microsoft.Build.Tasks>
\<xref:Microsoft.Build.Tasks>
\\<xref:Microsoft.Build.Tasks>
@Microsoft.Build.Tasks
""@""a[test](link)
@hehe

![img @hehe a](src ""title @hehe b"")
![img @hehe a
![img @hehe a](src ""title @hehe b""
![this **img @hehe a** haha](src ""title @hehe b"")

@""Microsoft.Build.Tasks?text=Tasks""
[link_text](xref:Microsoft.Build.Tasks)
<xref:Microsoft.Build.Tasks#Anchor_1>
<xref href=""Microsoft.Build.Tasks?alt=ImmutableArray""/>
<xref:""Microsoft.Build.Tasks?alt=ImmutableArray"">
<a href=""xref:Microsoft.Build.Tasks?displayProperty=fullName""/>
";
            // act
            var marked = TestUtility.MarkupWithoutSourceInfo(content, "Topic.md");

            // assert
            var expected = @"<p><xref href=""Microsoft.Build.Tasks"" data-throw-if-not-resolved=""True"" data-raw-source=""&lt;xref:Microsoft.Build.Tasks&gt;""></xref>
&lt;xref:Microsoft.Build.Tasks&gt;
\<xref href=""Microsoft.Build.Tasks"" data-throw-if-not-resolved=""True"" data-raw-source=""&lt;xref:Microsoft.Build.Tasks&gt;""></xref>
<xref href=""Microsoft.Build.Tasks"" data-throw-if-not-resolved=""False"" data-raw-source=""@Microsoft.Build.Tasks""></xref>
&quot;@&quot;a<a href=""link"">test</a>
<xref href=""hehe"" data-throw-if-not-resolved=""False"" data-raw-source=""@hehe""></xref></p>
<p><img src=""src"" alt=""img @hehe a"" title=""title @hehe b"" />
![img <xref href=""hehe"" data-throw-if-not-resolved=""False"" data-raw-source=""@hehe""></xref> a
![img <xref href=""hehe"" data-throw-if-not-resolved=""False"" data-raw-source=""@hehe""></xref> a](src &quot;title <xref href=""hehe"" data-throw-if-not-resolved=""False"" data-raw-source=""@hehe""></xref> b&quot;
<img src=""src"" alt=""this img @hehe a haha"" title=""title @hehe b"" /></p>
<p><xref href=""Microsoft.Build.Tasks?text=Tasks"" data-throw-if-not-resolved=""False"" data-raw-source=""@&quot;Microsoft.Build.Tasks?text=Tasks&quot;""></xref>
<a href=""xref:Microsoft.Build.Tasks"">link_text</a>
<xref href=""Microsoft.Build.Tasks#Anchor_1"" data-throw-if-not-resolved=""True"" data-raw-source=""&lt;xref:Microsoft.Build.Tasks#Anchor_1&gt;""></xref>
<xref href=""Microsoft.Build.Tasks?alt=ImmutableArray""/>
<xref href=""Microsoft.Build.Tasks?alt=ImmutableArray"" data-throw-if-not-resolved=""True"" data-raw-source=""&lt;xref:&quot;Microsoft.Build.Tasks?alt=ImmutableArray&quot;&gt;""></xref>
<a href=""xref:Microsoft.Build.Tasks?displayProperty=fullName""/></p>
";

            Assert.Equal(expected.Replace("\r\n", "\n"), marked.Html);
        }
コード例 #24
0
ファイル: CodeSnippetTest.cs プロジェクト: zikunfan/docfx
        public void CodeSnippetGeneral()
        {
            //arange
            var content = @"    line for start & end
    // <tag1>
    line1
    // </tag1>
" + " \tline for indent & range";

            File.WriteAllText("Program.cs", content.Replace("\r\n", "\n"));

            var marked = TestUtility.MarkupWithoutSourceInfo("[!code-csharp[name](Program.cs?start=1&end=1&name=tag&range=5-&highlight=1,2-2,4-&dedent=3#tag1)]", "Topic.md");

            // assert
            var expected = @"<pre><code class=""lang-csharp"" name=""name"" highlight-lines=""1,2,4-""> line1
</code></pre>";

            Assert.Equal(expected.Replace("\r\n", "\n"), marked.Html);
        }
コード例 #25
0
ファイル: InclusionTest.cs プロジェクト: xuan2261/docfx
        public void ImageTestBlockGeneralWithInclude()
        {
            var source         = @"[!include[](includes/source.md)]";
            var includeContent = @":::image type=""content"" source=""../media/example.jpg"" alt-text=""example"" lightbox=""../media/example.jpg"":::

:::image type=""content"" source=""~/media/example.jpg"" alt-text=""example"" lightbox=""~/media/example.jpg"":::

:::image type=""content"" source=""~/media/example.jpg"" alt-text=""example"" lightbox=""../media/example.jpg"":::

:::image type=""content"" source=""../media/example.jpg"" alt-text=""example"" lightbox=""~/media/example.jpg"":::";

            TestUtility.WriteToFile("a.md", source);
            TestUtility.WriteToFile("includes/source.md", includeContent);
            var marked = TestUtility.MarkupWithoutSourceInfo(source, "a.md");

            var expected = @"<p><span class=""mx-imgBorder"">
<a href=""~/media/example.jpg#lightbox"" data-linktype=""relative-path"">
<img src=""~/media/example.jpg"" alt=""example"">
</a>
</span>
</p>
<p><span class=""mx-imgBorder"">
<a href=""~/media/example.jpg#lightbox"" data-linktype=""relative-path"">
<img src=""~/media/example.jpg"" alt=""example"">
</a>
</span>
</p>
<p><span class=""mx-imgBorder"">
<a href=""~/media/example.jpg#lightbox"" data-linktype=""relative-path"">
<img src=""~/media/example.jpg"" alt=""example"">
</a>
</span>
</p>
<p><span class=""mx-imgBorder"">
<a href=""~/media/example.jpg#lightbox"" data-linktype=""relative-path"">
<img src=""~/media/example.jpg"" alt=""example"">
</a>
</span>
</p>
";

            Assert.Equal(expected.Replace("\r\n", "\n").Replace("\n", ""), marked.Html.Replace("\r\n", "\n").Replace("\n", ""));
        }
コード例 #26
0
ファイル: RenderZoneTest.cs プロジェクト: zikunfan/docfx
        public void NoOverlap()
        {
            //arange
            var content = @"::: zone target=""chromeless""
::: moniker range=""start""
::: zone-end
::: moniker-end
";

            var listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter(LoggerPhase);

            Logger.RegisterListener(listener);
            using (new LoggerPhaseScope(LoggerPhase))
            {
                TestUtility.MarkupWithoutSourceInfo(content);
            }
            Logger.UnregisterListener(listener);

            Assert.Equal("Invalid zone on line 0.  A zone cannot end before blocks nested within it have ended.", listener.Items.First(x => x.Code == "invalid-zone").Message);
        }
コード例 #27
0
        public void TestInteractiveCode_FencedCodeNonInteractiveSimple()
        {
            var source0 = @"```csharp
test
```";
            var source1 = @"```
test
```";
            var marked0 = TestUtility.MarkupWithoutSourceInfo(source0, "Topic.md");
            var marked1 = TestUtility.MarkupWithoutSourceInfo(source1, "Topic.md");

            Assert.Equal(
                @"<pre><code class=""lang-csharp"">test
</code></pre>
".Replace("\r\n", "\n"), marked0.Html);

            Assert.Equal(
                @"<pre><code>test
</code></pre>
".Replace("\r\n", "\n"), marked1.Html);
        }
コード例 #28
0
ファイル: InclusionTest.cs プロジェクト: yuzuruqyhe/docfx
        public void TestInlineLevelInclusion_CycleInclude()
        {
            var root = @"
# Hello World

Test Inline Included File: [!include[refa](~/r/a.md)].

";

            var refa = "This is a **included** token with [!include[root](~/r/root.md)]";

            TestUtility.WriteToFile("r/root.md", root);
            TestUtility.WriteToFile("r/a.md", refa);

            var result   = TestUtility.MarkupWithoutSourceInfo(root, "r/root.md");
            var expected = @"<h1 id=""hello-world"">Hello World</h1>
<p>Test Inline Included File: This is a <strong>included</strong> token with <!-- BEGIN ERROR INCLUDE: Unable to resolve [!include[root](~/r/root.md)]: Circular dependency found in &quot;r/a.md&quot; -->[!include[root](~/r/root.md)]<!--END ERROR INCLUDE -->.</p>
";

            Assert.Equal(expected.Replace("\r\n", "\n"), result.Html);
        }
コード例 #29
0
ファイル: RenderZoneTest.cs プロジェクト: zikunfan/docfx
        public void NotNested()
        {
            //arange
            var content = @"::: zone target=""chromeless""
::: zone target=""pdf""
::: zone-end
::: zone-end
";

            var listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter(LoggerPhase);

            Logger.RegisterListener(listener);
            using (new LoggerPhaseScope(LoggerPhase))
            {
                TestUtility.MarkupWithoutSourceInfo(content);
            }
            Logger.UnregisterListener(listener);

            Assert.Single(listener.Items);
            Assert.Equal("Invalid zone on line 1. \"::: zone target=\"chromeless\"\r\n::: zone target=\"pdf\"\r\n::: zone-end\r\n::: zone-end\r\n\" is invalid. Zones cannot be nested.", listener.Items[0].Message);
        }
コード例 #30
0
ファイル: InclusionTest.cs プロジェクト: xuan2261/docfx
        public void TestInlineLevelInclusion_CycleInclude()
        {
            var root = @"
# Hello World

Test Inline Included File: [!include[refa](~/r/a.md)].

";

            var refa = "This is a **included** token with [!include[root](~/r/root.md)]";

            TestUtility.WriteToFile("r/root.md", root);
            TestUtility.WriteToFile("r/a.md", refa);

            var result   = TestUtility.MarkupWithoutSourceInfo(root, "r/root.md");
            var expected = @"<h1 id=""hello-world"">Hello World</h1>
<p>Test Inline Included File: This is a <strong>included</strong> token with [!include[root](~/r/root.md)].</p>
";

            Assert.Equal(expected.Replace("\r\n", "\n"), result.Html);
        }