Skip to content

Commit 8498b3f

Browse files
authored
Merge branch 'main' into unescape-entities-in-codeblocks
2 parents 5e0e31b + a3849ed commit 8498b3f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
var xrefRegex = new Regex("<xref href=\"(.+?)\" data-throw-if-not-resolved=\"false\"></xref>", RegexOptions.Compiled);
2525
var langwordXrefRegex =
2626
new Regex("<xref uid=\"langword_csharp_.+?\" name=\"(.+?)\" href=\"\"></xref>", RegexOptions.Compiled);
27-
var codeBlockRegex = new Regex("<pre><code class=\"lang-csharp\">((.|\n)+?)</code></pre>", RegexOptions.Compiled);
27+
var codeBlockRegex = new Regex("<pre><code class=\"lang-([a-zA-Z0-9]+)\">((.|\n)+?)</code></pre>", RegexOptions.Compiled);
2828
var markdownCodeBlockRegex = new Regex(@"```(\w+)\n(.*?)\n```", RegexOptions.Compiled | RegexOptions.Singleline);
2929
var codeRegex = new Regex("<code>(.+?)</code>", RegexOptions.Compiled);
3030
var linkRegex = new Regex("<a href=\"(.+?)\">(.+?)</a>", RegexOptions.Compiled);
@@ -212,7 +212,7 @@ string Link(string uid, bool linkFromGroupedType, bool nameOnly = false, bool li
212212
return Link(uid, linkFromGroupedType);
213213
});
214214
summary = langwordXrefRegex.Replace(summary, match => $"`{match.Groups[1].Value}`");
215-
summary = codeBlockRegex.Replace(summary, match => $"```csharp\n{match.Groups[1].Value.Trim()}\n```");
215+
summary = codeBlockRegex.Replace(summary, match => $"```{match.Groups[1].Value.Trim()}\n{match.Groups[2].Value.Trim()}\n```");
216216
summary = codeRegex.Replace(summary, match => $"`{match.Groups[1].Value}`");
217217
summary = linkRegex.Replace(summary, match => $"[{match.Groups[2].Value}]({match.Groups[1].Value})");
218218
summary = brRegex.Replace(summary, _ => config.BrNewline);

0 commit comments

Comments
 (0)