[mapguide-commits] r10064 - in branches/4.0/MgDev/Doc: . mdpreprocess
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri Nov 10 10:50:06 PST 2023
Author: jng
Date: 2023-11-10 10:50:05 -0800 (Fri, 10 Nov 2023)
New Revision: 10064
Added:
branches/4.0/MgDev/Doc/mdpreprocess/
branches/4.0/MgDev/Doc/mdpreprocess/Program.cs
branches/4.0/MgDev/Doc/mdpreprocess/mdpreprocess.csproj
Log:
#2877: Add markdown preprocessor
Index: branches/4.0/MgDev/Doc/mdpreprocess
===================================================================
--- branches/4.0/MgDev/Doc/mdpreprocess 2023-11-10 18:28:50 UTC (rev 10063)
+++ branches/4.0/MgDev/Doc/mdpreprocess 2023-11-10 18:50:05 UTC (rev 10064)
Property changes on: branches/4.0/MgDev/Doc/mdpreprocess
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,2 ##
+bin
+obj
Added: branches/4.0/MgDev/Doc/mdpreprocess/Program.cs
===================================================================
--- branches/4.0/MgDev/Doc/mdpreprocess/Program.cs (rev 0)
+++ branches/4.0/MgDev/Doc/mdpreprocess/Program.cs 2023-11-10 18:50:05 UTC (rev 10064)
@@ -0,0 +1,34 @@
+using System.IO;
+using System.Text.RegularExpressions;
+
+if (args.Length != 1)
+{
+ Console.WriteLine("Usage: <program> [directory of .md.tpl files]");
+ return 1;
+}
+if (!Directory.Exists(args[0]))
+{
+ Console.WriteLine("Directory does not exist");
+ return 1;
+}
+var files = Directory.GetFiles(args[0], "*.md.tpl");
+var macroRegex = new Regex(@"\[(!doclinkclass )?([^]]+)\]");
+var evaluator = new MatchEvaluator(GenerateFragment);
+foreach (var f in files)
+{
+ var fileTgt = f.Replace(".md.tpl", ".md");
+
+ var sourceText = File.ReadAllText(f);
+ var replacedText = macroRegex.Replace(sourceText, evaluator);
+
+ File.WriteAllText(fileTgt, replacedText);
+ Console.WriteLine($"Pre-processed: {f} -> {fileTgt}");
+}
+
+return 0;
+
+static string GenerateFragment(Match match)
+{
+ // Groups[2] contains the class name
+ return $"([.net](dotnet_api/api/OSGeo.MapGuide.{match.Groups[2].Value}.html),[Java](java_api/org/osgeo/mapguide/{match.Groups[2].Value}.html),[PHP](TODO.md))";
+}
\ No newline at end of file
Added: branches/4.0/MgDev/Doc/mdpreprocess/mdpreprocess.csproj
===================================================================
--- branches/4.0/MgDev/Doc/mdpreprocess/mdpreprocess.csproj (rev 0)
+++ branches/4.0/MgDev/Doc/mdpreprocess/mdpreprocess.csproj 2023-11-10 18:50:05 UTC (rev 10064)
@@ -0,0 +1,10 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>net7.0</TargetFramework>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <Nullable>enable</Nullable>
+ </PropertyGroup>
+
+</Project>
More information about the mapguide-commits
mailing list