bhook 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8daa36a6bba5cff236d6bf93f33ff088d7baa4abb975fe372674c94746e3600
4
- data.tar.gz: 499905877d932384d7cb982290ed6bfced51398b63a85ef3101a625783f2113b
3
+ metadata.gz: 144ecf729bff710fb2848d0e64a1bd2c9aa2b1178ce079760f3cb7f0fa3cbb74
4
+ data.tar.gz: a615cb26c8c45647ca9dba86f382c84344e76e0710c7f1408f5cffee0022cc09
5
5
  SHA512:
6
- metadata.gz: e7538dd31e1790aab7fabca99e652ff97752c52bd0afeb7ade8d42d517eee6bd2f6687e642c06b95afe4e51cc48724b84646f6f9ee5803d3a73ae9b23f64023e
7
- data.tar.gz: 1d5aa665979f1be6f1ba0a96d7068622c782e604a1407a0757e6d254f538dde59507972e15412fcb7141d38f430ff0897c9e95ca8b3a6227b727f575d32bfb36
6
+ metadata.gz: 37caec4b0a9144b8a918b9af5d30ed84ae1882f22e2d29e1bd17dcfd03671865027c1a18cd8cd1c6f6931013cfac766a9f9e1096234cb9d8034ca49f791314fb
7
+ data.tar.gz: afe25a780b1f31a937876d33178142b0236341eccce7092db264668863f0cdfa8ed1473a4c0159465b1211e00bd7ea8761830be3b578852ab80d87c9e21a7659
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bhook (0.2.0)
4
+ bhook (0.2.1)
5
5
  git (~> 1.10)
6
6
  kramdown (~> 2.3)
7
7
  listen (~> 3.7)
@@ -24,21 +24,28 @@ module Bhook
24
24
 
25
25
  sig { params(el: Kramdown::Element, indent: Integer).returns(String) }
26
26
  def convert_header(el, indent)
27
- header = super(el, indent)
28
27
  src_title = el.options[:raw_text]
29
28
  after_h1_html = @options[:after_h1_strategy].call(binding)
30
29
 
31
30
  level = output_header_level(el.options[:level])
32
31
  if level == 1
33
32
  @options[:h1_callback].call(src_title)
34
- "#{header}#{' ' * indent}#{after_h1_html}"
33
+ "#{super(el, indent)}#{' ' * indent}#{after_h1_html}"
35
34
  else
36
- header
35
+ insert_anchor_into_header!(el)
36
+ super(el, indent)
37
37
  end
38
38
  end
39
39
 
40
40
  private
41
41
 
42
+ sig { params(el: Kramdown::Element).void }
43
+ def insert_anchor_into_header!(el)
44
+ el.attr['id'] = generate_id(el.options[:raw_text]) if @options[:auto_ids] && !el.attr['id']
45
+ anchor = Kramdown::Element.new(:a, '', { 'href' => "##{el.attr['id']}", 'class' => 'header-anchor' })
46
+ el.children << anchor
47
+ end
48
+
42
49
  sig { params(href_path: String).returns(T::Boolean) }
43
50
  def valid_relative_md_link?(href_path)
44
51
  (href_path.end_with?('.md') || href_path.include?('.md#')) &&
@@ -1,82 +1,111 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
- <meta name="viewport" content="width=device-width, initial-scale=1">
7
- <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
8
- <link href='https://fonts.googleapis.com/css?family=Fira+Sans' rel='stylesheet' type='text/css'>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
8
+ <link href='https://fonts.googleapis.com/css?family=Fira+Sans' rel='stylesheet' type='text/css'>
9
9
 
