diff --git a/libs/Format/Confluence/DetailsToExpand.php b/libs/Format/Confluence/DetailsToExpand.php index 2fad4ccb..710de191 100644 --- a/libs/Format/Confluence/DetailsToExpand.php +++ b/libs/Format/Confluence/DetailsToExpand.php @@ -6,6 +6,8 @@ public function convert(string $content): string { // convert ', '__CDATA_END__', $content); $dom = new \DOMDocument(); @@ -29,6 +31,9 @@ public function convert(string $content): string } // restore namespace tags + $finalContent = str_replace('__CDATA_START__', '', $finalContent); + return preg_replace('/<(\/?)(\w+)___(\w+)/', '<\1\2:\3', $finalContent); } diff --git a/tests/Format/Confluence/DetailsToExpandTest.php b/tests/Format/Confluence/DetailsToExpandTest.php index 975df26e..a9f6f9d0 100644 --- a/tests/Format/Confluence/DetailsToExpandTest.php +++ b/tests/Format/Confluence/DetailsToExpandTest.php @@ -60,6 +60,44 @@ public function provideExpandData() EOD ], + [ + // Works with confluence code blocks + <<<'EOD' + + + console.log("hi friends"); + + ]]> + + +
+ Title ! + + + +
+ EOD, + <<<'EOD' + + + console.log("hi friends"); + + ]]> + + Title ! + +
    +
  • Item 1
  • +
  • Item 2
  • +
+
+ EOD + ], [ // Don't convert without title <<<'EOD'