Skip to content

Commit 84342c7

Browse files
committed
Merge branch 'release/4.1.2'
2 parents 14c1f06 + c8f6404 commit 84342c7

File tree

8 files changed

+71
-13
lines changed

8 files changed

+71
-13
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# v4.1.2
2+
## 06/22/2019
3+
4+
1. [](#new)
5+
* Added new `h#` tags for `h1` through `h6` supporting `class` and `id` attributes
6+
1. [](#improved)
7+
* Make `ShortcodeManager::setStates()` more flexible to accept any type of object
8+
19
# v4.1.1
210
## 04/23/2019
311

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,24 @@ or
158158
[/div]
159159
```
160160
161+
#### Headers
162+
163+
Allows you to add `id` and `class` attributes to HTML `h1` through `h6` tags:
164+
165+
```
166+
[h1 class="major"]This is my title[/h1]
167+
```
161168
162169
#### Span
163170
164-
Allows you to wrap markdown in an HTML `span` tag that supports both `id` and `classes` attributes
171+
Allows you to wrap markdown in an HTML `span` tag that supports both `id` and `class` attributes
165172
166173
```
167174
[span class="text-center"]
168175
This text is **centered** aligned
169176
[/span]
170177
```
171178
172-
173179
#### Columns
174180
175181
Take advantage of powerful CSS columns support by using this shortcode

blueprints.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Shortcode Core
2-
version: 4.1.1
2+
version: 4.1.2
33
description: "This plugin provides the core functionality for shortcode plugins"
44
icon: code
55
author:

classes/ShortcodeManager.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,14 @@ public function processShortcodes($str)
272272
}
273273

274274
/**
275-
* set a state of a particular shortcode with a hash for retrieval later
275+
* set a state of a particular item with a hash for retrieval later
276276
*
277277
* @param string $hash a unique hash code
278-
* @param ShortcodeInterface $shortcode the shortcode to store
278+
* @param object $item some item to store
279279
*/
280-
public function setStates($hash, ShortcodeInterface $shortcode)
280+
public function setStates($hash, $item)
281281
{
282-
$this->states[$hash][] = $shortcode;
282+
$this->states[$hash][] = $item;
283283
}
284284

285285
/**

shortcodes/AlignShortcode.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
namespace Grav\Plugin\Shortcodes;
33

44
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
5-
use Thunder\Shortcode\Shortcode\ProcessedShortcode;
65

76
class AlignShortcode extends Shortcode
87
{
98
public function init()
109
{
11-
$this->shortcode->getHandlers()->add('center', function(ProcessedShortcode $sc) {
10+
$this->shortcode->getHandlers()->add('center', function(ShortcodeInterface $sc) {
1211
return '<div style="text-align: center;">'.$sc->getContent().'</div>';
1312
});
1413

shortcodes/ColumnsShortcode.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
namespace Grav\Plugin\Shortcodes;
33

44
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
5-
use Thunder\Shortcode\Shortcode\ProcessedShortcode;
65

76
class ColumnsShortcode extends Shortcode
87
{
98
public function init()
109
{
11-
$this->shortcode->getHandlers()->add('columns', function(ProcessedShortcode $sc) {
10+
$this->shortcode->getHandlers()->add('columns', function(ShortcodeInterface $sc) {
1211

1312
$column_count = intval($sc->getParameter('count', 2));
1413
$column_width = $sc->getParameter('width', 'auto');

shortcodes/HShortcode.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
namespace Grav\Plugin\Shortcodes;
3+
4+
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
5+
6+
class HShortcode extends Shortcode
7+
{
8+
public function init()
9+
{
10+
$this->shortcode->getRawHandlers()->add('h1', function(ShortcodeInterface $sc) {
11+
return $this->header(1, $sc);
12+
});
13+
14+
$this->shortcode->getRawHandlers()->add('h2', function(ShortcodeInterface $sc) {
15+
return $this->header(2, $sc);
16+
});
17+
18+
$this->shortcode->getRawHandlers()->add('h3', function(ShortcodeInterface $sc) {
19+
return $this->header(3, $sc);
20+
});
21+
22+
$this->shortcode->getRawHandlers()->add('h4', function(ShortcodeInterface $sc) {
23+
return $this->header(4, $sc);
24+
});
25+
26+
$this->shortcode->getRawHandlers()->add('h5', function(ShortcodeInterface $sc) {
27+
return $this->header(5, $sc);
28+
});
29+
30+
$this->shortcode->getRawHandlers()->add('h6', function(ShortcodeInterface $sc) {
31+
return $this->header(6, $sc);
32+
});
33+
34+
35+
}
36+
37+
protected function header($level, $sc)
38+
{
39+
$id = $sc->getParameter('id');
40+
$class = $sc->getParameter('class');
41+
$tag = 'h' . $level;
42+
43+
$id_output = $id ? ' id="' . $id . '" ': '';
44+
$class_output = $class ? ' class="' . $class . '"' : '';
45+
return "<{$tag}{$id_output}{$class_output}>{$sc->getContent()}</{$tag}>";
46+
}
47+
}

shortcodes/MarkShortcode.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
namespace Grav\Plugin\Shortcodes;
33

44
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
5-
use Thunder\Shortcode\Shortcode\ProcessedShortcode;
65

76
class MarkShortcode extends Shortcode
87
{
98
public function init()
109
{
11-
$this->shortcode->getHandlers()->add('mark', function(ProcessedShortcode $sc) {
10+
$this->shortcode->getHandlers()->add('mark', function(ShortcodeInterface $sc) {
1211
$style = $sc->getParameter('style', $this->getBbCode($sc));
1312
$class = $sc->getParameter('class', 'default');
1413

0 commit comments

Comments
 (0)