private async Task RaiseReady() { OnCompilationReady(new CompilerResultEventArgs( await CompilerResultFactory.GenerateResult( sourceFileName: SourceFilePath, targetFileName: TargetFilePath, isSuccess: true, result: await FileHelpers.ReadAllTextRetry(TargetFilePath), errors: null ))); }
protected async override Task <CompilerResult> RunCompilerAsync(string sourcePath, string targetPath) { var result = new MarkdownSharp.Markdown(WESettings.Instance.Markdown).Transform(await FileHelpers.ReadAllTextRetry(sourcePath)); if (!string.IsNullOrEmpty(targetPath)) { ProjectHelpers.CheckOutFileFromSourceControl(targetPath); // TODO: Only if output changed? await FileHelpers.WriteAllTextRetry(targetPath, result); } var compilerResult = await CompilerResultFactory.GenerateResult(sourcePath, targetPath, true, result, null); return(compilerResult); }
public async void RequestCompilationResult(bool cached) { if (cached && CompilerRunner.Settings.CompileOnSave) { var targetPath = CompilerRunner.GetTargetPath(Document.FilePath); if (File.Exists(targetPath)) { OnCompilationReady(new CompilerResultEventArgs(await CompilerResultFactory.GenerateResult(Document.FilePath, targetPath)), true); return; } } InitiateCompilationAsync(Document.FilePath, false, cached).DoNotWait("compiling " + Document.FilePath); }
public async void RequestCompilationResult(bool cached) { if (File.Exists(TargetFilePath)) { RaiseReady().DoNotWait("reading " + TargetFilePath + "file"); } else { OnCompilationReady(new CompilerResultEventArgs( await CompilerResultFactory.GenerateResult( sourceFileName: SourceFilePath, targetFileName: null, isSuccess: true, // HACK: Set IsSuccess to true to force margin to display result result: "// Not compiled to disk yet", errors: null ))); } }
protected async override Task <CompilerResult> RunCompilerAsync(string sourcePath, string targetPath) { var markdown = new MarkdownDeep.Markdown(); markdown.ExtraMode = true; markdown.SafeMode = false; markdown.FormatCodeBlock = FormatCodePrettyPrint; string content = await FileHelpers.ReadAllTextRetry(sourcePath); // Issue with MarkdownDeep reported here https://github.com/toptensoftware/markdowndeep/issues/62 content = content.Replace("```", "~~~"); // Change the fenced code block language for the markdown.FormatCodeBlock method content = Regex.Replace(content, @"(~~~\s?)(?<lang>[^\s]+)", "~~~\r{{${lang}}}"); // Issue with MarkdownDeep reported here https://github.com/toptensoftware/markdowndeep/issues/63 foreach (Match match in Regex.Matches(content, "( {0,3}>)+( {0,3})([^\r\n]+)", RegexOptions.Multiline)) { content = content.Replace(match.Value, match.Value + " "); } var result = markdown .Transform(content) .Replace("[ ] ", "<input type=\"checkbox\" disabled /> ") .Replace("[x] ", "<input type=\"checkbox\" disabled checked /> "); if (!string.IsNullOrEmpty(targetPath) && (!File.Exists(targetPath) || await FileHelpers.ReadAllTextRetry(targetPath) != result)) { ProjectHelpers.CheckOutFileFromSourceControl(targetPath); await FileHelpers.WriteAllTextRetry(targetPath, result); } var compilerResult = await CompilerResultFactory.GenerateResult(sourcePath, targetPath, true, result, null); Telemetry.TrackEvent("Compiled markdown"); return(compilerResult); }
protected async override Task <CompilerResult> RunCompilerAsync(string sourcePath, string targetPath) { var cmSettings = new CommonMark.CommonMarkSettings() { RenderSoftLineBreaksAsLineBreaks = WESettings.Instance.Markdown.RenderSoftLineBreaksAsLineBreaks, TrackSourcePosition = WESettings.Instance.Markdown.TrackSourcePosition }; var result = CommonMark.CommonMarkConverter.Convert(await FileHelpers.ReadAllTextRetry(sourcePath), cmSettings); if (!string.IsNullOrEmpty(targetPath) && (!File.Exists(targetPath) || await FileHelpers.ReadAllTextRetry(targetPath) != result)) { ProjectHelpers.CheckOutFileFromSourceControl(targetPath); await FileHelpers.WriteAllTextRetry(targetPath, result); } var compilerResult = await CompilerResultFactory.GenerateResult(sourcePath, targetPath, true, result, null); return(compilerResult); }
protected async override Task <CompilerResult> RunCompilerAsync(string sourcePath, string targetPath) { Encoding encoding = _document == null ? null : _document.Encoding; var sourceText = await FileHelpers.ReadAllTextRetry(sourcePath, encoding); var settings = new CommonMark.CommonMarkSettings { OutputFormat = CommonMark.OutputFormat.Html }; var result = CommonMark.CommonMarkConverter.Convert(sourceText, settings); if (!string.IsNullOrEmpty(targetPath) && (!File.Exists(targetPath) || await FileHelpers.ReadAllTextRetry(targetPath, encoding) != result)) { ProjectHelpers.CheckOutFileFromSourceControl(targetPath); await FileHelpers.WriteAllTextRetry(targetPath, result); } var compilerResult = await CompilerResultFactory.GenerateResult(sourcePath, targetPath, true, result, null); return(compilerResult); }