highlighting 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 204053f1c717db58034721aa40f737528cddce61
4
- data.tar.gz: efb1264e2ede9c2d098eb5a877871655c283401f
3
+ metadata.gz: 3a91cd326a58f0bf9c6fa2e02fd9da5ae3a07f13
4
+ data.tar.gz: b5db690c5a54d12385bbe12bc9d6b89576c9237a
5
5
  SHA512:
6
- metadata.gz: 8903d486c0dc71dff282bd9e7417bdfcb823838bd06ce1d5e18a73a225728bd155ad102b8e859af33c1ee11935fb28bc7a8420fe9dc183dd396b9bfad0dd73ad
7
- data.tar.gz: f0eb6f710a89a3c8d2e56789a81715e7d1c1ca0c7978313ba1c8dada4723f58c4e795019202e635b842b940ff02e894a97d2d7849847eeb27f74f9fb4d24ef07
6
+ metadata.gz: fcbfc9363c70920b181271852de51246b79551bfd1b8678021deed754d91ab62b59962ccd35a19858064d16aac0d6a61439ba7dd191d34e2811028dcaa1e2f54
7
+ data.tar.gz: 996c368f3e7f2c5d6044cfd1be83038ea7039bff1b0004fe5cbe5898f4343c18c6264aa14fb9a03db7b5fa7a98dc09870747393df4b140d388d2b02f62ca3f05
data/README.md CHANGED
@@ -1,11 +1,9 @@
1
1
  # Highlighting
2
2
 
3
- Highlighting is based on [PrismJS](http://prismjs.com).
3
+ Highlighting ships with [PrismJS](http://prismjs.com).
4
4
 
5
5
  > Prism is a lightweight, robust, elegant syntax highlighting library. It's a spin-off project from Dabblet.
6
6
 
7
- To use highlighting, please read this [stackoverflow post](http://stackoverflow.com/a/34373693/388280)
8
-
9
7
  ## Installation
10
8
 
11
9
  Add this line to your application's Gemfile:
@@ -26,17 +24,54 @@ Or install it yourself as:
26
24
  $ gem install highlighting
27
25
  ```
28
26
 
27
+ At application.js, replace [language] with the name of language. For example: prism-ruby or prism-coffeescript
28
+ ```
29
+ //= require jquery
30
+ //= require jquery_ujs
31
+ //= require turbolinks
32
+ //= require prism
33
+ //= require prism-[language]
34
+ //= require prism-turbolinks #optional
35
+ //= require_tree .
36
+ ```
37
+
38
+ At application.css, add `*= require prism-[theme]` or use the default `*= require prism`
39
+
40
+ ```
41
+ *= require_tree .
42
+ *= require prism-[theme]
43
+ *= require_self
44
+ ```
45
+ There are various other themes to choose from. For example `*= require prism-tomorrow`, `*= require prism-twilight`.
46
+
47
+
29
48
  ## Usage
49
+ Use the alias in place of xxxx in `language-xxxx`. `language-xxxx` is a css rule here used by prismjs.
50
+
51
+ For example: ruby, python, go, swift
30
52
 
31
53
  ```
32
- <pre>
33
- <code class="language-ruby">
34
- <!-- type any ruby code you like -->
35
- </code>
36
- </pre>
54
+ <%= code "language-ruby" %>
55
+ <!-- type any ruby code you like -->
56
+ <% end %>
57
+ ```
58
+
59
+ ## Known Issues
37
60
 
61
+ With turbolinks enabled, prismjs is not called at page load. For quick fix, add the `//= require prism-turbolinks` line at application.js
62
+
63
+ ```
64
+ //= require jquery
65
+ //= require jquery_ujs
66
+ //= require turbolinks
67
+ //= require prism
68
+ //= require prism-ruby
69
+ //= require prism-turbolinks
70
+ //= require_tree .
38
71
  ```
39
72
 
73
+ If you wish to add the code manually, read [prismjs not working with turbolinks](http://stackoverflow.com/questions/21278357/prism-js-not-working-with-rails-4-turbolinks/21355342#21355342)
74
+
40
75
  ## Development
41
76
 
42
77
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,2 +1,6 @@
1
1
  module SyntaxHelper
2
+ def code language, &block
3
+ content = capture(&block)
4
+ return "<pre><code class=\"#{language}\">#{content}</code></pre>".html_safe
5
+ end
2
6
  end
@@ -0,0 +1,22 @@
1
+ module Log
2
+ MESSAGE = "
3
+
4
+ ######################
5
+ ## HIGHLIGHTING
6
+ ######################
7
+
8
+ What's new in 0.1.2?
9
+ - SyntaxHelper <%= code "" %>
10
+ Usage:
11
+ <%= code \"language-ruby\" do %>
12
+ <!-- write any ruby code here !>
13
+ puts \"hello world\"
14
+ <% end %>
15
+
16
+ What's in 0.1.1?
17
+ - ship with PrismJS 1.4.1
18
+
19
+ Full Changelog -> https://github.com/ytbryan/highlighting/blob/master/changelog.md
20
+ Pull Request -> https://github.com/ytbryan/highlighting/pulls
21
+ "
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Highlighting
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -0,0 +1,5 @@
1
+ if (typeof Turbolinks !== "undefined") {
2
+ $(document).on('ready page:load', function() {
3
+ Prism.highlightAll()
4
+ });
5
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: highlighting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - bryan lim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-03 00:00:00.000000000 Z
11
+ date: 2016-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -45,10 +45,10 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - LICENSE
49
48
  - README.md
50
49
  - app/helpers/syntax_helper.rb
51
50
  - lib/highlighting.rb
51
+ - lib/highlighting/post_message.rb
52
52
  - lib/highlighting/version.rb
53
53
  - vendor/assets/javascripts/prism-abap.js
54
54
  - vendor/assets/javascripts/prism-abap.min.js
@@ -260,6 +260,7 @@ files:
260
260
  - vendor/assets/javascripts/prism-tcl.min.js
261
261
  - vendor/assets/javascripts/prism-textile.js
262
262
  - vendor/assets/javascripts/prism-textile.min.js
263
+ - vendor/assets/javascripts/prism-turbolinks.js
263
264
  - vendor/assets/javascripts/prism-twig.js
264
265
  - vendor/assets/javascripts/prism-twig.min.js
265
266
  - vendor/assets/javascripts/prism-typescript.js
@@ -283,11 +284,15 @@ files:
283
284
  - vendor/assets/stylesheets/prism-tomorrow.css
284
285
  - vendor/assets/stylesheets/prism-twilight.css
285
286
  - vendor/assets/stylesheets/prism.css
286
- homepage: http://github.com/ytbryan/highlighting.
287
+ homepage: http://github.com/ytbryan/highlighting
287
288
  licenses:
288
289
  - MIT
289
290
  metadata: {}
290
- post_install_message:
291
+ post_install_message: "\n\n ######################\n ## HIGHLIGHTING\n ######################\n\n
292
+ \ What's new in 0.1.2?\n - SyntaxHelper <%= code %>\n Usage:\n <%= code \"language-ruby\"
293
+ do %>\n <!-- write any ruby code here !>\n puts \"hello world\"\n <% end
294
+ %>\n\n What's in 0.1.1?\n - ship with PrismJS 1.4.1\n\n Full Changelog -> https://github.com/ytbryan/highlighting/blob/master/changelog.md\n
295
+ \ Pull Request -> https://github.com/ytbryan/highlighting/pulls\n "
291
296
  rdoc_options: []
292
297
  require_paths:
293
298
  - lib
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016 Bryan Lim
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.