Created
October 3, 2016 17:54
-
-
Save svick/cf2a16607c516ccbaed88df6200920cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| string path = @"E:\Users\Svick\git\visualfsharpdocs\docs\conceptual"; | |
| var files = Directory.EnumerateFiles(path); | |
| Regex regex = new Regex(@"\[([^]]*?)\]\(http.*?\)"); | |
| foreach (var file in files) | |
| { | |
| var lines = File.ReadAllLines(file); | |
| bool code = false; | |
| bool changed = false; | |
| for (int i = 0; i < lines.Length; i++) | |
| { | |
| var line = lines[i]; | |
| if (line.TrimStart().StartsWith("```")) | |
| code = !code; | |
| if (code) | |
| { | |
| var newLine = regex.Replace(line, @"$1"); | |
| if (newLine != line) | |
| { | |
| lines[i] = newLine; | |
| changed = true; | |
| } | |
| } | |
| } | |
| if (changed) | |
| { | |
| Console.WriteLine(file); | |
| File.WriteAllLines(file, lines); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment