public void TestInlineElementWithChar() { var inlineElement = new MarkdownText("Inline element"); Assert.Equal('*', new MarkdownEmphasis(inlineElement, '*').Char); Assert.Equal('_', new MarkdownEmphasis(inlineElement, '_').Char); }
public NoteEditor() { InitializeComponent(); //CommandBindings.Add(new CommandBinding(ApplicationCommands.Save, SaveNote)); CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, CloseEditor)); InsertAsImgCommand = new NoteFileCommand(InsertNoteFileAsImg); InsertAsMdCommand = new NoteFileCommand(InsertNoteFileAsMd); _messageClearTimer = new DispatcherTimer(); _messageClearTimer.Tick += ClearMessage; _messageClearTimer.Interval = TimeSpan.FromMilliseconds(2500); _documentEntitiys = new List <DocumentEntitiy>(); var documentEntitiesTimer = new DispatcherTimer(); documentEntitiesTimer.Tick += UpdateDocumentEntities; documentEntitiesTimer.Interval = TimeSpan.FromMilliseconds(1000); documentEntitiesTimer.Start(); Closing += NoteEditorClosing; MarkdownText.Focus(); }
private MarkdownFile GenerateTableOfContents(DotNetDocumentationFile xmlDocumentation, DotNetQualifiedClassNameTreeNode node) { List <DotNetType> types = xmlDocumentation.Types.Where(t => t.Name.FullNamespace == node.Value).ToList(); List <DotNetDelegate> _delegates = xmlDocumentation.Delegates.Where(d => d.Name.FullNamespace == node.Value).ToList(); MarkdownFile markdown = new MarkdownFile(); string header = "Contents of " + node.Value.FullName; if (node.Parent != null) { header = String.Format("Contents of [{0}]({1}).{2}", node.Parent.Value.FullName, TableOfContentsFilename(node.Parent.Value), node.Value.LocalName); } MarkdownSection section = markdown.AddSection(header); if (node.Children.Count > 0) { MarkdownSection childNamespacesSection = section.AddSection("Namespaces"); foreach (DotNetQualifiedClassNameTreeNode child in node.Children) { section.AddInLine(new MarkdownInlineLink(MarkdownText.Bold(child.Value.FullName), TableOfContentsFilename(child.Value))); } } AddTableOfContentsSection(section, "Concrete Types", types.Where(t => t.Category == TypeCategory.Normal).ToList()); AddTableOfContentsSection(section, "Static Types", types.Where(t => t.Category == TypeCategory.Static).ToList()); AddTableOfContentsSection(section, "Abstract Types", types.Where(t => t.Category == TypeCategory.Abstract).ToList()); AddTableOfContentsSection(section, "Interfaces", types.Where(t => t.Category == TypeCategory.Interface).ToList()); AddTableOfContentsSection(section, "Enums", types.Where(t => t.Category == TypeCategory.Enum).ToList()); AddTableOfContentsSection(section, "Structs", types.Where(t => t.Category == TypeCategory.Struct).ToList()); AddTableOfContentsSection(section, "Delegates", _delegates); AddTableOfContentsSection(section, "Exceptions", types.Where(t => t.Category == TypeCategory.Exception).ToList()); return(markdown); }
public void TestDefaultTextAlignment() { var inlineElement = new MarkdownText("Inline element"); Assert.Equal(MarkdownTableTextAlignment.Default, new MarkdownTableHeaderCell("Text").ColumnTextAlignment); Assert.Equal(MarkdownTableTextAlignment.Default, new MarkdownTableHeaderCell(inlineElement).ColumnTextAlignment); }
private void HandleBackTab(KeyEventArgs e, int lineIndex, int tabSize) { var line = MarkdownText.GetLineText(lineIndex); int spaceCount = line.TakeWhile(Char.IsWhiteSpace).Count(); if (spaceCount == 0) { e.Handled = true; return; } int spacesToTrim; if (spaceCount == tabSize || spaceCount % tabSize == 0) { spacesToTrim = tabSize; } else { spacesToTrim = (int)Math.IEEERemainder(spaceCount, tabSize); } int oldPos = MarkdownText.CaretIndex; MarkdownText.SelectionStart = MarkdownText.GetCharacterIndexFromLineIndex(lineIndex); MarkdownText.SelectionLength = spacesToTrim; MarkdownText.SelectedText = string.Empty; MarkdownText.CaretIndex = oldPos - spacesToTrim; e.Handled = true; }
public void TestToString() { var text = new MarkdownText("Markdown"); text.Append(" Builder "); text.Append(new MarkdownEmoji("thumbsup")); Assert.Equal("Markdown Builder :thumbsup:", text.ToString()); }
internal static MarkdownText ToMDText(DotNetCommentParameterLink comment) { if (comment == null) { return(new MarkdownText("")); } return(MarkdownText.Italic(comment.Name)); }
public void MarkdownText_EscapeCloseAngleBracket() { //arrange MarkdownText text = new MarkdownText("a>a"); //act string result = text.ToMarkdownString(null); //assert Assert.AreEqual("a>a", result); }
public void MarkdownText_EscapeBacktics() { //arrange MarkdownText text = new MarkdownText("a`a"); //act string result = text.ToMarkdownString(null); //assert Assert.AreEqual("a`a", result); }
private void RemoveLine(int lineIndex) { List <string> lines = new List <string>(MarkdownText.Text.Split('\n')); lines.RemoveAt(lineIndex); int carretPosition = MarkdownText.GetCharacterIndexFromLineIndex(lineIndex); MarkdownText.Text = string.Join("\n", lines.ToArray()); MarkdownText.CaretIndex = carretPosition; }
private void HandleTab(KeyEventArgs e, int lineIndex, int tabSize) { int oldIndex = MarkdownText.CaretIndex; MarkdownText.CaretIndex = MarkdownText.GetCharacterIndexFromLineIndex(lineIndex); MarkdownText.SelectionLength = 0; MarkdownText.SelectedText = new string(' ', tabSize); MarkdownText.CaretIndex = oldIndex + tabSize; e.Handled = true; }
public void MarkdownList_Add_InLine() { //arrange MarkdownList list = new MarkdownList(); MarkdownText text = new MarkdownText("abc"); //act list.Add(text as IMarkdownInLine); //assert Assert.AreEqual(1, list.Length); Assert.IsNotNull(list[0]); }
private List <Block> ShopItemSection(Item item, string shopId) { var textBlock = new MarkdownText($"{item.Icon} *{item.Name}*"); var buttonBlock = new Button(string.Format(DougMessages.BuyFor, _governmentService.GetPriceWithTaxes(item)), item.Id, Actions.Buy.ToString()); var shopItem = new List <Block> { new Section(textBlock, buttonBlock, $"{shopId}:{item.Id}") }; return(shopItem); }
private Block StatSection(string message, int stat, string type, bool buttonDisplayed) { var textBlock = new MarkdownText(string.Format(message, stat)); if (!buttonDisplayed) { return(new Section(textBlock)); } var buttonBlock = new Button(DougMessages.AddStatPoint, type, Actions.Attribution.ToString()); return(new Section(textBlock, buttonBlock)); }
public CraftingMenu(IEnumerable <InventoryItem> items) { var options = items.Select(item => new Option($"{item.Item.Icon} {item.Item.Name}", item.InventoryPosition.ToString())).ToList(); var accessory = new MultiSelect(options, new PlainText(DougMessages.CraftingSelect), Actions.Craft.ToString()); var text = new MarkdownText(DougMessages.CraftingDialog); Blocks = new List <Block> { CraftingHeader(), new Divider(), new Section(text, accessory) }; }
public void MarkdownSection_ToMarkdown_TextThenSection() { //arrange MarkdownSection sectionA = new MarkdownSection("A"); MarkdownText text = new MarkdownText("Text"); sectionA.Add(text); MarkdownSection sectionB = sectionA.AddSection("B"); //act string result = sectionA.ToMarkdownString(); //assert Assert.AreEqual("# A\n\nText\n\n## B\n\n", result); }
public MonsterMenu(SpawnedMonster spawnedMonster) { var monster = spawnedMonster.Monster; var monsterText = new MarkdownText($"*{monster.Name}* `lvl {monster.Level}` \n *{monster.Health}*/{monster.MaxHealth} \n {monster.Description}"); var monsterDescription = new Section(monsterText, new Image(monster.Image, monster.Name)); Blocks = new List <Block> { monsterDescription, new ActionList(new List <Accessory> { new Button(DougMessages.AttackAction, spawnedMonster.Id.ToString(), Actions.Attack.ToString()) }) }; }
private void StripHtmlButtonClick(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(MarkdownText.SelectedText)) { MarkdownText.SelectAll(); } var textToStrip = MarkdownText.SelectedText; const string acceptable = "img|a"; const string stringPattern = @"</?(?(?=" + acceptable + @")notag|[a-zA-Z0-9]+)(?:\s[a-zA-Z0-9\-]+=?(?:(["",']?).*?\1?)?)*\s*/?>"; string result = Regex.Replace(textToStrip, stringPattern, string.Empty); MarkdownText.SelectedText = result; }
private void AddTableOfContentsSection(MarkdownSection parent, string header, List <DotNetDelegate> _delegates) { if (_delegates.Count == 0) { return; } MarkdownSection section = parent.AddSection(header); foreach (DotNetDelegate _delegate in _delegates.OrderBy(t => t.Name.LocalName)) { section.AddInLine(new MarkdownInlineLink(MarkdownText.Bold(_delegate.Name.LocalName), FormatFilename(_delegate.Name.FullName + Ext.MD))); section.Add(ConvertDotNet.DotNetCommentGroupToMarkdown(_delegate.SummaryComments, _delegate)); section.Add(new MarkdownLine()); } }
private List <Block> ItemSection(EquipmentItem equipment, string slot) { var textBlock = new MarkdownText($"{slot} : *Empty*"); var section = new Section(textBlock); if (equipment != null) { textBlock = new MarkdownText($"{slot} : {equipment.Icon} *{equipment.Name}*"); var itemOptions = ItemActionsAccessory(equipment.Slot); section = new Section(textBlock, itemOptions); } return(new List <Block> { section, new Divider() }); }
private List <Block> ShopItemSection(Item item, string shopId) { var textBlock = new MarkdownText($"{item.Icon} *{item.Name}*"); var buttonBlock = new Button(string.Format(DougMessages.BuyFor, _governmentService.GetPriceWithTaxes(item)), item.Id, Actions.Buy.ToString()); var shopItem = new List <Block> { new Section(textBlock, buttonBlock, $"{shopId}:{item.Id}") }; if (item is EquipmentItem equipmentItem) { var attributes = equipmentItem.GetDisplayAttributeList(); shopItem.Add(new Context(attributes)); } return(shopItem); }
private void MarkdownText_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter && Keyboard.Modifiers == ModifierKeys.None) { int lineIndex = MarkdownText.GetLineIndexFromCharacterIndex(MarkdownText.CaretIndex); if (lineIndex < 0) { return; } string line = MarkdownText.GetLineText(lineIndex); string lineTextTrim = line.Trim(); if (lineTextTrim.Equals("- [ ]") || lineTextTrim.Equals("-")) { RemoveLine(lineIndex); return; } string lineTextTrimStart = line.TrimStart(); int leadingWhitespaces = line.Length - lineTextTrimStart.Length; string whiteSpaces = string.Empty; if (leadingWhitespaces > 0) { whiteSpaces = new string(' ', leadingWhitespaces); } string stringToInsert = null; if (lineTextTrimStart.StartsWith("- [")) { stringToInsert = "- [ ] "; } else if (lineTextTrimStart.StartsWith("- ")) { stringToInsert = "- "; } if (stringToInsert != null) { InsertAt("\n" + whiteSpaces + stringToInsert, MarkdownText.CaretIndex); e.Handled = true; } } }
private List <Block> ItemSection(InventoryItem item) { var quantity = item.Quantity == 1 ? string.Empty : $"`×{item.Quantity}`"; var textBlock = new MarkdownText($"{item.Item.Icon} *{item.Item.Name}* {quantity} \n {item.Item.Description}"); var itemOptions = ItemActionsAccessory(item.InventoryPosition, item.Item.Price / 2); var blocks = new List <Block> { new Section(textBlock, itemOptions) }; if (item.Item is EquipmentItem equipmentItem) { var attributes = equipmentItem.GetDisplayAttributeList(); blocks.Add(new Context(attributes)); } blocks.Add(new Divider()); return(blocks); }
private void MarkdownText_KeyUp(object sender, KeyEventArgs e) { const int tabSize = 4; var lineIndex = MarkdownText.GetLineIndexFromCharacterIndex(MarkdownText.CaretIndex); if (lineIndex < 0) { return; } if (e.Key == Key.Enter && Keyboard.Modifiers == ModifierKeys.None) { HandleListLineBreak(e, lineIndex); } else if (e.Key == Key.Tab && Keyboard.Modifiers == ModifierKeys.Shift) { HandleBackTab(e, lineIndex, tabSize); } else if (e.Key == Key.Tab) { HandleTab(e, lineIndex, tabSize); } }
private void HandleListLineBreak(KeyEventArgs e, int lineIndex) { var line = MarkdownText.GetLineText(lineIndex); int spaceCount = line.TakeWhile(Char.IsWhiteSpace).Count(); var lineTextTrim = line.Trim(); if (lineTextTrim.Equals("- [ ]") || lineTextTrim.Equals("-")) { RemoveLine(lineIndex); return; } var lineTextTrimStart = line.TrimStart(); var whiteSpaces = string.Empty; if (spaceCount > 0) { whiteSpaces = new string(' ', spaceCount); } string stringToInsert = null; if (lineTextTrimStart.StartsWith("- [")) { stringToInsert = "- [ ] "; } else if (lineTextTrimStart.StartsWith("- ")) { stringToInsert = "- "; } if (stringToInsert != null) { InsertAt("\n" + whiteSpaces + stringToInsert, MarkdownText.CaretIndex); e.Handled = true; } }
public void TestInlineElement() { var inlineElement = new MarkdownText("Inline element"); Assert.Equal("Inline element", new MarkdownParagraph(inlineElement).Text); }
/// <summary> /// Creates a string that the maple client will interpret as having the given /// </summary> /// <param name="mod"></param> /// <param name="sMsg"></param> /// <returns></returns> public static string Text(MarkdownText mod, string sMsg, bool bBold = false) => $"{(bBold ? $"#{MarkdownText.Bold}" : "")}#{mod}{sMsg}#{MarkdownText.Black}#{MarkdownText.Normal}";
public void TestInlineELement() { var inlineElement = new MarkdownText("Inline element"); Assert.Equal("Inline element", new MarkdownTableHeaderCell(inlineElement).Text); }
public void TestInlineElement() { var inlineElement = new MarkdownText("Inline element"); Assert.Equal("Inline element", new MarkdownStrongEmphasis(inlineElement).Text); }
public void TestInlineElement() { var inlineElement = new MarkdownText("Inline element"); Assert.Equal("Inline element", new MarkdownLink(inlineElement, "url").Text); }