anchors 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +24 -4
- data/lib/anchors.rb +3 -3
- data/lib/anchors/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49d66a136f6d898f5091eaf0c03a792cb20839e8
|
4
|
+
data.tar.gz: 872634dddccb96495cd7613d077d8caf88046d33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab0b55b34707741d344b98480b70ee77e6a700dd73d63ff484bac6fe06d22cd3a86d0c02e5022c225560516e85f8881c2236986539a7a689c1e152b1b25fa23b
|
7
|
+
data.tar.gz: 6bc51cacae25847e5ea3903f4b8d2dcd368e28f46c0bbb07fab66d68a30559be4f4de29bfb0b30ff1bd56e0155965a77958652f642702ac3a6205a5623e185d0
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,26 @@
|
|
1
1
|
# ⚓ Anchors ⚓
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/bradgessler/anchors.svg?branch=master)](https://travis-ci.org/bradgessler/anchors)
|
4
|
+
|
5
|
+
This gem will add anchors to all of your websites h1-h6 headers. Its useful for static website generators, like Middleman. It turns this:
|
6
|
+
|
7
|
+
```html
|
8
|
+
<body>
|
9
|
+
<h1>How are you?</h1>
|
10
|
+
<h2>I am fine<img src='hi.gif'/></h2>
|
11
|
+
<h3>How are you?</h3>
|
12
|
+
</body>
|
13
|
+
```
|
14
|
+
|
15
|
+
into this:
|
16
|
+
|
17
|
+
```html
|
18
|
+
<body>
|
19
|
+
<h1 id="how_are_you"><a href="#how_are_you">How are you?</a></h1>
|
20
|
+
<h2 id="i_am_fine"><a href="#i_am_fine">I am fine<img src="hi.gif"></a></h2>
|
21
|
+
<h3 id="how_are_you_2"><a href="#how_are_you_2">How are you?</a></h3>
|
22
|
+
</body>
|
23
|
+
```
|
4
24
|
|
5
25
|
## Installation
|
6
26
|
|
@@ -29,14 +49,14 @@ use Anchors::Middleware
|
|
29
49
|
|
30
50
|
and the `body` will automatically have anchors applied to all of the h1-h6 tags.
|
31
51
|
|
32
|
-
|
52
|
+
You can even customize it a bit:
|
33
53
|
|
34
54
|
```ruby
|
35
55
|
require "anchors"
|
36
56
|
use Anchors::Middleware,
|
37
57
|
css: "section.anchorize", # CSS headers are applied to. Defaults to 'body'
|
38
|
-
seperator: "-",
|
39
|
-
link: false
|
58
|
+
seperator: "-", # Change the seperator in the header. Defaults to '_'
|
59
|
+
link: false # Don't convert the headers into links to their own anchors. Defaults to 'true'.
|
40
60
|
```
|
41
61
|
|
42
62
|
## Development
|
data/lib/anchors.rb
CHANGED
@@ -28,15 +28,15 @@ module Anchors
|
|
28
28
|
private
|
29
29
|
# Super lame, but awesome way to get CSS options CSS selector.
|
30
30
|
def css
|
31
|
-
options
|
31
|
+
options.fetch :css, CSS_SELECTOR
|
32
32
|
end
|
33
33
|
|
34
34
|
def seperator
|
35
|
-
options
|
35
|
+
options.fetch :seperator, SEPERATOR
|
36
36
|
end
|
37
37
|
|
38
38
|
def link?
|
39
|
-
options
|
39
|
+
options.fetch :link, LINK
|
40
40
|
end
|
41
41
|
|
42
42
|
def dom_id(el)
|
data/lib/anchors/version.rb
CHANGED