Ejemplo n.º 1
0
        public CreoleParser(ApplicationSettings applicationSettings, SiteSettings siteSettings)
        {
            MarkupParserHelp = new MarkupParserHelp()
            {
                BoldToken         = "**",
                ItalicToken       = "//",
                UnderlineToken    = "__",
                LinkStartToken    = "[[%URL%|",
                LinkEndToken      = "%LINKTEXT%]]",
                ImageStartToken   = "{{%FILENAME%|",
                ImageEndToken     = "%ALT%}}",
                BulletListToken   = "*",
                NumberedListToken = "#",
                HeadingToken      = "=",
            };

            _applicationSettings = applicationSettings;
            AddIdToParagraphTags = false;
            HTMLAttributes       = new Dictionary <string, string>();
            InterWiki            = new Dictionary <string, string>();
            TabStop           = 7;   // default to 7 char tabstop
            NoWikiEscapeStart = "{{{";
            NoWikiEscapeEnd   = "}}}";

            if (siteSettings != null)
            {
                InterWiki.Add("tag", siteSettings.SiteUrl + "/pages/tag/");
            }
        }
Ejemplo n.º 2
0
        /// <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 MarkdownParser(bool loadOptionsFromConfigFile)
        {
            MarkupParserHelp = new MarkupParserHelp()
            {
                BoldToken = "**",
                ItalicToken = "*",
                UnderlineToken = "",
                LinkStartToken = "[%LINKTEXT%",
                LinkEndToken = "](%URL%)",
                ImageStartToken = "![%ALT%",
                ImageEndToken = "](%FILENAME%)",
                BulletListToken = "*",
                NumberedListToken = "1.",
                HeadingToken = "#",
            };

            if (!loadOptionsFromConfigFile)
                return;

            var settings = ConfigurationManager.AppSettings;
            foreach (string key in settings.Keys)
            {
                switch (key)
                {
                    case "Markdown.AutoHyperlink":
                        _autoHyperlink = Convert.ToBoolean(settings[key]);
                        break;
                    case "Markdown.AutoNewlines":
                        _autoNewlines = Convert.ToBoolean(settings[key]);
                        break;
                    case "Markdown.EmptyElementSuffix":
                        _emptyElementSuffix = settings[key];
                        break;
                    case "Markdown.EncodeProblemUrlCharacters":
                        _encodeProblemUrlCharacters = Convert.ToBoolean(settings[key]);
                        break;
                    case "Markdown.LinkEmails":
                        _linkEmails = Convert.ToBoolean(settings[key]);
                        break;
                    case "Markdown.StrictBoldItalic":
                        _strictBoldItalic = Convert.ToBoolean(settings[key]);
                        break;
                }
            }
        }
Ejemplo n.º 3
0
		public CreoleParser(ApplicationSettings applicationSettings, SiteSettings siteSettings)
		{
			MarkupParserHelp = new MarkupParserHelp()
			{
				BoldToken = "**",
				ItalicToken = "//",
				UnderlineToken = "__",
				LinkStartToken = "[[%URL%|",
				LinkEndToken = "%LINKTEXT%]]",
				ImageStartToken = "{{%FILENAME%|",
				ImageEndToken = "%ALT%}}",
				BulletListToken = "*",
				NumberedListToken = "#",
				HeadingToken = "=",
			};

			_applicationSettings = applicationSettings;
			AddIdToParagraphTags = false;
			HTMLAttributes = new Dictionary<string, string>();
			InterWiki = new Dictionary<string, string>();
			TabStop = 7; // default to 7 char tabstop
			NoWikiEscapeStart = "{{{";
			NoWikiEscapeEnd = "}}}";

			if (siteSettings != null)
				InterWiki.Add("tag", siteSettings.SiteUrl + "/pages/tag/");
		}