-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathConfluenceHtml2MarkdownCommand.php
More file actions
42 lines (37 loc) · 1.02 KB
/
ConfluenceHtml2MarkdownCommand.php
File metadata and controls
42 lines (37 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace App\Commands;
use App\Confluence;
use LaravelZero\Framework\Commands\Command;
class ConfluenceHtml2MarkdownCommand extends Command
{
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'confluence:html2markdown
{html_path : HTML 文件路径,如 ./confluence/space1/231543.html}
';
/**
* The description of the command.
*
* @var string
*/
protected $description = 'Confluence HTML 转 Markdown';
/**
* Execute the console command.
*
*/
public function handle(Confluence $confluence): int
{
$htmlPath = $this->argument('html_path');
$dataDir = dirname($htmlPath);
$page = basename($htmlPath);
$markdown = $confluence->htmlFile2Markdown($htmlPath);
$mdFilename = substr($page, 0, -5) . '.md';
$mdPath = $dataDir . DIRECTORY_SEPARATOR . $mdFilename;
file_put_contents($mdPath, $markdown . "\n");
$this->info($mdPath);
return 0;
}
}