mm-jekyll-prism 0.0.2 → 1.0.0

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: c6194e3d834c5870a546c300f30e59e091b39b15
4
- data.tar.gz: 88aed2b55dface71eb1a8fec0042fe1207f6786e
3
+ metadata.gz: ee9d3abbb8cfe50668f66aa94f539ea9440cbff5
4
+ data.tar.gz: 7f93b9904dbfb941010d34bc68a57d3c4e32c047
5
5
  SHA512:
6
- metadata.gz: 5fefd7e3261ef751ab9a0556160adeb5e0f856d5780cc594e1f6322f219ad2a5c4bb04acb2f2579548183df61a9a693fb30ddb5aaf1e721c40bce642c4590571
7
- data.tar.gz: 9f4e201f1f6296fb908c6c2b5796251d0168a598c6899ab02c12a32fa0f218eedd97919a58765bb81f9cab375c7e356bbf8736af6a0e99c26646e3540559905d
6
+ metadata.gz: 14cbf871ba9e7465bb7fb729124ed615f39f7042f344149f9b102a02a36efa0fc553ba7b8c9f7d973b34852389cf202d904a6911fd8f1970425d55ab6e01b045
7
+ data.tar.gz: 64091dc8e5f69fe39ddea8626daec139e68871dba8ae7eff0fbd2595527dfad86a49a330d7f839e382ca0b556998cc0cbc2f124df1493e7c07e03cfa944fc869
data/.gitignore CHANGED
@@ -1 +1,3 @@
1
1
  Gemfile.lock
2
+ vendor/
3
+ .bundle/
@@ -1,7 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ### 0.0.1
4
- - Initial release
3
+ ### 1.0.0
4
+ - Added support for commandline
5
5
 
6
6
  ### 0.0.2
7
7
  - Fixed naming issue with gem file
8
+
9
+ ### 0.0.1
10
+ - Initial release
data/README.md CHANGED
@@ -89,6 +89,33 @@ __With offset__
89
89
  // ...
90
90
  {% endprism %}
91
91
 
