private async Task AddShowNotes(Models.Podcast podcast)
        {
            try
            {
                var response = await _httpClient.GetAsync($"https://content.red-folder.com/podcasts/{podcast.SafeUrl}.md");

                if (!response.IsSuccessStatusCode)
                {
                    if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
                    {
                        // Fall back to the number notation i.e. 4.md
                        response = await _httpClient.GetAsync($"https://content.red-folder.com/podcasts/{podcast.EpisodeNumber}.md");

                        if (!response.IsSuccessStatusCode)
                        {
                            return;
                        }
                    }
                }

                var markdown = await response.Content.ReadAsStringAsync();

                HeyRed.MarkdownSharp.Markdown processor = new HeyRed.MarkdownSharp.Markdown();

                podcast.ShowNotes = processor.Transform(markdown);
            }
            catch
            {
            }
        }
Esempio n. 2
0
        public static string ToHtml(string mdText)
        {
            var    markdown = new HeyRed.MarkdownSharp.Markdown();
            string html     = markdown.Transform(mdText);

            return(html);
        }
Esempio n. 3
0
        public static string Markdown(string text)
        {
            var m    = new HeyRed.MarkdownSharp.Markdown();
            var html = m.Transform(text);

            return(html);
        }
Esempio n. 4
0
        public async Task <string> GetMarkdownStringAsync(string key)
        {
            var entity = await _microTextStore.LoadAsync(key);

            if (entity == null || entity.Language != Markdown)
            {
                return(null);
            }

            var processor = new HeyRed.MarkdownSharp.Markdown();

            return(processor.Transform(entity.Text));
        }
Esempio n. 5
0
        public override string GetHtml(string markdown)
        {
            var engine = new HeyRed.MarkdownSharp.Markdown(_options);

            return(engine.Transform(markdown));
        }
Esempio n. 6
0
        protected override string PostTransform(JObject meta, string markdown)
        {
            HeyRed.MarkdownSharp.Markdown processor = new HeyRed.MarkdownSharp.Markdown();

            return(processor.Transform(markdown));
        }
Esempio n. 7
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseStaticFiles();

            app.UseHumid(
                env, routes => {
                var get_hello_A =
                    Get("/a")
                    | Content("Hello A")
                    | OK;

                var any_hello_B =
                    new Route("/b", OK)
                    | Content("Hello B");

                var delete_only_hello_C =
                    Path("/c")
                    | Verbs(DELETE)
                    | Content("Hello C")
                    | OK;

                var get_hello_name =
                    Get("/hello/{name}")
                    | Do(ctx => ctx.With(content: $"Hello {ctx.Params<string>("name", "world").ToUpper()}"))
                    | OK;

                var get_hello_object =
                    Get("/hello/world")
                    | Do(ctx => {
                    var md   = new HeyRed.MarkdownSharp.Markdown();
                    var html = md.Transform("<h2>Hello,</h2><p>**uncatched route**</p>");

                    return(new{ message = html, value = 42 });
                })
                    | OK;

                var get_hello_view =
                    Get("/niceHello/{name}")
                    | Do(ctx => {
                    int id   = ctx.Query <int>("id", -1);
                    var name = ctx.Params <string>("name", "world");
                    return(new { name, id });
                })
                    | Html("simpleHello")
                    | OK
                    | Log("production");

                var get_hello_liquid =
                    Get("/liquid/hello")
                    |  Do(c => new { name = new { first = c.Query <string>("name", "world") } })
                    |  Html("liquid/simple")
                    | OK
                    |  Log(
                        match: "Production",
                        logger: c => Console.WriteLine($"match : {c.Request.TypeName} {c.Request.Path}"));

                //how to group routes by functionality, ex:
                var groupedRoutesWithViews =
                    f <Router>(r => r
                               - get_hello_view
                               - get_hello_liquid);

                return(routes
                       - get_hello_A
                       - any_hello_B
                       - delete_only_hello_C
                       - get_hello_object
                       - get_hello_name
                       - groupedRoutesWithViews
                       );
            });

            app.Run(async(context) =>
            {
                if (context.Response.StatusCode == 400)
                {
                    await context.Response.WriteAsync("your query doesn't match any route");
                }
            });
        }
Esempio n. 8
0
 public DependentOnMarkdownAndHtmlAgilityPackMarkdownTransformer(HeyRed.MarkdownSharp.Markdown markdown, HtmlDocument document)
 {
     _markdown = markdown;
     _document = document;
 }