示例#1
0
        public UpdateAvailable(Models.UpdateCheck update = null)
        {
            InitializeComponent();

            this.DataContext = MainViewModel;

            this.Width  *= MainViewModel.UIScaleFactor;
            this.Height *= MainViewModel.UIScaleFactor;

            var _markdownPipelineBuilder = new Markdig.MarkdownPipelineBuilder();

            _markdownPipelineBuilder.Extensions.Add(new Markdig.Extensions.Tables.PipeTableExtension());
            _markdownPipeline = _markdownPipelineBuilder.Build();
            try
            {
                var cssPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Assets", "CSS", "markdown.css");
                _css = System.IO.File.ReadAllText(cssPath);

                if (MainViewModel.UISettings?.UITheme?.ToLower() == "dark")
                {
                    cssPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Assets", "CSS", "dark-mode.css");
                    _css   += System.IO.File.ReadAllText(cssPath);
                }
            }
            catch
            {
                // will fail in design mode
            }

            _update = update;
        }
示例#2
0
        public Preview()
        {
            InitializeComponent();

            Steps = new ObservableCollection <ActionStep>();

            var _markdownPipelineBuilder = new Markdig.MarkdownPipelineBuilder();

            _markdownPipelineBuilder.Extensions.Add(new Markdig.Extensions.Tables.PipeTableExtension());
            _markdownPipeline = _markdownPipelineBuilder.Build();
        }
示例#3
0
        public Preview()
        {
            InitializeComponent();

            Steps = new ObservableCollection <ActionStep>();

            var _markdownPipelineBuilder = new Markdig.MarkdownPipelineBuilder();

            _markdownPipelineBuilder.Extensions.Add(new Markdig.Extensions.Tables.PipeTableExtension());
            _markdownPipeline = _markdownPipelineBuilder.Build();
            _css = System.IO.File.ReadAllText(System.AppDomain.CurrentDomain.BaseDirectory + "\\Assets\\CSS\\markdown.css");
        }
        public DefaultMarkdownHtmlRenderer()
        {
            var pipelineBuilderUnsafe = new Markdig.MarkdownPipelineBuilder();

            Markdig.MarkdownExtensions.UseAdvancedExtensions(pipelineBuilderUnsafe);
            Markdig.MarkdownExtensions.UseNoFollowLinks(pipelineBuilderUnsafe);
            Markdig.MarkdownExtensions.UseBootstrap(pipelineBuilderUnsafe);
            pipelineUnsafe = pipelineBuilderUnsafe.Build();

            var pipelineBuilderSafe = new Markdig.MarkdownPipelineBuilder();

            Markdig.MarkdownExtensions.UseAdvancedExtensions(pipelineBuilderSafe);
            Markdig.MarkdownExtensions.UseNoFollowLinks(pipelineBuilderSafe);
            Markdig.MarkdownExtensions.UseBootstrap(pipelineBuilderSafe);
            Markdig.MarkdownExtensions.DisableHtml(pipelineBuilderSafe);
            Markdig.MarkdownExtensions.DisableHeadings(pipelineBuilderSafe);
            pipelineSafe = pipelineBuilderSafe.Build();
        }
示例#5
0
文件: Page.cs 项目: kjmtks/LMS7
        public async Task <RenderFragment> RenderAsync(NavigationManager NM, Entities.User user)
        {
            try
            {
                var text   = Lecture.ReadPageFile(Path, Branch);
                var source = await preprocessAsync(text, user);

                var file = new System.IO.FileInfo(Path);

                if (file.Extension == ".md")
                {
                    var r = new Markdig.MarkdownPipelineBuilder();
                    var q = Markdig.MarkdownExtensions.UseAdvancedExtensions(r);
                    var p = q.Build();
                    source = Markdig.Markdown.ToHtml(source
                                                     .Replace("\\[", "\\\\[").Replace("\\]", "\\\\]")
                                                     .Replace("\\(", "\\\\(").Replace("\\)", "\\\\)")
                                                     .Replace("\\{", "\\\\{").Replace("\\}", "\\\\}"), p);
                }

                if (file.Extension == ".md" || file.Extension == ".html" || file.Extension == ".htm")
                {
                    return((builder) =>
                    {
                        var options = new AngleSharp.Html.Parser.HtmlParserOptions();
                        var parser = new AngleSharp.Html.Parser.HtmlParser(options);
                        var doc = parser.ParseDocument(source);
                        var content = compile(NM, doc.Body, user);
                        builder.AddContent(0, content);
                    });
                }
                else
                {
                    return((builder) => builder.AddMarkupContent(0, $"Not found page `{Path}'"));
                }
            }
            catch (FileNotFoundException e)
            {
                return((builder) => builder.AddMarkupContent(0, $"Not found page `{Path}': {e.Message}"));
            }
        }
示例#6
0
        private void PrepareImportPreview(ImportExportPackage package, List <ActionStep> steps, string title)
        {
            Markdig.MarkdownPipeline _markdownPipeline;
            string _css = "";


            var _markdownPipelineBuilder = new Markdig.MarkdownPipelineBuilder();

            _markdownPipelineBuilder.Extensions.Add(new Markdig.Extensions.Tables.PipeTableExtension());
            _markdownPipeline = _markdownPipelineBuilder.Build();

            try
            {
                var cssPath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Assets", "CSS", "markdown.css");
                _css = System.IO.File.ReadAllText(cssPath);

                if (MainViewModel.UISettings?.UITheme?.ToLower() == "dark")
                {
                    cssPath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Assets", "CSS", "dark-mode.css");
                    _css   += System.IO.File.ReadAllText(cssPath);
                }
            }
            catch
            {
            }
            var intro    = $"Importing from source: {package.SourceName}, exported {package.ExportDate.ToLongDateString()}, app version {package.SystemVersion?.ToString() ?? "(unknown)"}";
            var markdown = GetStepsAsMarkdown(steps, title, intro);

            var result = Markdig.Markdown.ToHtml(markdown, _markdownPipeline);

            result = "<html><head><meta http-equiv='Content-Type' content='text/html;charset=UTF-8'><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />" +
                     "<style>" + _css + "</style></head><body>" + result + "</body></html>";


            MarkdownView.NavigateToString(result);
        }
示例#7
0
        public UpdateAvailable(Models.UpdateCheck update = null)
        {
            InitializeComponent();

            this.DataContext = MainViewModel;

            this.Width  *= MainViewModel.UIScaleFactor;
            this.Height *= MainViewModel.UIScaleFactor;

            var _markdownPipelineBuilder = new Markdig.MarkdownPipelineBuilder();

            _markdownPipelineBuilder.Extensions.Add(new Markdig.Extensions.Tables.PipeTableExtension());
            _markdownPipeline = _markdownPipelineBuilder.Build();
            try
            {
                _css = System.IO.File.ReadAllText(System.AppDomain.CurrentDomain.BaseDirectory + "\\Assets\\CSS\\markdown.css");
            }
            catch
            {
                // will fail in design mode
            }

            _update = update;
        }