Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/Coding/Wiki.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,7 +27,7 @@ public function createWiki($token, $projectName, $data)

public function createMarkdownZip($markdown, $path, $markdownFilename): bool|string
{
$zipFileFullPath = sys_get_temp_dir() . '/' . $markdownFilename . '-' . Str::uuid() . '.zip'
$zipFileFullPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $markdownFilename . '-' . Str::uuid() . '.zip'
if ($this->zipArchive->open($zipFileFullPath, ZipArchive::CREATE) !== true){
Log::error("cannot open <$zipFileFullPath>");
return false;
Expand All@@ -39,11 +39,12 @@ public function createMarkdownZip($markdown, $path, $markdownFilename): bool|str
// markdown image title: ![](images/default.svg "admin")
$tmp = explode(' ', $attachment);
$filename = $tmp[0];
if (!file_exists($path . $filename)){
$filepath = $path . DIRECTORY_SEPARATOR . $filename;
if (!file_exists($filepath)){
error_log("文件不存在:$filename");
continue;
}
$this->zipArchive->addFile($path . $filename, $filename);
$this->zipArchive->addFile($filepath, $filename);
}
}
$this->zipArchive->close();
Expand Down
1 change: 1 addition & 0 deletions app/Confluence.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,6 +40,7 @@ public function htmlFile2Markdown(string $filename): string
'|<span class="confluence-embedded-file-wrapper">.*</span>|',
'|<div class="drop-zone-empty-text">.*</div>|s',
'|<li class="drop-zone-text hidden">.*</li>|s',
'|<a class="confluence-userlink url fn".*</a>|',
'|<img .* src="data:.*/>|',
],
'',
Expand Down
8 changes: 8 additions & 0 deletions tests/Unit/ConfluenceTest.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,6 +26,14 @@ public function testHtmlFile2Markdown()
$this->assertEquals("你好\n==", $markdown);
}

public function testHtmlFile2MarkdownUserLink()
{
$confluence = new Confluence();
$markdown = file_get_contents($this->dataDir . 'confluence/space1/image-demo_65619.md');
$newMarkdown = $confluence->htmlFile2Markdown($this->dataDir . 'confluence/space1/image-demo_65619.html');
$this->assertEquals(trim($markdown), $newMarkdown);
}

public function testParsePagesTree()
{
$document = new DOMDocument();
Expand Down