private static async Task DoFile(DocumentContext context, RelativeFile file) { if (file.Source.Extension != "md") { return; } Console.Error.WriteLine($"Working on {file.Source.FullPath}"); var text = await file.Read(); var doc = MarkdownFactory.Parse(text); doc.ApplyD2LTweaks(); var html = MarkdownFactory.RenderToString(doc, context); var renderer = TemplateRenderer.CreateFromResource("Templates.page.html"); var formatted = await renderer.RenderAsync( title : GetTitle(doc), content : html, editLink : file.EditSourceLink ); await file.Write(formatted); CopyAssociatedFiles(doc, context, file.Source.Path); }
public void StaticRender(string fileName) { var source = _files.LoadDestinationFile(Path.Combine(_files.DestinationPath, _folder, fileName)); var renderer = new DocumentRenderer(nameof(RendererTest), _shell.Services); var document = MarkdownFactory.ParseToMarkdown(source); var actual = renderer.RenderStaticHtml(document); CompareToBaseline(fileName, actual); }
protected override bool IsEnabled() { var start = _view.Caret.ContainingTextViewLine.Start; var length = _view.Caret.ContainingTextViewLine.Length; _span = new SnapshotSpan(_view.TextBuffer.CurrentSnapshot, start, length); var text = _span.GetText(); return(MarkdownFactory.MatchSmartBlock(text)); }
public static DocumentLocation Build(string fileName, IVsTextView textView, int line, int col) { string text = GetTextUpToLine(textView, line); MarkdownDocument markdownDocument = MarkdownFactory.ParseToMarkdown(text); LinkInline link = FindLinkAtPos(markdownDocument, col, line); var location = new DocumentLocation { _link = link, _fileName = fileName }; location.Build(); return location; }
static void Main(string[] args) { string[] commands; var list = File.ReadAllText("CreateDocumentScript.txt"); commands = list.Split('#'); foreach (var command in commands) { var strippedCommand = Regex.Replace(command, @"\t|\n|\r", ""); var commandList = strippedCommand.Split(':'); switch (commandList[0]) { case "Document": // Your document creation code goes here string[] fileName = commandList[1].Split(';'); if (fileName[0] == "Markdown") { //fileNameArray[1] == fileName factory = MarkdownFactory.CreateInstance(); document = factory.CreateDocument(fileName[1]); Console.WriteLine(fileName[1]); } else if (fileName[0] == "Html") { factory = HTMLFactory.CreateInstance(); document = factory.CreateDocument(fileName[1]); Console.WriteLine(fileName[1]); } break; case "Element": // Your element creation code goes here document.AddElement(factory.CreateElement(commandList[1], commandList[2])); break; case "Run": // Your document running code goes here document.RunDocument(); Console.WriteLine("Running Document"); break; default: break; } } Console.WriteLine("Thanks for using...done"); System.Environment.Exit(0); }
public async Task <ActionResult> GetBottleCaps([FromForm] SlackRequest data) { var(team_id, channel_id, channel_name, _, _, _) = data; // get all players for a game var existingGame = await _context .Games .Include(i => i.Players) .FirstOrDefaultAsync(a => a.TeamId == team_id && a.SlackId == channel_id); if (existingGame == null) { return(Ok(this._responseFactory.GameNotFoundMessage(channel_name))); } else { var response = new { blocks = new List <Object> { new { type = "header", text = new { type = "plain_text", text = $":spinning-coin: Bottle caps for {existingGame.ChannelName} :spinning-coin:", emoji = true } }, new { type = "divider", }, new { type = "section", text = new { type = "mrkdwn", text = MarkdownFactory.CreateTable(existingGame.Players) } } } }; return(Ok(new { blocks = response.blocks, response_type = "in_channel" })); } }