initial COmmit: Add KB Antora Importer plugin files

This commit is contained in:
Sven Steinert
2026-05-12 14:37:09 +02:00
parent cf253c1367
commit 6abf6f9c3d
39 changed files with 2945 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace KbAntoraImporter\Antora;
final class AntoraParser
{
public function pageSlugFromPath(string $path): string
{
$name = preg_replace('/\.adoc$/', '', basename($path)) ?: basename($path);
return 'index' === $name ? '' : sanitize_title($name);
}
public function moduleFromPath(string $path): string
{
if (preg_match('#^modules/([^/]+)/#', $path, $matches)) {
return $matches[1];
}
return 'ROOT';
}
}