console_renderer 0.0.7 → 0.0.8

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/console_renderer.rb +2 -35
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4d9a107a5916160388a434d9319824e535f17cc
4
- data.tar.gz: 48116e88f843e037cabd6fb410e36f2e72093fbe
3
+ metadata.gz: 5063c6b2c041be1ee569ccdc2ef00937f554dd9e
4
+ data.tar.gz: 41b7ce6af930a0f0a7f53a7b2273796847a965c8
5
5
  SHA512:
6
- metadata.gz: 9841f68ce2f356e3e7b4f2488b0cbb20ee19763ac5cea9701b5825121d96393b2c60cb0004ea773c2176f49a246ee2f3e1fd7332295f9b5dfb252bbd5c6b928d
7
- data.tar.gz: 569d625955e6e15371e46fa191ab265cb2758760e0c658b43375117d1ce4699fc07f19c0665482873208551e953837a663d384b913f36db246b8714dd950b4a1
6
+ metadata.gz: 4839fb3a3c4d4a1292d26522dca0ff2dec7540ab25eac466c52426ae17361e857ae4f8c38cc586c345a5d6d79f80fb77f9fca3473751fbea3de26f39198f23ee
7
+ data.tar.gz: e95a1aede230f46096b521ad4c283bb43229e899867b3d7a88b922ca7fc5688efe2f4baea66c9a7b2ca58d8a3eb257695b474a068cbf63a5132b4e0aeed24024
@@ -1,44 +1,11 @@
1
1
  require 'redcarpet'
2
2
  require 'rainbow'
3
- require 'syntax/convertors/html'
4
3
 
5
4
  class ConsoleRenderer < Redcarpet::Render::Base
6
5
 
7
6
  @@listitemid = 0
8
- def self.syntax_highlight(code, inline=true)
9
- tokenizer = Syntax.load "ruby"
10
-
11
- c_line = ""
12
-
13
- code.split("\n").each do |line|
14
- c_line += " " unless inline
15
- begin
16
- bkp = c_line
17
- tokenizer.tokenize( line ) do |token|
18
- case token.group.to_s
19
- when "comment" then c_line = c_line + Rainbow(token).color(:green)
20
- when "constant" then c_line = c_line + Rainbow(token).color(:blue)
21
- when "expr" then c_line = c_line + Rainbow(token).color(:red)
22
- when "ident" then c_line = c_line + Rainbow(token).color(:white)
23
- when "keyword" then c_line = c_line + Rainbow(token).color(:yellow)
24
- when "normal" then c_line = c_line + Rainbow(token).color(:cyan)
25
- when "number" then c_line = c_line + Rainbow(token).color(:red)
26
- when "punct" then c_line = c_line + Rainbow(token).color(:white)
27
- when "string" then c_line = c_line + Rainbow(token).color(:red)
28
- when "symbol" then c_line = c_line + Rainbow(token).color(:green)
29
- else c_line += token
30
- end
31
- end
32
- rescue
33
- c_line = bkp + line
34
- end
35
- c_line += "\n" unless inline
36
- end
37
- c_line
38
- end
39
-
40
7
  def block_code(code, language)
41
- "\n" + (ConsoleRenderer.syntax_highlight(code, false)) + "\n"
8
+ "\n" + code + "\n"
42
9
  end
43
10
 
44
11
  def block_quote(quote)
@@ -102,7 +69,7 @@ class ConsoleRenderer < Redcarpet::Render::Base
102
69
  end
103
70
 
104
71
  def codespan(code)
105
- ConsoleRenderer.syntax_highlight(code)
72
+ code
106
73
  end
107
74
 
108
75
  def double_emphasis(text)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: console_renderer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aditya Bhargava