hagenburger / pimd

PIMD – Processing Instructions for Markdown
https://hagenburger.github.io/pimd-docs/
MIT License
20 stars 5 forks source link

Showmore plugin: Allow negative numbers #77

Open hagenburger opened 6 years ago

hagenburger commented 6 years ago

Existing functionality

Video preview of Showmore plugin

Detailed documentation: https://github.com/hagenburger/pimd/tree/master/plugins/showmore#readme

New feature

To allow more easy counting, allow negative numbers:

```html +showmore=2..-2
<ul>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>

Should have the same result as:

````markdown
```html +showmore=2..11
<ul>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>

And should look like:

```html
<ul>
  ···
</ul>

The counting works like:

 1 -12 <ul>
 2 -11   <li></li>
 3 -10   <li></li>
 4  -9   <li></li>
 5  -8   <li></li>
 6  -7   <li></li>
 7  -6   <li></li>
 8  -5   <li></li>
 9  -4   <li></li>
10  -3   <li></li>
11  -2   <li></li>
12  -1 </ul>

Both numbers of the range can be negative:

```html +showmore=-3..-1
<ul>
  <li></li>
  <li></li>
</ul>

Should result in:

```html
<ul>
  ···