Skip to content

Commit f652963

Browse files
committed
feat: #60 ignore space contributors
1 parent b5c0a2a commit f652963

File tree

4 files changed

+86
-1
lines changed

4 files changed

+86
-1
lines changed

app/Confluence.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ public function htmlFile2Markdown(string $filename): string
5252
$contentElement = $this->document->getElementById('main-content');
5353
$divElements = $contentElement->getElementsByTagName('div');
5454
foreach ($divElements as $divElement) {
55-
if ($divElement->getAttribute('class') == 'recently-updated recently-updated-social') {
55+
if (
56+
in_array($divElement->getAttribute('class'), [
57+
'recently-updated recently-updated-social',
58+
'plugin-contributors',
59+
])
60+
) {
5661
$divElement->parentNode->parentNode->removeChild($divElement->parentNode);
5762
}
5863
}

tests/Unit/ConfluenceTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,12 @@ public function testIgnoreRecentSpaceActivity()
123123
$newMarkdown = $confluence->htmlFile2Markdown($this->dataDir . 'confluence/recent-space-activity-demo.html');
124124
$this->assertEquals(trim($markdown), $newMarkdown);
125125
}
126+
127+
public function testIgnoreSpaceContributors()
128+
{
129+
$confluence = new Confluence();
130+
$markdown = file_get_contents($this->dataDir . 'confluence/space-contributors-demo.md');
131+
$newMarkdown = $confluence->htmlFile2Markdown($this->dataDir . 'confluence/space-contributors-demo.html');
132+
$this->assertEquals(trim($markdown), $newMarkdown);
133+
}
126134
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>空间 1 : Image Demo</title>
5+
<link rel="stylesheet" href="styles/site.css" type="text/css"/>
6+
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
7+
</head>
8+
9+
<body class="theme-default aui-theme-default">
10+
<div id="page">
11+
<div id="main" class="aui-page-panel">
12+
<div id="main-header">
13+
<div id="breadcrumb-section">
14+
<ol id="breadcrumbs">
15+
<li class="first">
16+
<span><a href="index.html">Demo</a></span>
17+
</li>
18+
<li>
19+
<span><a href="65591.html">Demo</a></span>
20+
</li>
21+
</ol>
22+
</div>
23+
<h1 id="title-heading" class="pagetitle">
24+
<span id="title-text">
25+
空间 1 : Image Demo
26+
</span>
27+
</h1>
28+
</div>
29+
30+
<div id="content" class="view">
31+
<div class="page-metadata">
32+
Created by <span class='author'> admin</span>, last modified on 七月 05, 2021
33+
</div>
34+
<div id="main-content" class="wiki-content group">
35+
<h1>hello</h1>
36+
<div class="cell normal" data-type="normal">
37+
<div class="innerCell">
38+
<h2 id="PDA首页-Spacecontributors">Space contributors</h2><p>
39+
</p><div class="plugin-contributors">
40+
<ul class="contributors-list">
41+
<li>
42+
<a href="http://wiki.pagoda.com.cn/display/~20200921007">张三</a> (59天以前) </li>
43+
<li>
44+
<a href="http://wiki.pagoda.com.cn/display/~zhouyi">周1</a> (340天以前) </li>
45+
<li>
46+
<a href="http://wiki.pagoda.com.cn/display/~weiyi">魏1</a> (428天以前) </li>
47+
<li>
48+
<a href="http://wiki.pagoda.com.cn/display/~lisi">李四</a> (736天以前) </li>
49+
</ul>
50+
</div>
51+
<p></p></div>
52+
</div>
53+
<p>Hello World!</p>
54+
</div>
55+
56+
</div>
57+
</div>
58+
<div id="footer" role="contentinfo">
59+
<section class="footer-body">
60+
<p>Document generated by Confluence on 七月 05, 2021 18:26</p>
61+
<div id="footer-logo"><a href="http://www.atlassian.com/">Atlassian</a></div>
62+
</section>
63+
</div>
64+
</div>
65+
</body>
66+
</html>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
hello
2+
=====
3+
4+
5+
6+
Hello World!

0 commit comments

Comments
 (0)