From 08d3757d992ccfc81f9d636b45d3ffabd2248c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pekr=C3=B3l?= Date: Thu, 1 Aug 2024 15:23:56 +0200 Subject: [PATCH] fixed ordering of code tabs blocks --- .../DocumentBuilding/CodeBlockHelper.cs | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Raven.Documentation.Parser/Helpers/DocumentBuilding/CodeBlockHelper.cs b/Raven.Documentation.Parser/Helpers/DocumentBuilding/CodeBlockHelper.cs index b53ab78ce..3c640e14d 100644 --- a/Raven.Documentation.Parser/Helpers/DocumentBuilding/CodeBlockHelper.cs +++ b/Raven.Documentation.Parser/Helpers/DocumentBuilding/CodeBlockHelper.cs @@ -172,27 +172,33 @@ private static string GenerateCodeBlockFromFile(string languageAsString, string private static string GenerateCodeTabsBlock(string content, string documentationVersion, ParserOptions options, IDictionary placeholders) { var tabs = new List(); + var matchList = new SortedList(); + var matches = CodeTabFinder.Matches(content); foreach (Match match in matches) - { - var languageAndTitle = match.Groups[1].Value.Trim(); - var parts = languageAndTitle.Split(':'); - var languageAsString = parts[0]; - - var title = parts.Length > 1 ? parts[1] : null; - var value = match.Groups[2].Value.Trim(); - tabs.Add(GenerateCodeTabFromFile(languageAsString, title, value, documentationVersion, options)); - } + matchList.Add(match.Index, (match, true)); matches = CodeTabBlockFinder.Matches(content); foreach (Match match in matches) + matchList.Add(match.Index, (match, false)); + + foreach (var kvp in matchList) { + var isFromFile = kvp.Value.IsFromFile; + var match = kvp.Value.Match; + var languageAndTitle = match.Groups[1].Value.Trim(); var parts = languageAndTitle.Split(':'); var languageAsString = parts[0]; - var title = parts.Length > 1 ? parts[1] : null; var value = match.Groups[2].Value.Trim(); + + if (isFromFile) + { + tabs.Add(GenerateCodeTabFromFile(languageAsString, title, value, documentationVersion, options)); + continue; + } + tabs.Add(GenerateCodeTabBlock(languageAsString, title, value)); }