ghwikipp: build_categories: Deal with Markdown pages correctly.

From 83b30c3b3fa5b482926ebdbb38bae9aefb81ff48 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 27 Feb 2023 23:13:00 -0500
Subject: [PATCH] build_categories: Deal with Markdown pages correctly.

---
 build_categories.php | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/build_categories.php b/build_categories.php
index ce4620e..8a9c212 100755
--- a/build_categories.php
+++ b/build_categories.php
@@ -68,7 +68,11 @@ function build_category_lists($srcdir)
                     if (($line = fgets($fp)) !== false) {
                         $cats = explode(',', trim($line));
                         foreach ($cats as $c) {
-                            $c = preg_replace('/^\[\[(.*?)\]\]$/', '$1', trim($c));
+                            if ($from_format == "mediawiki") {
+                                $c = preg_replace('/^\[\[(.*?)\]\]$/', '$1', trim($c));
+                            } else if ($from_format == "md") {
+                                $c = preg_replace('/^\[(.*?)\]\(.*?\)$/', '$1', trim($c));
+                            }
                             if (!isset($categories[$c])) {
                                 $categories[$c] = array();
                             }