Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Mar 5, 2023. It is now read-only.

Commit de500f1

Browse files
Consider first major (#73)
* removing unused dependencies * update tests * update performance tests * dependency check * update performance tests * performance tests * test * tests * tests * tests * tests * tests * tests * tests * Update SimpleTest.php * test
1 parent 2e9c756 commit de500f1

File tree

10 files changed

+535
-333
lines changed

10 files changed

+535
-333
lines changed

‎composer.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
}
1111
],
1212
"require": {
13-
"php": "~7.0|^8.0",
14-
"8fold/php-shoop-shelf": "~0.8.4",
13+
"php": "~7.2|^8.0",
14+
"8fold/php-shoop-shelf": "~0.8.5",
1515
"8fold/php-html-spec": "~0.0.3",
1616
"nesbot/carbon": "~2.5"
1717
},

‎composer.lock‎

Lines changed: 485 additions & 234 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/UIKit/Elements/Compound/Markdown.php‎

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44

55
use Eightfold\Markup\Html\HtmlElement;
66

7-
use League\CommonMark\Extension\Table\TableExtension;
8-
use League\CommonMark\Extension\TaskList\TaskListExtension;
9-
10-
use Eightfold\Shoop\Apply;
11-
127
use Eightfold\ShoopShelf\Shoop;
138

149
class Markdown extends HtmlElement
@@ -31,53 +26,50 @@ public function __construct(string $markdown, array $config = [])
3126
public function caseSensitive($caseSensitive = true)
3227
{
3328
$this->caseSensitive = $caseSensitive;
29+
3430
return $this;
3531
}
3632

3733
public function markdownReplacements($replacements = [])
3834
{
3935
$this->markdownReplacements = $replacements;
36+
4037
return $this;
4138
}
4239

4340
public function htmlReplacements($replacements = [])
4441
{
4542
$this->htmlReplacements = $replacements;
43+
4644
return $this;
4745
}
4846

4947
public function trim($trim = true)
5048
{
5149
$this->trim = $trim;
50+
5251
return $this;
5352
}
5453

5554
public function minified($minified = true)
5655
{
5756
$this->minified = $minified;
57+
5858
return $this;
5959
}
6060

6161
public function extensions(...$extensions)
6262
{
63-
if (Apply::isEmpty()->unfoldUsing($extensions)) {
64-
$this->extensions = Shoop::this([
65-
TableExtension::class,
66-
TaskListExtension::class
67-
]);
68-
69-
} else {
70-
$this->extensions = Shoop::this($extensions);
71-
72-
}
73-
$this->extensions = $this->extensions->drop(fn($v) => empty($v))->unfold();
63+
$this->extensions = Shoop::this($extensions)
64+
->drop(fn($v) => empty($v))->unfold();
7465

7566
return $this;
7667
}
7768

7869
public function prepend(string $markdown)
7970
{
8071
$this->markdown = $markdown . $this->markdown;
72+
8173
return $this;
8274
}
8375

‎tests/Element/ElementTest.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ public function from_fold()
2626
'<container id="hello">',
2727
"string",
2828
14.76, // 14.59, // shoopified 7.17, // 5.29, // 4.56, // 4.02,
29-
437 // 436 // 433 // 427 // 426 // 401 // 397 // 394 // 393
29+
475// 437 // 436 // 433 // 427 // 426 // 401 // 397 // 394 // 393
3030
)->unfoldUsing(
3131
Element::fold("container")->attr("id hello")->omitEndTag(true)
3232
);
3333