10
- <!-- Bootstrap -->
11
- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
12
- <style>
13
- body {
14
- font-family: 'Fira Sans', sans-serif;
15
- color: #000000;
16
- }
17
-
18
- h2, h5 {
19
- margin-bottom: 0.5em;
20
- }
21
-
22
- .after-h1 {
23
- border-bottom: 1px solid #bbbbbb;
24
- margin-bottom: 1.5em;
25
- }
26
-
27
- .footer {
28
- margin: 0.5em 0 1.5em 0;
29
- }
30
-
31
- table {
32
- margin: 0.5em 0 0.5em 0.5em;
33
- }
34
-
35
- table thead tr {
36
- background: #eeeeee;
37
- }
38
-
39
- table td, table th {
40
- padding: 0.1em 1em 0.1em 1em;
41
- border: 1px solid #bbbbbb;
42
- }
10
+ <!-- Bootstrap -->
11
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
12
+ <style>
13
+ body {
14
+ font-family: 'Fira Sans', sans-serif;
15
+ color: #000000;
16
+ }
43
17
 
44
- blockquote {
18
+ h2, h3, h4, h5 {
19
+ margin-bottom: 0.5em;
20
+ margin-top: 0.5em;
21
+ }
22
+
23
+ h2 {
24
+ border-bottom: 1px solid #eaeaea;
25
+ }
26
+
27
+ h2 a.header-anchor, h3 a.header-anchor,
28
+ h4 a.header-anchor, h5 a.header-anchor {
29
+ float: left;
30
+ margin-left: -20px;
31
+ text-decoration: none;
32
+ outline: none;
33
+ position: relative;
34
+ }
35
+
36
+ h2 a.header-anchor:after, h3 a.header-anchor:after,
37
+ h4 a.header-anchor:after, h5 a.header-anchor:after {
38
+ content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%23333' fill-rule='evenodd' d='M9.683 6.676l-.047-.048C8.27 5.26 6.07 5.243 4.726 6.588l-2.29 2.29c-1.344 1.344-1.328 3.544.04 4.91 1.366 1.368 3.564 1.385 4.908.04l1.753-1.752c-.695.074-1.457-.078-2.176-.444L5.934 12.66c-.634.634-1.67.625-2.312-.017-.642-.643-.65-1.677-.017-2.312L6.035 7.9c.634-.634 1.67-.625 2.312.017.024.024.048.05.07.075l.003-.002c.36.36.943.366 1.3.01.355-.356.35-.938-.01-1.3l-.027-.024zM6.58 9.586l.048.05c1.367 1.366 3.565 1.384 4.91.04l2.29-2.292c1.344-1.343 1.328-3.542-.04-4.91-1.366-1.366-3.564-1.384-4.908-.04L7.127 4.187c.695-.074 1.457.078 2.176.444l1.028-1.027c.635-.634 1.67-.624 2.313.017.643.644.652 1.678.018 2.312l-2.43 2.432c-.635.634-1.67.624-2.313-.018-.024-.024-.048-.05-.07-.075l-.003.004c-.36-.362-.943-.367-1.3-.01-.355.355-.35.937.01 1.3.01.007.018.015.027.023z'/%3E%3C/svg%3E");
39
+ box-sizing: border-box;
40
+ font-size: medium;
41
+ visibility: hidden;
42
+ }
43
+
44
+ h2:hover a.header-anchor:after, h3:hover a.header-anchor:after,
45
+ h4:hover a.header-anchor:after, h5:hover a.header-anchor:after {
46
+ visibility: visible;
47
+ }
48
+
49
+ div.after-h1 {
50
+ border-bottom: 1px solid #bbbbbb;
51
+ margin-bottom: 1.5em;
52
+ }
53
+
54
+ div.footer {
55
+ margin: 0.5em 0 1.5em 0;
56
+ }
57
+
58
+ table {
59
+ margin: 0.5em 0 1em 0.5em;
60
+ }
61
+
62
+ table thead tr {
63
+ background: #eeeeee;
64
+ }
65
+
66
+ table td, table th {
67
+ padding: 0.1em 1em 0.1em 1em;
68
+ border: 1px solid #bbbbbb;
69
+ }
70
+
71
+ blockquote {
45
72
  border-left: 10px solid #cccccc;
46
73
  background: #eeeeee;
47
74
  display: inline-block;
48
75
  padding: 1em;
49
- }
50
- </style>
51
- <!-- Global site tag (gtag.js) - Google Analytics -->
52
- <script async src="https://www.googletagmanager.com/gtag/js?id=G-CT9TWBW0WR"></script>
53
- <script>
54
- window.dataLayer = window.dataLayer || [];
55
- function gtag(){dataLayer.push(arguments);}
56
- gtag('js', new Date());
57
-
58
- gtag('config', 'G-CT9TWBW0WR');
59
- </script>
60
- <title><%= src_title -%></title>
61
- </head>
62
- <body>
63
- <div class="body container">
64
- <div class="content row justify-content-center">
65
- <div class="col-10">
66
- <%= output %>
67
- </div>
68
- </div>
69
- <div class="footer d-flex justify-content-center">
70
- <div>
71
- <% short_sha = src_file_sha ? src_file_sha[0..7] : nil -%>
72
- <% if file_url && short_sha -%>
73
- v. <a href="<%= file_url -%>"><%= short_sha -%></a>,
74
- <% elsif short_sha -%>
75
- v. <%= short_sha -%>,
76
- <% end -%>
77
- <%= src_file_date -%> © <a href="https://sidu.in">Sidu Ponnappa</a>
78
- </div>
79
- </div>
80
- </div>
81
- </body>
76
+ }
77
+ </style>
78
+ <!-- Global site tag (gtag.js) - Google Analytics -->
79
+ <script async src="https://www.googletagmanager.com/gtag/js?id=G-CT9TWBW0WR"></script>
80
+ <script>
81
+ window.dataLayer = window.dataLayer || [];
82
+ function gtag() { dataLayer.push(arguments); }
83
+ gtag('js', new Date());
84
+ gtag('config', 'G-CT9TWBW0WR');
85
+ </script>
86
+ <title><%= src_title -%></title>
87
+ </head>
88
+ <body>
89
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
90
+ <path fill="#333" fill-rule="evenodd" d="M9.683 6.676l-.047-.048C8.27 5.26 6.07 5.243 4.726 6.588l-2.29 2.29c-1.344 1.344-1.328 3.544.04 4.91 1.366 1.368 3.564 1.385 4.908.04l1.753-1.752c-.695.074-1.457-.078-2.176-.444L5.934 12.66c-.634.634-1.67.625-2.312-.017-.642-.643-.65-1.677-.017-2.312L6.035 7.9c.634-.634 1.67-.625 2.312.017.024.024.048.05.07.075l.003-.002c.36.36.943.366 1.3.01.355-.356.35-.938-.01-1.3l-.027-.024zM6.58 9.586l.048.05c1.367 1.366 3.565 1.384 4.91.04l2.29-2.292c1.344-1.343 1.328-3.542-.04-4.91-1.366-1.366-3.564-1.384-4.908-.04L7.127 4.187c.695-.074 1.457.078 2.176.444l1.028-1.027c.635-.634 1.67-.624 2.313.017.643.644.652 1.678.018 2.312l-2.43 2.432c-.635.634-1.67.624-2.313-.018-.024-.024-.048-.05-.07-.075l-.003.004c-.36-.362-.943-.367-1.3-.01-.355.355-.35.937.01 1.3.01.007.018.015.027.023z"/>
91
+ </svg>
92
+ <div class="body container">
93
+ <div class="content row justify-content-center">
94
+ <div class="col-10">
95
+ <%= output %>
96
+ </div>
97
+ </div>
98
+ <div class="footer d-flex justify-content-center">
99
+ <div>
100
+ <% short_sha = src_file_sha ? src_file_sha[0..7] : nil -%>
101
+ <% if file_url && short_sha -%>
102
+ v. <a href="<%= file_url -%>"><%= short_sha -%></a>,
103
+ <% elsif short_sha -%>
104
+ v. <%= short_sha -%>,
105
+ <% end -%>
106
+ <%= src_file_date -%> © <a href="https://sidu.in">Sidu Ponnappa</a>
107
+ </div>
108
+ </div>
109
+ </div>
110
+ </body>
82
111
  </html>
data/lib/bhook/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Bhook
5
- VERSION = '0.2.0'
5
+ VERSION = '0.2.1'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bhook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sidu Ponnappa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-01 00:00:00.000000000 Z
11
+ date: 2022-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git