public static void Configure() { var options = new MarkdownOptions { AutoHyperlink = true }; var converter = new Markdown(options); Mapper.CreateMap<Entry, EntryViewModel>() // convert content from markdown to html .ForMember(entry => entry.Content, expression => expression.ResolveUsing(source => converter.Transform(source.Content))) // convert summary from markdown to html .ForMember(entry => entry.Summary, expression => expression.ResolveUsing(source => converter.Transform(source.Summary))); // convert the closed type of the derived generic list Mapper.CreateMap<PagedList<Entry>, PagedList<EntryViewModel>>() .AfterMap((entity, model) => Mapper.Map<List<Entry>, List<EntryViewModel>>(entity, model)); Mapper.CreateMap<EntryInput, Entry>() .ForMember(entry => entry.Slug, expression => expression.MapFrom( entry => SlugConverter.Convert(entry.Header))) .ForMember(entry => entry.Tags, expression => expression.MapFrom( entry => TagsResolver.ResolveTags(entry.Tags))); Mapper.CreateMap<Entry, EntryInput>() .ForMember(entry => entry.Tags, opt => opt.MapFrom( entry => TagsResolver.ResolveTags(entry.Tags))); Mapper.CreateMap<Entry, EntryInput>(); }
public string Process(string input) { var options = new MarkdownOptions(); var markdown = new Markdown(); var output = markdown.Transform(input); return output; }
public MarkdownConverter() { options = new MarkdownOptions { LinkEmails = true }; }
public IMarkdownOptions CreateMarkdownOptions() { var options = new MarkdownOptions(); options.AutoHyperlink = true; options.AutoNewLines = true; options.LinkEmails = true; return options; }
public WikiController() { _connString = ConfigurationManager.ConnectionStrings["microwiki"].ConnectionString; var options = new MarkdownOptions(); options.AutoHyperlink = true; _markdown = new Markdown(options); }
/// <summary> /// Markdowns the specified content. /// </summary> /// <param name="controller">The controller.</param> /// <param name="markdown">The markdown.</param> /// <param name="options">The options.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">controller</exception> public static MarkdownResult Markdown(this ControllerBase controller, string markdown, MarkdownOptions options = null) { if (controller == null) { throw new ArgumentNullException("controller"); } return new MarkdownResult(markdown, options); }
public MarkdownConverter(MarkdownOptions options) { if (options == null) { throw new ArgumentNullException("options"); } this.options = options; }
public MarkdownSharpMarkdownToHtml() { MarkdownOptions options = new MarkdownOptions(); options.AutoHyperlink = true; // options.AutoNewLines = true; options.LinkEmails = true; this.Markdown = new Markdown(options); }
public static Markdown CreateCompiler() { MarkdownSharp.MarkdownOptions options = new MarkdownSharp.MarkdownOptions(); options.AutoHyperlink = AutoHyperlinks; options.LinkEmails = LinkEmails; options.AutoNewLines = AutoNewLines; options.EmptyElementSuffix = GenerateXHTML ? "/>" : ">"; options.EncodeProblemUrlCharacters = EncodeProblemUrlCharacters; options.StrictBoldItalic = StrictBoldItalic; return new Markdown(options); }
public static Markdown GetMarkdown() { var options = new MarkdownOptions() { AutoHyperlink = true, AutoNewlines = false, EmptyElementSuffix = " />", LinkEmails = false, StrictBoldItalic = true }; var m = new Markdown(options); return m; }
public string Parse(string content) { if (string.IsNullOrWhiteSpace(content)) return string.Empty; var markdownOptions = new MarkdownOptions { AutoHyperlink = true }; var markdown = new MarkdownSharp.Markdown (markdownOptions); return markdown.Transform (content); }
/// <summary> /// Enables processing of the result of an action method by a custom type that inherits from the /// <see cref="T:System.Web.Mvc.ActionResult" /> class. /// </summary> /// <param name="context"> /// The context in which the result is executed. The context information includes the controller, /// HTTP content, request context, and route data. /// </param> public override void ExecuteResult(ControllerContext context) { if (Options == null) { Options = new MarkdownOptions(); } Markdown markdown = new Markdown(Options); Content = markdown.Transform(Content); ContentType = "text/html"; base.ExecuteResult(context); }
public Markdown(MarkdownOptions options) { this._emptyElementSuffix = " />"; this._linkEmails = true; this._urls = new Dictionary<string, string>(); this._titles = new Dictionary<string, string>(); this._htmlBlocks = new Dictionary<string, string>(); this._autoHyperlink = options.AutoHyperlink; this._autoNewlines = options.AutoNewlines; this._emptyElementSuffix = options.EmptyElementSuffix; this._encodeProblemUrlCharacters = options.EncodeProblemUrlCharacters; this._linkEmails = options.LinkEmails; this._strictBoldItalic = options.StrictBoldItalic; }
public static string HtmlFromMarkdown(this string content) { var options = new MarkdownOptions { AutoHyperlink = true, AutoNewLines = true, EncodeProblemUrlCharacters = true, LinkEmails = true }; var md = new Markdown(options); return md.Transform(content); }
public string Transform(string content) { var options = new MarkdownOptions { AutoHyperlink = true, AutoNewLines = true, EmptyElementSuffix = "/>", EncodeProblemUrlCharacters = false, LinkEmails = true, StrictBoldItalic = true }; var parser = new Markdown(options); var result = parser.Transform(content); return result; }
public Response RenderView(ViewLocationResult viewLocationResult, dynamic model, IRenderContext renderContext) { var response = new HtmlResponse(); var html = renderContext.ViewCache.GetOrAdd(viewLocationResult, result => { string markDown = File.ReadAllText(rootPathProvider.GetRootPath() + viewLocationResult.Location + Path.DirectorySeparatorChar + viewLocationResult.Name + ".md"); MarkdownOptions options = new MarkdownOptions(); options.AutoNewLines = false; var parser = new Markdown(options); return parser.Transform(markDown); }); /* <p> - matches the literal string "<p>" ( - creates a capture group, so that we can get the text back by backreferencing in our replacement string @ - matches the literal string "@" [^<]* - matches any character other than the "<" character and does this any amount of times ) - ends the capture group </p> - matches the literal string "</p>" */ var regex = new Regex("<p>(@[^<]*)</p>"); var serverHtml = regex.Replace(html, "$1"); var renderHtml = this.engineWrapper.Render(serverHtml, model, new MarkdownViewEngineHost(new NancyViewEngineHost(renderContext), renderContext)); response.Contents = stream => { var writer = new StreamWriter(stream); writer.Write(renderHtml); writer.Flush(); }; return response; }
public static Document Create(string filename) { Document doc = new Document(); doc.Filename = filename; string text = File.ReadAllText(doc.Filename).Trim(); Match metaMatch = metaAreaRegex.Match(text); if (metaMatch.Success && 0 == metaMatch.Index) { Match endMetaMatch = metaAreaRegex.Match(text, metaMatch.Length); if (endMetaMatch.Success) { string[] meta = text.Substring(metaMatch.Length, endMetaMatch.Index - metaMatch.Length).Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (string line in meta) { Match m = keyValuesRegex.Match(line); if (m.Success) { string key = m.Groups["key"].Value.ToLowerInvariant(); string value = m.Groups["value"].Value.Trim(); doc.Meta.Add(key, value); } } text = text.Substring(endMetaMatch.Index + endMetaMatch.Length).Trim(); } } var mdOptions = new MarkdownOptions { AutoHyperlink = true, EmptyElementSuffix = " />" }; var markdown = new Markdown(mdOptions); doc.Text = markdown.Transform(text).Trim().Replace("\n", Environment.NewLine).Replace("\r\r", "\r"); return doc; }
public LicenseDialog() { InitializeComponent(); Text = string.Format(Text, Assembly.GetExecutingAssembly().GetName().Version); _licenseBrowser = new Browser(); _licenseBrowser.Isolator = new NavigationIsolator(); // never used while other browsers are around _licenseBrowser.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; _licenseBrowser.Location = new Point(12, 12); _licenseBrowser.Name = "licenseBrowser"; _licenseBrowser.Size = new Size(_acceptButton.Right - 12, _acceptButton.Top - 24); Controls.Add(_licenseBrowser); var options = new MarkdownOptions() { LinkEmails = true, AutoHyperlink = true }; var m = new Markdown(options); var locale = CultureInfo.CurrentUICulture.Name; string licenseFilePath = BloomFileLocator.GetFileDistributedWithApplication("license.md"); var localizedLicenseFilePath = licenseFilePath.Substring(0, licenseFilePath.Length - 3) + "-" + locale + ".md"; if (RobustFile.Exists(localizedLicenseFilePath)) licenseFilePath = localizedLicenseFilePath; else { var index = locale.IndexOf('-'); if (index > 0) { locale = locale.Substring(0, index); localizedLicenseFilePath = licenseFilePath.Substring(0, licenseFilePath.Length - 3) + "-" + locale + ".md"; if (RobustFile.Exists(localizedLicenseFilePath)) licenseFilePath = localizedLicenseFilePath; } } var contents = m.Transform(RobustFile.ReadAllText(licenseFilePath, Encoding.UTF8)); var html = string.Format("<html><head><head/><body>{0}</body></html>", contents); _licenseBrowser.NavigateRawHtml(html); _licenseBrowser.Visible = true; }
private void InitializeCompiler() { if (_compiler == null) { MarkdownSharp.MarkdownOptions options = new MarkdownSharp.MarkdownOptions(); options.AutoHyperlink = AutoHyperlinks; options.LinkEmails = LinkEmails; options.AutoNewLines = AutoNewLines; options.EmptyElementSuffix = GenerateXHTML ? "/>" : ">"; options.EncodeProblemUrlCharacters = EncodeProblemUrlCharacters; options.StrictBoldItalic = StrictBoldItalic; _compiler = new Markdown(options); } }
public static void Main(string[] args) { Console.WriteLine("Chloride Site Generator"); Console.WriteLine(); Console.Write("Checking for site configuration..."); XmlDocument confd = new XmlDocument(); confd.InnerXml = "<SiteSettings></SiteSettings>"; MarkdownOptions mdo = new MarkdownOptions(); mdo.AutoHyperlink = true; mdo.AutoNewlines = true; mdo.EncodeProblemUrlCharacters = true; mdo.LinkEmails = true; Markdown md = new Markdown(mdo); if (!File.Exists("site.xml")) { Console.WriteLine(" Nonexistant"); Console.WriteLine(); StreamWriter confsw = File.CreateText("site.xml"); Console.Write("Friendly site name: "); AddXmlNode("SiteName", Console.ReadLine(), confd.DocumentElement); Console.Write("Website footer: "); AddXmlNode("SiteFooter", Console.ReadLine(), confd.DocumentElement); Console.WriteLine("--Available themes--"); foreach (string d in Directory.GetDirectories("themes")) { Console.WriteLine(d); } Console.Write("Select a theme: "); AddXmlNode("SiteTheme", Console.ReadLine(), confd.DocumentElement); confd.Save(confsw.BaseStream); } else { Console.WriteLine(" OK"); StreamReader confsr = File.OpenText("site.xml"); confd.LoadXml(confsr.ReadToEnd()); } SortedDictionary<int, string[]> pages = new SortedDictionary<int, string[]>(); //Unconventional use but meh Console.Write("Counting pages..."); bool first = true; foreach (string f in Directory.GetFiles("pages")) { string file = Path.GetFileNameWithoutExtension(f); int sortnum = Convert.ToInt32(file.Substring(0, 3)); string filename; if (first) filename = "index.html"; else filename = file.Substring(3).ToLowerInvariant().Replace(" ","") + ".html"; string[] values = new string[] { file.Substring(3), filename, f }; pages.Add(sortnum, values); first = false; } Console.WriteLine(" " + pages.Count + " pages found"); Console.Write("Generating pages..."); if (Directory.Exists("html")) { Directory.Delete("html", true); } Directory.CreateDirectory("html"); string SiteTitle = confd.DocumentElement["SiteName"].InnerText; Console.WriteLine(SiteTitle); string SiteFooter = confd.DocumentElement["SiteFooter"].InnerText; Console.WriteLine(SiteFooter); string SiteTheme = confd.DocumentElement["SiteTheme"].InnerText; Console.WriteLine(SiteTheme); string TemplateHTML = ""; foreach (string f in Directory.GetFiles(SiteTheme)) { if (Path.GetFileName(f) == "index.html") { TemplateHTML = File.OpenText(f).ReadToEnd(); foreach (string lne in TemplateHTML.Split(new string[] { "\n" }, StringSplitOptions.None)) { if (lne.Contains("$PAGE_URL") && lne.Contains("$PAGE_TITLE")) { //Correct line string output = ""; foreach (KeyValuePair<int, string[]> kvp in pages) { output += lne.Replace("$PAGE_URL", kvp.Value[1]).Replace("$PAGE_TITLE", kvp.Value[0]) + "\n"; } output = output.Substring(0, output.Length - 1); TemplateHTML = TemplateHTML.Replace(lne, output); break; } } TemplateHTML = TemplateHTML.Replace("\r", ""); } else { File.Copy(f, "html/" + Path.GetFileName(f), true); } } foreach (KeyValuePair<int, string[]> kvp in pages) { string TemporaryHTML = TemplateHTML; string csginfo = "Generated with Chloride Page Generator at " + DateTime.UtcNow.ToShortTimeString() + ", " + DateTime.UtcNow.ToShortDateString() + " (UTC)"; TemporaryHTML = TemporaryHTML.Replace("$WEBSITE_TITLE", SiteTitle).Replace("$WEBSITE_FOOTER", SiteFooter).Replace("$PAGE_URL", kvp.Value[1]).Replace("$PAGE_TITLE", kvp.Value[0]).Replace("$CSG_INFO", csginfo); TemporaryHTML = TemporaryHTML.Replace("$PAGE_CONTENT", md.Transform(File.OpenText(kvp.Value[2]).ReadToEnd())); File.WriteAllText("html/" + kvp.Value[1], TemporaryHTML); } Console.WriteLine(" OK"); Environment.Exit(0); }
/// <summary> /// Create a new Markdown instance and set the options from the MarkdownOptions object. /// </summary> public Markdown(MarkdownOptions options) { if (!String.IsNullOrEmpty(options.EmptyElementSuffix)) { _emptyElementSuffix = options.EmptyElementSuffix; } _allowEmptyLinkText = options.AllowEmptyLinkText; _disableHr = options.DisableHr; _disableHeaders = options.DisableHeaders; _disableImages = options.DisableImages; _quoteSingleLine = options.QuoteSinleLine; _autoHyperlink = options.AutoHyperlink; _autoNewlines = options.AutoNewlines; _linkEmails = options.LinkEmails; _strictBoldItalic = options.StrictBoldItalic; _asteriskIntraWordEmphasis = options.AsteriskIntraWordEmphasis; }
public void Configuration(IAppBuilder app) { if (_managerAssembly != null) { AreaRegistration.RegisterAllAreas(); CallChildConfigure(app, _managerAssembly, "VirtoCommerce.Platform.Web.Startup", "Configuration", "~/areas/admin", "admin/"); } UnityWebActivator.Start(); var container = UnityConfig.GetConfiguredContainer(); // Caching configuration // Be cautious with SystemWebCacheHandle because it does not work in native threads (Hangfire jobs). var localCache = CacheFactory.FromConfiguration<object>("storefrontCache"); var localCacheManager = new LocalCacheManager(localCache); container.RegisterInstance<ILocalCacheManager>(localCacheManager); //Because CacheManagerOutputCacheProvider used diff cache manager instance need translate clear region by this way //https://github.com/MichaCo/CacheManager/issues/32 localCacheManager.OnClearRegion += (sender, region) => { try { CacheManagerOutputCacheProvider.Cache.ClearRegion(region.Region); } catch { } }; localCacheManager.OnClear += (sender, args) => { try { CacheManagerOutputCacheProvider.Cache.Clear(); } catch { } }; var distributedCache = CacheFactory.Build("distributedCache", settings => { var jsonSerializerSettings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }; var redisCacheEnabled = ConfigurationManager.AppSettings.GetValue("VirtoCommerce:Storefront:RedisCache:Enabled", false); var memoryHandlePart = settings .WithJsonSerializer(jsonSerializerSettings, jsonSerializerSettings) .WithUpdateMode(CacheUpdateMode.Up) .WithSystemRuntimeCacheHandle("memory") .WithExpiration(ExpirationMode.Absolute, TimeSpan.FromHours(1)); if (redisCacheEnabled) { var redisCacheConnectionStringName = ConfigurationManager.AppSettings.GetValue("VirtoCommerce:Storefront:RedisCache:ConnectionStringName", "RedisCache"); var redisConnectionString = ConfigurationManager.ConnectionStrings[redisCacheConnectionStringName].ConnectionString; memoryHandlePart .And .WithRedisConfiguration("redis", redisConnectionString) .WithRetryTimeout(100) .WithMaxRetries(1000) .WithRedisBackplane("redis") .WithRedisCacheHandle("redis", true) .WithExpiration(ExpirationMode.Absolute, TimeSpan.FromHours(1)); } }); var distributedCacheManager = new DistributedCacheManager(distributedCache); container.RegisterInstance<IDistributedCacheManager>(distributedCacheManager); var logger = LogManager.GetLogger("default"); container.RegisterInstance<ILogger>(logger); // Create new work context for each request container.RegisterType<WorkContext, WorkContext>(new PerRequestLifetimeManager()); Func<WorkContext> workContextFactory = () => container.Resolve<WorkContext>(); container.RegisterInstance(workContextFactory); // Workaround for old storefront base URL: remove /api/ suffix since it is already included in every resource address in VirtoCommerce.Client library. var baseUrl = ConfigurationManager.ConnectionStrings["VirtoCommerceBaseUrl"].ConnectionString; if (baseUrl != null && baseUrl.EndsWith("/api/", StringComparison.OrdinalIgnoreCase)) { var apiPosition = baseUrl.LastIndexOf("/api/", StringComparison.OrdinalIgnoreCase); if (apiPosition >= 0) { baseUrl = baseUrl.Remove(apiPosition); } } var apiAppId = ConfigurationManager.AppSettings["vc-public-ApiAppId"]; var apiSecretKey = ConfigurationManager.AppSettings["vc-public-ApiSecretKey"]; var apiClient = new StorefrontHmacApiClient(baseUrl, apiAppId, apiSecretKey, workContextFactory); container.RegisterInstance<ApiClient>(apiClient); container.RegisterInstance(new VirtoCommerce.Client.Client.Configuration(apiClient)); container.RegisterType<IStoreModuleApi, StoreModuleApi>(); container.RegisterType<IVirtoCommercePlatformApi, VirtoCommercePlatformApi>(); container.RegisterType<ICustomerManagementModuleApi, CustomerManagementModuleApi>(); container.RegisterType<ICommerceCoreModuleApi, CommerceCoreModuleApi>(); container.RegisterType<ICustomerManagementModuleApi, CustomerManagementModuleApi>(); container.RegisterType<ICatalogModuleApi, CatalogModuleApi>(); container.RegisterType<IPricingModuleApi, PricingModuleApi>(); container.RegisterType<IInventoryModuleApi, InventoryModuleApi>(); container.RegisterType<IShoppingCartModuleApi, ShoppingCartModuleApi>(); container.RegisterType<IOrderModuleApi, OrderModuleApi>(); container.RegisterType<IMarketingModuleApi, MarketingModuleApi>(); container.RegisterType<ICMSContentModuleApi, CMSContentModuleApi>(); container.RegisterType<IQuoteModuleApi, QuoteModuleApi>(); container.RegisterType<ISearchModuleApi, SearchModuleApi>(); container.RegisterType<IMarketingService, MarketingServiceImpl>(); container.RegisterType<IPromotionEvaluator, PromotionEvaluator>(); container.RegisterType<ICartValidator, CartValidator>(); container.RegisterType<IPricingService, PricingServiceImpl>(); container.RegisterType<ICustomerService, CustomerServiceImpl>(); container.RegisterType<IMenuLinkListService, MenuLinkListServiceImpl>(); container.RegisterType<ICartBuilder, CartBuilder>(); container.RegisterType<IQuoteRequestBuilder, QuoteRequestBuilder>(); container.RegisterType<ICatalogSearchService, CatalogSearchServiceImpl>(); container.RegisterType<IAuthenticationManager>(new InjectionFactory(context => HttpContext.Current.GetOwinContext().Authentication)); container.RegisterType<IStorefrontUrlBuilder, StorefrontUrlBuilder>(new PerRequestLifetimeManager()); //Register domain events container.RegisterType<IEventPublisher<OrderPlacedEvent>, EventPublisher<OrderPlacedEvent>>(); container.RegisterType<IEventPublisher<UserLoginEvent>, EventPublisher<UserLoginEvent>>(); container.RegisterType<IEventPublisher<QuoteRequestUpdatedEvent>, EventPublisher<QuoteRequestUpdatedEvent>>(); //Register event handlers (observers) container.RegisterType<IAsyncObserver<OrderPlacedEvent>, CustomerServiceImpl>("Invalidate customer cache when user placed new order"); container.RegisterType<IAsyncObserver<QuoteRequestUpdatedEvent>, CustomerServiceImpl>("Invalidate customer cache when quote request was updated"); container.RegisterType<IAsyncObserver<UserLoginEvent>, CartBuilder>("Merge anonymous cart with loggined user cart"); container.RegisterType<IAsyncObserver<UserLoginEvent>, QuoteRequestBuilder>("Merge anonymous quote request with loggined user quote"); var cmsContentConnectionString = BlobConnectionString.Parse(ConfigurationManager.ConnectionStrings["ContentConnectionString"].ConnectionString); var themesBasePath = cmsContentConnectionString.RootPath.TrimEnd('/') + "/" + "Themes"; var staticContentBasePath = cmsContentConnectionString.RootPath.TrimEnd('/') + "/" + "Pages"; //Use always file system provider for global theme var globalThemesBlobProvider = new FileSystemContentBlobProvider(ResolveLocalPath("~/App_Data/Themes/default")); IContentBlobProvider themesBlobProvider; IContentBlobProvider staticContentBlobProvider; if ("AzureBlobStorage".Equals(cmsContentConnectionString.Provider, StringComparison.OrdinalIgnoreCase)) { themesBlobProvider = new AzureBlobContentProvider(cmsContentConnectionString.ConnectionString, themesBasePath, localCacheManager); staticContentBlobProvider = new AzureBlobContentProvider(cmsContentConnectionString.ConnectionString, staticContentBasePath, localCacheManager); } else { themesBlobProvider = new FileSystemContentBlobProvider(ResolveLocalPath(themesBasePath)); staticContentBlobProvider = new FileSystemContentBlobProvider(ResolveLocalPath(staticContentBasePath)); } var shopifyLiquidEngine = new ShopifyLiquidThemeEngine(localCacheManager, workContextFactory, () => container.Resolve<IStorefrontUrlBuilder>(), themesBlobProvider, globalThemesBlobProvider, "~/themes/assets", "~/themes/global/assets"); container.RegisterInstance<ILiquidThemeEngine>(shopifyLiquidEngine); //Register liquid engine ViewEngines.Engines.Add(new DotLiquidThemedViewEngine(shopifyLiquidEngine)); // Shopify model binders convert Shopify form fields with bad names to VirtoCommerce model properties. container.RegisterType<IModelBinderProvider, ShopifyModelBinderProvider>("shopify"); var markdownOptions = new MarkdownOptions { LinkEmails = false // Render mailto: links as is without markup transformations }; //Static content service var staticContentService = new StaticContentServiceImpl(new Markdown(markdownOptions), shopifyLiquidEngine, localCacheManager, workContextFactory, () => container.Resolve<IStorefrontUrlBuilder>(), StaticContentItemFactory.GetContentItemFromPath, staticContentBlobProvider); container.RegisterInstance<IStaticContentService>(staticContentService); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters, workContextFactory, () => container.Resolve<CommonController>()); RouteConfig.RegisterRoutes(RouteTable.Routes, workContextFactory, container.Resolve<ICommerceCoreModuleApi>(), container.Resolve<IStaticContentService>(), localCacheManager); AuthConfig.ConfigureAuth(app, () => container.Resolve<IStorefrontUrlBuilder>()); app.Use<WorkContextOwinMiddleware>(container); app.UseStageMarker(PipelineStage.PostAuthorize); app.Use<StorefrontUrlRewriterOwinMiddleware>(container); app.UseStageMarker(PipelineStage.PostAuthorize); }
/// <summary> /// Create a new Markdown instance using default options /// </summary> /*public Markdown() : this(false) { }*/ /// <summary> /// Create a new Markdown instance and optionally load options from a configuration /// file. There they should be stored in the appSettings section, available options are: /// /// Markdown.StrictBoldItalic (true/false) /// Markdown.EmptyElementSuffix (">" or " />" without the quotes) /// Markdown.LinkEmails (true/false) /// Markdown.AutoNewLines (true/false) /// Markdown.AutoHyperlink (true/false) /// Markdown.EncodeProblemUrlCharacters (true/false) /// /// </summary> /*public Markdown(bool loadOptionsFromConfigFile) { this.EmptyElementSuffix = " />"; this.LinkEmails = true; if (!loadOptionsFromConfigFile) return; var settings = ConfigurationManager.AppSettings; foreach (string key in settings.Keys) { switch (key) { case "Markdown.AutoHyperlink": this.AutoHyperlink = Convert.ToBoolean(settings[key]); break; case "Markdown.AutoNewlines": this.AutoNewLines = Convert.ToBoolean(settings[key]); break; case "Markdown.EmptyElementSuffix": this.EmptyElementSuffix = settings[key]; break; case "Markdown.EncodeProblemUrlCharacters": this.EncodeProblemUrlCharacters = Convert.ToBoolean(settings[key]); break; case "Markdown.LinkEmails": this.LinkEmails = Convert.ToBoolean(settings[key]); break; case "Markdown.StrictBoldItalic": this.StrictBoldItalic = Convert.ToBoolean(settings[key]); break; case "Markdown.SupportArticles": this.SupportArticles = Convert.ToBoolean(settings[key]); break; } } }*/ /// <summary> /// Create a new Markdown instance and set the options from the MarkdownOptions object. /// </summary> public Markdown(MarkdownOptions options) { this.AutoHyperlink = options.AutoHyperlink; this.AutoNewLines = options.AutoNewLines; this.EmptyElementSuffix = options.EmptyElementSuffix; this.EncodeProblemUrlCharacters = options.EncodeProblemUrlCharacters; this.LinkEmails = options.LinkEmails; this.StrictBoldItalic = options.StrictBoldItalic; this.SupportArticles = options.SupportArticles; }
protected override void ProcessRecord() { if (MarkdownContent != null && MarkdownContent.Length > 0) { MarkdownOptions options = new MarkdownOptions { AutoHyperlink = this.AutoHyperlink, AutoNewlines = this.AutoNewlines, EmptyElementSuffix = this.EmptyElementSuffix, EncodeProblemUrlCharacters = this.EncodeProblemUrlCharacters, LinkEmails = this.LinkEmails, StrictBoldItalic = this.StrictBoldItalic }; Markdown markyMark = new Markdown(options); WriteObject(markyMark.Transform(MarkdownContent)); } }
private void ShowReadme(string readmePath) { if (string.IsNullOrEmpty(readmePath)) { BEditReadme.Visibility = Visibility.Hidden; BAddReadme.Visibility = Visibility.Visible; WbReadme.Navigate("about:blank"); return; } BEditReadme.Visibility = Visibility.Visible; BAddReadme.Visibility = Visibility.Hidden; var strAppDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); if (strAppDir == null) return; var strFullPathToMyFile = Path.Combine(strAppDir, "ReadMeStyle.less"); var source = File.ReadAllText(readmePath); var options = new MarkdownOptions { AutoHyperlink = true, AutoNewlines = true, LinkEmails = true, QuoteSingleLine = true, StrictBoldItalic = true }; var mark = new Markdown(options); var headerHtml = @"<!DOCTYPE html> <head> <meta charset='utf-8'> <link rel='stylesheet' type='text/css' href=' " + strFullPathToMyFile + @"' /> </head> <body> "; const string footerHtml = @"</body>"; var htmlString = headerHtml + mark.Transform(source) + footerHtml; WbReadme.NavigateToString(htmlString); }
/// <summary> /// Create a new Markdown instance and set the options from the MarkdownOptions object. /// </summary> public Markdown(MarkdownOptions options) { _autoHyperlink = options.AutoHyperlink; _autoNewlines = options.AutoNewlines; _emptyElementSuffix = options.EmptyElementSuffix; _encodeProblemUrlCharacters = options.EncodeProblemUrlCharacters; _linkEmails = options.LinkEmails; _strictBoldItalic = options.StrictBoldItalic; }
/// <summary> /// Converts Markdown syntax to markup. /// </summary> /// <param name="text"></param> /// <returns></returns> private string ConvertToMarkup(string markdown) { MarkdownOptions opts = new MarkdownOptions(); opts.AutoNewlines = true; opts.AutoHyperlink = true; opts.EncodeProblemUrlCharacters = true; // Strings are heavy and immutable StringBuilder output = new StringBuilder(); MarkdownSharp.Markdown maker = new Markdown(opts); output.Append(maker.Transform(markdown)); return output.ToString(); }
/// <summary> /// Initializes a new instance of the <see cref="MarkdownResult" /> class. /// </summary> public MarkdownResult() { Options = new MarkdownOptions(); }
/// <summary> /// Create a new Markdown instance and set the options from the MarkdownOptions object. /// </summary> public Markdown(MarkdownOptions options) { SupportedLanguageMap = new Dictionary<string, string>(); _autoHyperlink = options.AutoHyperlink; _autoNewlines = options.AutoNewlines; _emptyElementSuffix = options.EmptyElementSuffix; _encodeProblemUrlCharacters = options.EncodeProblemUrlCharacters; _linkEmails = options.LinkEmails; _strictBoldItalic = options.StrictBoldItalic; Preprocessor = new Preprocessor.Preprocessor(this); }
/// <summary> /// Create a new Markdown instance and set the options from the MarkdownOptions object. /// </summary> public Markdown(MarkdownOptions options) { _autoHyperlink = options.AutoHyperlink; _autoNewlines = options.AutoNewlines; _emptyElementSuffix = options.EmptyElementSuffix; _linkEmails = options.LinkEmails; _strictBoldItalic = options.StrictBoldItalic; _asteriskIntraWordEmphasis = options.AsteriskIntraWordEmphasis; }
/// <summary> /// Initializes a new instance of the <see cref="MarkdownResult" /> class. /// </summary> /// <param name="markdown">The markdown.</param> /// <param name="options">The options.</param> public MarkdownResult(string markdown, MarkdownOptions options) { Content = markdown; Options = options; }