3434
AssertEquals::applyWith(
3535
'<container id="goodbye">',
3636
"string",
37-
0.85, // 0.5, // 0.42, // 0.27, // 0.26, // 0.25,
37+
3.36, // 1.9, // 0.85, // 0.5, // 0.42, // 0.27, // 0.26, // 0.25,
3838
1
3939
)->unfoldUsing(
4040
Element::fold("container")->attr("id hello")->omitEndTag(true)
@@ -53,7 +53,7 @@ public function from_fold()
5353
AssertEquals::applyWith(
5454
'<p><span>Hello, World!</span></p>',
5555
"string",
56-
7.08, // 3.95,
56+
11.26, // 7.08, // 3.95,
5757
470 // 311
5858
)->unfoldUsing(
5959
Element::fold("p",
@@ -88,7 +88,7 @@ public function self_contained_element()
8888
AssertEquals::applyWith(
8989
'<a href="/path"></a>',
9090
"string",
91-
0.32, // 0.3, // 0.27, // 0.21, // 0.2,
91+
1.25, // 1.23, // 1.21, // 1.03, // 0.32, // 0.3, // 0.27, // 0.21, // 0.2,
9292
1
9393
)->unfoldUsing(
9494
new Element("a", ["href /path"], false)
@@ -136,7 +136,7 @@ public function attribute_list()
136136
AssertEquals::applyWith(
137137
["id" => "hello"],
138138
"array",
139-
0.07,
139+
0.35, // 0.28, // 0.21, // 0.07,
140140
1
141141
)->unfoldUsing(
142142
(new Element("hello", ["id hello"]))->attrList(false)
@@ -145,7 +145,7 @@ public function attribute_list()
145145
AssertEquals::applyWith(
146146
["id" => "hello"],
147147
"array",
148-
0.42, // 0.25, // 0.21, // 0.18, // 0.17, // increase shoop 0.13, // 0.11, // 0.09,
148+
1.09, // 1.01, // 1, // 0.94, // 0.86, // 0.81, // 0.42, // 0.25, // 0.21, // 0.18, // 0.17, // increase shoop 0.13, // 0.11, // 0.09,
149149
1
150150
)->unfoldUsing(
151151
Element::fold("hello")->attr("id hello")->attrList(false)
@@ -160,7 +160,7 @@ public function testPage()
160160
AssertEquals::applyWith(
161161
'<html><head><title>Hello, World!</title><style></style></head><body><img src="http://example.com" alt="A picture of the world"><p is="my-component" required>Hello, World!</p><my-link href="http://example.com/domination">World Domination</my-link><p>Done!</p></body></html>',
162162
"string",
163-
5.71,
163+
16.26, // 13.11, // 5.71,
164164
397
165165
)->unfoldUsing(
166166
Element::fold('html',

‎tests/Html/HtmlElementTest.php‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function test_ordering_lightweight()
2626
AssertEquals::applyWith(
2727
'<p role="alert" id="something" class="somethingElse somethingElse2" style="background: red;" type="some_type" tabindex="1" accesskey="S">Hello</p>',
2828
"string",
29-
8.42, // 8.34, // 7.8, // 7.38, // updated shoop 8.11 // 7.82 // 7.6 // 6.85
29+
9.69, // 8.42, // 8.34, // 7.8, // 7.38, // updated shoop 8.11 // 7.82 // 7.6 // 6.85
3030
559
3131
)->unfoldUsing(
3232
Html::p('Hello')
@@ -50,7 +50,7 @@ public function full_page()
5050
AssertEquals::applyWith(
5151
'<div><div></div></div>',
5252
"string",
53-
2.48, // 1.99, // 1.48, // 1.29, // updated shoop 5.24 // 4.98
53+
4.12, // 3.19, // 2.48, // 1.99, // 1.48, // 1.29, // updated shoop 5.24 // 4.98
5454
1
5555
)->unfoldUsing(
5656
Html::div(Html::div())->unfold()
@@ -59,7 +59,7 @@ public function full_page()
5959
AssertEquals::applyWith(
6060
'<html><head><title>Hello, World!</title><style></style></head><body><img src="http://example.com" alt="A picture of the world"><p is="my-component">Hello, World!</p><my-link href="http://example.com/domination">World Domination</my-link><p>Done!</p></body></html>',
6161
"string",
62-
8.56, // 7.07, // 6.69, // 6.64, // 6.59, // 6.11, // 5.53, // 5.34, // 9.56 // 7.14 // 6.94
62+
18.93, // 18.84, // 18.13, // 17.62, // 15.45, // 8.56, // 7.07, // 6.69, // 6.64, // 6.59, // 6.11, // 5.53, // 5.34, // 9.56 // 7.14 // 6.94
6363
1
6464
)->unfoldUsing(
6565
Html::html(
@@ -88,7 +88,7 @@ public function child_elements_omitting_end_tag()
8888
AssertEquals::applyWith(
8989
'<object><param name="hello" value="world"><param name="you" value="are"><param name="awesome" value="today!"></object>',
9090
"string",
91-
5.34, // 4.11, // 3.51, // 3.01, // updated shoop 6.87 // 6.67 // 6.24
91+
15.21, // 12.75, // 12.57, // 9.17, // 5.34, // 4.11, // 3.51, // 3.01, // updated shoop 6.87 // 6.67 // 6.24
9292
1
9393
)->unfoldUsing(
9494
Html::object(
@@ -113,7 +113,7 @@ public function child_elements_omitting_end_tag()
113113
AssertEquals::applyWith(
114114
'<head><title>Hello, World!</title><link rel="stylesheet" href="#"><link rel="stylesheet" href="#"></head>',
115115
"string",
116-
4.93, // 4.86, // 4.73, // 4.01, // 3.14, // 2.84, // 5.24
116+
12.1, // 11.66, // 10.72, // 8.63, // 8.37, // 4.93, // 4.86, // 4.73, // 4.01, // 3.14, // 2.84, // 5.24
117117
1
118118
)->unfoldUsing(
119119
Html::head(
@@ -132,7 +132,7 @@ public function nested_elements_with_string()
132132
AssertEquals::applyWith(
133133
'<ul><li>Hello<ol><li>My name is:</li></ol></li></ul>',
134134
"string",
135-
4.95, // 4.16, // 3.04, // 3, // 2.88, // 2.78, // 2.53, // updated shoop 7.24
135+
10.23, // 8.76, // 8.22, // 6.19, // 4.95, // 4.16, // 3.04, // 3, // 2.88, // 2.78, // 2.53, // updated shoop 7.24
136136
1
137137
)->unfoldUsing(
138138
Html::ul(
@@ -148,7 +148,7 @@ public function nested_elements_with_string()
148148
AssertEquals::applyWith(
149149
'<a class="some-class" href="http://example.com">Hello</a>',
150150
"string",
151-
1.76, // 1.6, // 1.56, // 1.21, // 1.13, // 0.97, // 0.87, // 2.37
151+
3.99, // 3.93, // 3.9, // 3.75, // 3.32, // 1.76, // 1.6, // 1.56, // 1.21, // 1.13, // 0.97, // 0.87, // 2.37
152152
1
153153
)->unfoldUsing(
154154
Html::a('Hello')->attr('class some-class', 'href http://example.com')
@@ -164,7 +164,7 @@ public function all_passed_attributes_end_up_in_the_element()
164164
AssertEquals::applyWith(
165165
'<body role="document"></body>',
166166
"string",
167-
2.09, // 1.12, // 0.95, // 0.85, // 0.78, // updated shoop 4.13 // 6.15 // 6.12 // 5.76
167+
3, // 2.83, // 2.24, // 2.09, // 1.12, // 0.95, // 0.85, // 0.78, // updated shoop 4.13 // 6.15 // 6.12 // 5.76
168168
1
169169
)->unfoldUsing(
170170
Html::body()->attr("role document")->unfold()
@@ -173,7 +173,7 @@ public function all_passed_attributes_end_up_in_the_element()
173173
AssertEquals::applyWith(
174174
'<body role="application"></body>',
175175
"string",
176-
1.95, // 1.52, // 0.9, // 0.85, // 0.83, // 0.75, // 0.72, // 0.67, // 0.8 // 0.74 // 0.72 // 0.58 // 0.56 // 0.32 // 0.64 // 0.53 // 0.41
176+
6.98, // 3.25, // 2.81, // 2.59, // 2.56, // 2.29, // 1.95, // 1.52, // 0.9, // 0.85, // 0.83, // 0.75, // 0.72, // 0.67, // 0.8 // 0.74 // 0.72 // 0.58 // 0.56 // 0.32 // 0.64 // 0.53 // 0.41
177177
1
178178
)->unfoldUsing(
179179
Html::body()->attr("role application")->unfold()
@@ -182,7 +182,7 @@ public function all_passed_attributes_end_up_in_the_element()
182182
AssertEquals::applyWith(
183183
'<body id="acceptable"></body>',
184184
"string",
185-
1.17, // 0.9, // 0.72, // 0.76 // 0.7 // 0.68 // 0.57 // 0.25 // 0.19 // 5.85
185+
3.02, // 2.61, // 2.28, // 1.17, // 0.9, // 0.72, // 0.76 // 0.7 // 0.68 // 0.57 // 0.25 // 0.19 // 5.85
186186
1
187187
)->unfoldUsing(
188188
Html::body()->attr("id acceptable")->unfold()

‎tests/UIKit/CompoundTest.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function web_head()
6363
AssertEquals::applyWith(
6464
'<meta name="viewport" content="width=device-width,initial-scale=1"><link type="image/x-icon" rel="icon" href="favicon.ico"><link rel="stylesheet" href="main.css"><script src="main.js"></script>',
6565
"string",
66-
6.17, // 5.86, // 5.14, // 4.95, // 4.47, // 3.73,
66+
14.08, // 13.84, // 13.31, // 10.88, // 6.17, // 5.86, // 5.14, // 4.95, // 4.47, // 3.73,
6767
4 // 3
6868
)->unfoldUsing(
6969
UIKit::webHead()
@@ -76,7 +76,7 @@ public function web_head()
7676
AssertEquals::applyWith(
7777
'<meta name="viewport" content="width=device-width,initial-scale=1"><meta content="website" property="og:type"><meta content="8fold PHP Markup" property="og:title"><meta content="https://8fold.dev/open-source/markup/php" property="og:url"><meta content="Get the HTML out of your PHP with this HTML generator." property="og:description"><meta name="twitter:card" content="summary_large_image"><meta name="twitter:site" content="8foldPros">',
7878
"string",
79-
14.88, // 12.25, // 7.47,
79+
27.96, // 24.18, // 22.08, // 21.04, // 19.46, // 14.88, // 12.25, // 7.47,
8080
570
8181
)->unfoldUsing(
8282
UIKit::webHead()->social(
@@ -100,7 +100,7 @@ public function accordion()
100100
AssertEquals::applyWith(
101101
'<h2 is="accordion"><button id="'. $summaryId .'" aria-controls="'. $summaryId .'-panel" aria-expanded="true">'. $summary .'</button></h2><div is="accordion-panel" role="region" id="'. $summaryId .'-panel" tabindex="-1" aria-hidden="false" aria-labelledby="'. $summaryId .'">'. $content->unfold() .'</div>',
102102
"string",
103-
7.36, // 5.78
103+
18.54, // 17.82, // 17.66, // 17.01, // 13.7, // 7.36, // 5.78
104104
13
105105
)->unfoldUsing(
106106
UIKit::accordion($summaryId, $summary, $content)

‎tests/UIKit/MarkdownTest.php‎

Lines changed: 9 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
use Eightfold\Markup\UIKit;
99

10-
use Eightfold\CommonMarkAbbreviations\AbbreviationExtension;
10+
use League\CommonMark\Extension\Table\TableExtension;
1111

1212
/**
1313
* @group Markdown
@@ -29,9 +29,6 @@ private function docTable()
2929
|Header 1 |Header 2 |
3030
|:--------|:--------|
3131
|Cell 1 |Cell 2 |
32-
33-
- [ ] Task 1
34-
- [x] Task 2
3532
EOD;
3633
}
3734

@@ -44,16 +41,16 @@ public function basic()
4441
'<h1>Heading</h1><p>Content</p>',
4542
"string",
4643
30.48, // 13.06, // 12.69, // 11.83, // 11.8,
47-
1100
44+
1868// 1758 // 1658 // 1100
4845
)->unfoldUsing(
4946
UIKit::markdown($this->doc())
5047
);
5148

5249
AssertEquals::applyWith(
5350
'<p>Hello, World!</p>',
5451
"string",
55-
0.84, // 0.22, // 0.18, // 0.16,
56-
39
52+
0.99, // 0.84, // 0.22, // 0.18, // 0.16,
53+
42// 39
5754
)->unfoldUsing(
5855
UIKit::markdown("Hello, World!")
5956
);
@@ -105,57 +102,19 @@ public function remove()
105102
/**
106103
* @test
107104
*/
108-
public function no_extensions()
109-
{
110-
AssertEquals::applyWith(
111-
'<p>|Header 1 |Header 2 ||:--------|:--------||Cell 1 |Cell 2 |</p><ul><li>[ ] Task 1</li><li>[x] Task 2</li></ul>',
112-
"string",
113-
15.17,
114-
1144
115-
)->unfoldUsing(
116-
UIKit::markdown($this->docTable())
117-
);
118-
}
119-
120-
/**
121-
* @test
122-
* @group current
123-
*/
124105
public function default_extensions()
125106
{
126-
$expected = '<table><thead><tr><th align="left">Header 1</th><th align="left">Header 2</th></tr></thead><tbody><tr><td align="left">Cell 1</td><td align="left">Cell 2</td></tr></tbody></table><ul><li><input disabled="" type="checkbox"> Task 1</li><li><input checked="" disabled="" type="checkbox"> Task 2</li></ul>';
107+
$expected = '<table><thead><tr><th align="left">Header 1</th><th align="left">Header 2</th></tr></thead><tbody><tr><td align="left">Cell 1</td><td align="left">Cell 2</td></tr></tbody></table>';
127108

128109
AssertEquals::applyWith(
129110
$expected,
130111
"string",
131112
21.68,
132113
1459
133114
)->unfoldUsing(
134-
UIKit::markdown($this->docTable())->extensions()
135-
);
136-
}
137-
138-
/**
139-
* @test
140-
*/
141-
public function abbreviation_allow_html()
142-
{
143-
$doc = <<<EOD
144-
[.abbr](abbreviation)
145-
146-
<abbr title="abbreviation">abbr</abbr>
147-
EOD;
148-
149-
$expected = '<p><abbr title="abbreviation">abbr</abbr></p><p><abbr title="abbreviation">abbr</abbr></p>';
150-
151-
AssertEquals::applyWith(
152-
$expected,
153-
"string",
154-
4.21,
155-
139 // 68
156-
)->unfoldUsing(
157-
UIKit::markdown($doc, ['html_input' => 'allow'])
158-
->extensions(AbbreviationExtension::class)
115+
UIKit::markdown($this->docTable())->extensions(
116+
new TableExtension()
117+
)
159118
);
160119
}
161120

@@ -171,7 +130,7 @@ public function testCanPrepend()
171130
AssertEquals::applyWith(
172131
'<h1>Heading</h1><p>Base</p>',
173132
"string",
174-
0.59, // 0.47,
133+
1.21, // 0.98, // 0.88, // 0.86, // 0.59, // 0.47,
175134
48
176135
)->unfoldUsing(
177136
UIKit::markdown($doc)->prepend("# Heading\n\n")

‎tests/UIKit/PageTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function web_view()
2121
AssertEquals::applyWith(
2222
'<!doctype html><html><head><title>UIKit</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"></head><body class="theme"><p>Hello, World!</p></body></html>',
2323
"string",
24-
13.74, // 10.21 // 9.69 // 9.46
24+
17.82, // 17.28, // 13.74, // 10.21 // 9.69 // 9.46
2525
596
2626
)->unfoldUsing(
2727
UIKit::webView(

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /