public void TestOpenTagParser() { OpenTagParser parser = null; // try { parser = new OpenTagParser("@item", "xxx"); Assert.Fail(); } catch { } // parser = new OpenTagParser("@item", "<@item>"); Assert.AreEqual(0, parser.Attributes.Count); // parser = new OpenTagParser("@item", "<@item >"); Assert.AreEqual(0, parser.Attributes.Count); // parser = new OpenTagParser("@item", "<@item >"); Assert.AreEqual(0, parser.Attributes.Count); // parser = new OpenTagParser("@item", "<@item title=abc >"); Assert.AreEqual(1, parser.Attributes.Count); Assert.AreEqual("abc", parser.Attributes["title"]); // parser = new OpenTagParser("@item", "<@item title=\"abc\">"); Assert.AreEqual(1, parser.Attributes.Count); Assert.AreEqual("abc", parser.Attributes["title"]); // parser = new OpenTagParser("@item", "<@item title=\'abc\'>"); Assert.AreEqual(1, parser.Attributes.Count); Assert.AreEqual("abc", parser.TryGetAttribute("title")); Assert.AreEqual(null, parser.TryGetAttribute("title2")); }
private string doReplace(string openTag, string content, string closeTag) { if (!Globals.OutSettings.DevOutMode) { if (content.IndexOf("!!!!") >= 0) return string.Empty; } // OpenTagParser openTagParser = new OpenTagParser("@item", openTag); string title = openTagParser.TryGetAttribute("title"); if (string.IsNullOrEmpty(title)) title = "Untitled"; string _class = openTagParser.TryGetAttribute("class"); string _id = openTagParser.TryGetAttribute("id"); // StringBuilder sb = new StringBuilder(); // sb.AppendLine("<dt>"); SignatureParser signatureParser = new SignatureParser(title); sb.AppendLine(signatureParser.CalcHtmlH4(_class, _id)); sb.AppendLine("</dt>"); // sb.AppendLine("<dd>"); sb.AppendLine(content); sb.AppendLine("</dd>"); // return sb.ToString(); }
private string doReplace(string openTag, string content, string closeTag) { if (!Globals.OutSettings.DevOutMode) { if (CommentsChecker.IsStringEmptyOrComments(content)) return string.Empty; } // OpenTagParser openTagParser = new OpenTagParser("@section", openTag); // string title = openTagParser.TryGetAttribute("title"); if (string.IsNullOrEmpty(title)) title = "Untitled"; // string id_text = ""; string id = openTagParser.TryGetAttribute("id"); if (!string.IsNullOrEmpty(id)) id_text = " id=\"" + id + "\""; // // StringBuilder sb = new StringBuilder(); // sb.AppendLine(""); sb.AppendLine("<h3 class=\"subsection-title\"" + id_text + ">" + title + "</h3>"); // "Methods": <h3 class="subsection-title">Features</h3> sb.AppendLine("<dl class=\"doc-section\">"); // sb.AppendLine(content); // sb.AppendLine("</dl>"); // return sb.ToString(); }
private string doReplace(string openTag, string content, string closeTag) { if (!Globals.OutSettings.DevOutMode) { if (CommentsChecker.IsStringEmptyOrComments(content)) return string.Empty; } // OpenTagParser openTagParser = new OpenTagParser("@overloads", openTag); string title = openTagParser.TryGetAttribute("title"); if (string.IsNullOrEmpty(title)) title = "Untitled"; // SignatureParser signatureParser = new SignatureParser(title); // StringBuilder sb = new StringBuilder(); // sb.AppendLine(""); sb.AppendLine("<dt>"); sb.AppendLine(" <h4 id=\"" + signatureParser.CalcId() + "__\" >" + title + "...</h4>"); // "fields()": <h4 id="fields__" >fields()...</h4> sb.AppendLine("</dt>"); sb.AppendLine("<dd>"); sb.AppendLine(" <dl>"); // sb.AppendLine(content); // sb.AppendLine(" </dl>"); sb.AppendLine("</dd>"); // return sb.ToString(); }
private string doReplace(string openTag, string content, string closeTag) { OpenTagParser openTagParser = new OpenTagParser("@codeblock", openTag); string src = openTagParser.TryGetAttribute("src"); if (string.IsNullOrEmpty(src)) src = null; // StringBuilder sb = new StringBuilder(); sb.AppendLine("<div>"); // if (src != null) { TestSourceLoader testSourceLoader = new TestSourceLoader(src); // string labelText = testSourceLoader.State.ToString(); if (testSourceLoader.State == TestSourceLoader.TestState.Passed) labelText = "√ " + labelText; // string stateClass = ""; string labelClass = "label-ok"; string problemId = ""; if (testSourceLoader.State != TestSourceLoader.TestState.Passed) { stateClass = " testerror"; labelClass = "label-problem"; problemId = string.Format("id=\"{0}\"", this.calcExampleProblemId(this.exampleProblemsCount++)); } // //sb.AppendLine("<div class=\"example-wrapper" + stateClass + "\">"); sb.AppendLine(string.Format("<div {0} class=\"example-wrapper{1}\">", problemId, stateClass)); sb.AppendLine(string.Format("<p class=\"example-label {0}\" title=\"{2}\">{1}</p>\r\n", labelClass, labelText, "The code unit test state")); sb.Append("<pre class=\"prettyprint\"><code>"); sb.Append(this.processContent(testSourceLoader.Text)); sb.Append("</code></pre>"); sb.AppendLine("</div>"); } // if (content != null) { sb.AppendLine("<div class=\"example-wrapper staticcode\">"); sb.AppendLine("<p class=\"example-label label-static\" title=\"This code is not checked by unit testing system\">Static code</p>\r\n"); sb.Append("<pre class=\"prettyprint\"><code>"); sb.Append(this.processContent(content)); sb.Append("</code></pre>"); sb.AppendLine("</div>"); } // // sb.AppendLine("</div>"); return sb.ToString(); }
public void TestCodeblockSrc2() { OpenTagParser parser = new OpenTagParser("@codeblock", "<@codeblock src=\"/z_core/data-object/Data_Object.spec.js:dobj() - Data_Object\" />"); string src = parser.TryGetAttribute("src"); Assert.AreEqual(src, "/z_core/data-object/Data_Object.spec.js:dobj() - Data_Object"); }