GetLinkDefinition() public méthode

public GetLinkDefinition ( string id ) : LinkDefinition
id string
Résultat LinkDefinition
Exemple #1
0
        public static string FormatCodePrettyPrint(Markdown m, string code)
        {
            var match = rxExtractLanguage.Match(code);
            string language = null;

            if (match.Success)
            {
                // Save the language
                var g=(Group)match.Groups[2];
                language = g.ToString();

                // Remove the first line
                code = code.Substring(match.Groups[1].Length);
            }

            if (language == null)
            {
                var d = m.GetLinkDefinition("default_syntax");
                if (d!=null)
                    language = d.title;
            }
            if (language == "C#")
                language = "csharp";
            if (language == "C++")
                language = "cpp";

            if (string.IsNullOrEmpty(language))
                return string.Format("<pre><code>{0}</code></pre>\n", code);
            else
                return string.Format("<pre class=\"prettyprint lang-{0}\"><code>{1}</code></pre>\n", language.ToLowerInvariant(), code);
        }
Exemple #2
0
        public static string FormatCodePrettyPrint(MarkdownDeep.Markdown m, string code)
        {
            code = code.TrimEnd();

            // Try to extract the language from the first line
            var    match    = rxExtractLanguage.Match(code);
            string language = null;

            if (match.Success)
            {
                // Save the language
                var g = match.Groups[2];
                language = g.ToString();

                // Remove the first line
                code = code.Substring(match.Groups[1].Length);
            }

            // If not specified, look for a link definition called "default_syntax" and
            // grab the language from its title
            if (language == null)
            {
                var d = m.GetLinkDefinition("default_syntax");
                if (d != null)
                {
                    language = d.title;
                }
            }

            // Common replacements
            if (language == "C#")
            {
                language = "csharp";
            }
            if (language == "C++")
            {
                language = "cpp";
            }

            // Wrap code in pre/code tags and add PrettyPrint attributes if necessary
            if (string.IsNullOrEmpty(language))
            {
                return($"<pre><code>{code}</code></pre>\n");
            }
            return($"<textarea class='code code-sample' data-lang='{language.ToLowerInvariant()}'>{code}</textarea>\n");
        }
        private static string FormatCodeBlock(Markdown markdown, string code)
        {
            // Try to extract the language from the first line
            var match       = rxExtractLanguage.Match(code);
            string language = null;

            if (match.Success)
            {
                // Save the language
                var g       = match.Groups[2];
                language    = g.ToString();

                // Remove the first line
                code        = code.Substring(match.Groups[1].Length);
            }

            // If not specified, look for a link definition called "default_syntax" and
            // grab the language from its title
            if (language == null)
            {
                var d = markdown.GetLinkDefinition("default_syntax");
                if (d != null)
                {
                    language = d.title;
                }
            }

            // Common replacements
            if (language == "C#")
            {
                language = "csharp";
            }

            if (language == "C++")
            {
                language = "cpp";
            }

            if (string.IsNullOrWhiteSpace(language))
            {
                language = "csharp";
            }

            // Wrap code in pre/code tags and add PrettyPrint attributes if necessary
            return string.Format("<pre class=\"brush: {0};toolbar: false;\">{1}</pre>\n", language, code);
        }