Skip to content

Commit

Permalink
Use IEnumerable<T>.Aggregate to shave off a line
Browse files Browse the repository at this point in the history
  • Loading branch information
dontangg committed Sep 13, 2012
1 parent 31b9971 commit 5e0cc63
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Nocco/Nocco.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.Razor;

namespace Nocco {
Expand Down Expand Up @@ -72,10 +73,8 @@ private static List<Section> Parse(string source, string[] lines) {

Action<string, string> save = (docs, code) => sections.Add(new Section { DocsHtml = docs, CodeHtml = code });
Func<string, string> mapToMarkdown = docs => {
if (language.MarkdownMaps != null) {
foreach (var map in language.MarkdownMaps)
docs = System.Text.RegularExpressions.Regex.Replace(docs, map.Key, map.Value, System.Text.RegularExpressions.RegexOptions.Multiline);
}
if (language.MarkdownMaps != null)
docs = language.MarkdownMaps.Aggregate(docs, (currentDocs, map) => Regex.Replace(currentDocs, map.Key, map.Value, RegexOptions.Multiline));
return docs;
};

Expand Down

0 comments on commit 5e0cc63

Please sign in to comment.