Beispiel #1
0
        /// <summary>
        /// Returns formatted code for the specified language.
        ///
        /// see CSharpFormat for supported types
        /// </summary>
        /// <param name="code"></param>
        /// <param name="language"></param>
        /// <returns></returns>
        public string GetFormattedCode(string code, string language, bool showLineNumbers = false, bool allowWordWrap = false)
        {
            SourceFormat formatter = CodeFormatFactory.Create(language);

            formatter.AllowWordWrapping = allowWordWrap;

            if (showLineNumbers)
            {
                formatter.LineNumbers = true;
            }

            return(formatter.FormatCode(code));
        }
Beispiel #2
0
 private string SyntaxMatcher(Match match)
 {
     return(match.Result(string.Format(base.Replace, _formatter.FormatCode(HttpUtility.HtmlDecode(match.Groups[1].Value))))); // need to call htmldecode as all html was encoded before getting here. If you don't encode the source data, then remove this call.
 }
Beispiel #3
0
 private string SyntaxMatcher(Match match)
 {
     return(match.Result(string.Format(Replace, _formatter.FormatCode(HttpUtility.HtmlDecode(match.Groups[1].Value)))));
 }