diff --git a/src/Converter/ConfluenceConverter.php b/src/Converter/ConfluenceConverter.php
index 0d52907..e5cca64 100644
--- a/src/Converter/ConfluenceConverter.php
+++ b/src/Converter/ConfluenceConverter.php
@@ -27,6 +27,7 @@
use HalloWelt\MigrateConfluence\Converter\Processor\Emoticon;
use HalloWelt\MigrateConfluence\Converter\Processor\ExpandMacro;
use HalloWelt\MigrateConfluence\Converter\Processor\Image;
+use HalloWelt\MigrateConfluence\Converter\Processor\MacroAlign;
use HalloWelt\MigrateConfluence\Converter\Processor\PageLink;
use HalloWelt\MigrateConfluence\Converter\Processor\PreserveCode;
use HalloWelt\MigrateConfluence\Converter\Processor\StructuredMacroChildren;
@@ -242,7 +243,8 @@ private function runProcessors( $dom ) {
$currentPageTitle, $this->nsFileRepoCompat
),
new StructuredMacroContenByLabel( $this->currentPageTitle ),
- new ExpandMacro()
+ new ExpandMacro(),
+ new MacroAlign()
];
/** @var IProcessor $processor */
@@ -353,7 +355,8 @@ private function processMacro( $sender, $match, $dom, $xpath ) {
'children',
'drawio',
'contentbylabel',
- 'expand'
+ 'expand',
+ 'align'
]
) ) {
return;
diff --git a/src/Converter/Processor/MacroAlign.php b/src/Converter/Processor/MacroAlign.php
new file mode 100644
index 0000000..6a403d3
--- /dev/null
+++ b/src/Converter/Processor/MacroAlign.php
@@ -0,0 +1,97 @@
+getElementsByTagName( 'macro' );
+
+ $macros = [];
+ foreach ( $macrosTags as $macrosTag ) {
+ $macros[] = $macrosTag;
+ }
+
+ $macroName = $this->getMacroName();
+ foreach ( $macros as $macro ) {
+ if ( $macro->getAttribute( 'ac:name' ) === $macroName ) {
+ $this->doProcessMacro( $macro );
+ }
+ }
+ }
+
+ /**
+ * @param DOMNode $node
+ * @return void
+ */
+ protected function doProcessMacro( $node ): void {
+ $macroName = $node->getAttribute( 'ac:name' );
+
+ $macroReplacement = $node->ownerDocument->createElement( 'div' );
+
+ $macroReplacement->setAttribute( 'class', "ac-macro-$macroName" );
+
+ $macroParams = $this->getMacroParams( $node, $macroReplacement );
+ if ( !empty( $macroParams ) ) {
+ $macroReplacement->setAttribute( 'data-params', json_encode( $macroParams ) );
+ }
+
+ if ( isset( $macroParams['align'] ) ) {
+ $style = 'text-align: ' . $macroParams['align'] . ';';
+ $macroReplacement->setAttribute( 'style', $style );
+ }
+
+ $this->macroBody( $node, $macroReplacement );
+ $node->parentNode->replaceChild( $macroReplacement, $node );
+ }
+
+ /**
+ *
+ * @param DOMNode $macro
+ * @param DOMElement $macroReplacement
+ * @return array
+ */
+ private function getMacroParams( $macro, $macroReplacement ): array {
+ $params = [];
+ foreach ( $macro->childNodes as $childNode ) {
+ if ( $childNode->nodeName === 'ac:parameter' ) {
+ $paramName = $childNode->getAttribute( 'ac:name' );
+ $params[$paramName] = $childNode->nodeValue;
+ }
+ }
+
+ return $params;
+ }
+
+ /**
+ *
+ * @param DOMNode $macro
+ * @param DOMElement $macroReplacement
+ * @return void
+ */
+ private function macroBody( $macro, $macroReplacement ): void {
+ foreach ( $macro->childNodes as $childNode ) {
+ if ( $childNode->nodeName === 'ac:rich-text-body' ) {
+ foreach ( $childNode->childNodes as $node ) {
+ $newNode = $node->cloneNode( true );
+ $macroReplacement->appendChild( $newNode );
+ }
+ }
+ }
+ }
+}
diff --git a/tests/phpunit/Converter/Processor/MacroAlignTest.php b/tests/phpunit/Converter/Processor/MacroAlignTest.php
new file mode 100644
index 0000000..e8ca935
--- /dev/null
+++ b/tests/phpunit/Converter/Processor/MacroAlignTest.php
@@ -0,0 +1,34 @@
+loadXML( $input );
+
+ $processor = new MacroAlign();
+ $processor->process( $dom );
+
+ $actualOutput = $dom->saveXML( $dom->documentElement );
+
+ $input = file_get_contents( "$dir/macroalign-output.xml" );
+ $expectedDom = new DOMDocument();
+ $expectedDom->loadXML( $input );
+ $expectedOutput = $expectedDom->saveXML( $expectedDom->documentElement );
+
+ $this->assertEquals( $expectedOutput, $actualOutput );
+ }
+}
diff --git a/tests/phpunit/data/macroalign-input.xml b/tests/phpunit/data/macroalign-input.xml
new file mode 100644
index 0000000..67ef87e
--- /dev/null
+++ b/tests/phpunit/data/macroalign-input.xml
@@ -0,0 +1,6 @@
+
+ sit amet
+
sit amet
+ \ No newline at end of file