92
+ #### Command Line
93
+ __Help document__: http://prismjs.com/plugins/command-line/
94
+
95
+ To use add the options __user__ and __host__ with the desired user name and host name.
96
+
97
+ For those that want a Window's style prompt, use the option __prompt__ with the desire prompt string.
98
+
99
+ You can also choose which files are considered output lines using the __output__ tag. It operates similar to the highlighting tag.
100
+
101
+ ##### Example
102
+ __With User and Host__
103
+
104
+ {% prism user="john" host="local" %}
105
+ // ...
106
+ {% endprism %}
107
+
108
+ __With User and Host with Output__
109
+
110
+ {% prism user="john" host="local" output="1,3-5,10%}
111
+ // ...
112
+ {% endprism %}
113
+
114
+ __With Prompt__
115
+
116
+ {% prism prompt="john"%}
117
+ // ...
118
+ {% endprism %}
92
119
 
93
120
  #### Show Language
94
121
  __Help document__: http://prismjs.com/plugins/show-language/
@@ -4,20 +4,23 @@ module Jekyll
4
4
  include Liquid::StandardFilters
5
5
 
6
6
  LANGUAGE = /^[a-z\-]+$/
7
- OPTION_PARAMS = /(file|highlight|numbering|language)(?:\s*=\s*("[a-zA-Z0-9.,\-\/\s]*"|\-?[0-9]+))?/
7
+ OPTION_PARAMS = /(user|prompt|host|highlight|numbering|file|prompt|output)(?:\s*=\s*("[a-zA-Z0-9.,\-\/\s]*"|\-?[0-9]+))?/
8
8
 
9
9
  @language = nil
10
10
  @file = nil
11
11
  @numbering = false
12
12
  @highlight = false
13
+ @output = false
14
+ @host = nil
15
+ @user = nil
16
+ @prompt = nil
13
17
 
14
18
  def initialize(tag_name, markup, tokens)
15
19
  super
16
20
 
17
21
  markup = markup.strip
18
22
 
19
- tmp = markup.split(/\s+/, 2)
20
-
23
+ tmp = markup.split(/\s+/, 2)
21
24
  if tmp.count >= 1 then
22
25
  param = tmp[0].strip.downcase
23
26
  if LANGUAGE =~ param then
@@ -53,6 +56,14 @@ module Jekyll
53
56
  @highlight = value.tr('"', '')
54
57
  elsif name.eql? "numbering" then
55
58
  @numbering = value.to_i
59
+ elsif name.eql? "host" then
60
+ @host = value.tr('"', '')
61
+ elsif name.eql? "user" then
62
+ @user = value.tr('"', '')
63
+ elsif name.eql? "prompt" then
64
+ @prompt = value.tr('"', '')
65
+ elsif name.eql? "output" then
66
+ @output = value.tr('"', '')
56
67
  end
57
68
  else
58
69
  syntax_error
@@ -94,6 +105,21 @@ module Jekyll
94
105
  dataline = "data-line='#{@highlight}'"
95
106
  end
96
107
 
108
+ unless @output.nil? then
109
+ dataline = dataline + " data-output='#{@output}' "
110
+ end
111
+
112
+ unless @prompt.nil? then
113
+ dataline = dataline + " data-prompt='#{@prompt}'"
114
+ class_attr = class_attr + " command-line "
115
+ end
116
+
117
+ unless @user.nil? || @host.nil?then
118
+ dataline = dataline + " data-user='#{@user}'"
119
+ dataline = dataline + " data-host='#{@host}'"
120
+ class_attr = class_attr + " command-line "
121
+ end
122
+
97
123
  if @file.nil?
98
124
  "<pre class=\"#{class_attr}\" #{datastart} #{dataline}><code>#{code}</code></pre>"
99
125
  else
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "mm-jekyll-prism"
7
- spec.version = "0.0.2"
7
+ spec.version = "1.0.0"
8
8
  spec.authors = ["Tim Oram"]
9
9
  spec.email = ["mitmaro@gmail.com"]
10
10
  spec.summary = %q{Prism plugin for Jekyll}
@@ -29,7 +29,27 @@ RSpec.describe Jekyll::Prism do
29
29
  prism = Jekyll::Prism.new("prism", 'javascript highlight="1-2,4,5-9" ', ["{% endprism %}"]);
30
30
  expect(prism.instance_variable_get(:@highlight)).to eql("1-2,4,5-9")
31
31
  end
32
+
33
+ it "Understands how to accept a user parameter" do
34
+ prism = Jekyll::Prism.new("prism", 'javascript user="john"', ["{% endprism %}"]);
35
+ expect(prism.instance_variable_get(:@user)).to eql("john")
36
+ end
37
+
38
+ it "Understands how to accept a host parameter" do
39
+ prism = Jekyll::Prism.new("prism", 'javascript host="local" ', ["{% endprism %}"]);
40
+ expect(prism.instance_variable_get(:@host)).to eql("local")
41
+ end
32
42
 
43
+ it "Understands how to accept a prompt parameter" do
44
+ prism = Jekyll::Prism.new("prism", 'javascript prompt="john" ', ["{% endprism %}"]);
45
+ expect(prism.instance_variable_get(:@prompt)).to eql("john")
46
+ end
47
+
48
+ it "Understands how to accept a output parameter" do
49
+ prism = Jekyll::Prism.new("prism", 'javascript output="1-2,4,5-9"', ["{% endprism %}"]);
50
+ expect(prism.instance_variable_get(:@output)).to eql("1-2,4,5-9")
51
+ end
52
+
33
53
  it "Understands how to accept a numbering parameter" do
34
54
  prism = Jekyll::Prism.new("prism", 'javascript numbering ', ["{% endprism %}"]);
35
55
  expect(prism.instance_variable_get(:@numbering)).to eql(true)
@@ -38,14 +58,33 @@ RSpec.describe Jekyll::Prism do
38
58
  prism = Jekyll::Prism.new("prism", 'javascript numbering=-10 ', ["{% endprism %}"]);
39
59
  expect(prism.instance_variable_get(:@numbering)).to eql(-10)
40
60
  end
61
+
41
62
  end
42
63
 
43
64
  context "Valid render from code with all options" do
44
65
 
45
- let(:content) { '{% prism cpp numbering=5 highlight="1,2-5,10" %} My Code {% endprism %}' }
66
+ let(:content) { '{% prism cpp numbering=5 highlight="1,2-5,10" %}{% endprism %}' }
67
+
68
+ it "Understands how to render code from code block" do
69
+ expect(output).to match("<pre class=\" language-cpp line-numbers \" data-start=\"5\" data-line=\"1,2-5,10\"><code></code></pre>")
70
+ end
71
+ end
72
+
73
+ context "Valid render from code with user, host, and output options on" do
74
+
75
+ let(:content) { '{% prism cpp host="local" user="john" output="1,2-5,10" %}{% endprism %}' }
76
+
77
+ it "Understands how to render code from code block" do
78
+ expect(output).to match("<pre class=\" language-cpp command-line \" data-output=\"1,2-5,10\" data-user=\"john\" data-host=\"local\"><code></code></pre>")
79
+ end
80
+ end
81
+
82
+ context "Valid render from code with prompt and output options on" do
83
+
84
+ let(:content) { '{% prism cpp prompt="john" output="1,2-5,10" %}{% endprism %}' }
46
85
 
47
86
  it "Understands how to render code from code block" do
48
- expect(output).to match("<pre class=\" language-cpp line-numbers \" data-start=\"5\" data-line=\"1,2-5,10\"><code>My Code</code></pre>")
87
+ expect(output).to match("<pre class=\" language-cpp command-line \" data-output=\"1,2-5,10\" data-prompt=\"john\"><code></code></pre>")
49
88
  end
50
89
  end
51
90
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mm-jekyll-prism
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Oram
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-28 00:00:00.000000000 Z
11
+ date: 2017-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project:
123
- rubygems_version: 2.4.1
123
+ rubygems_version: 2.5.1
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: Prism plugin for Jekyll