neo4j-asciidoctor-extensions 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +9 -0
  3. data/.github/workflows/ci.yml +12 -0
  4. data/.gitignore +57 -0
  5. data/.rakeTasks +7 -0
  6. data/.rubocop.yml +11 -0
  7. data/Gemfile +5 -0
  8. data/Gemfile.lock +108 -0
  9. data/LICENSE +201 -0
  10. data/README.adoc +141 -0
  11. data/Rakefile +5 -0
  12. data/lib/neo4j_asciidoctor_extensions.rb +8 -0
  13. data/lib/neo4j_asciidoctor_extensions/course_document_attributes.rb +8 -0
  14. data/lib/neo4j_asciidoctor_extensions/course_document_attributes/extension.rb +65 -0
  15. data/lib/neo4j_asciidoctor_extensions/cypher_syntax_role.rb +8 -0
  16. data/lib/neo4j_asciidoctor_extensions/cypher_syntax_role/extension.rb +33 -0
  17. data/lib/neo4j_asciidoctor_extensions/document_metadata_generator.rb +8 -0
  18. data/lib/neo4j_asciidoctor_extensions/document_metadata_generator/extension.rb +136 -0
  19. data/lib/neo4j_asciidoctor_extensions/inline_highlighter_rouge.rb +9 -0
  20. data/lib/neo4j_asciidoctor_extensions/inline_highlighter_rouge/extension.rb +62 -0
  21. data/lib/neo4j_asciidoctor_extensions/revealjs_linear_navigation.rb +8 -0
  22. data/lib/neo4j_asciidoctor_extensions/revealjs_linear_navigation/extension.rb +31 -0
  23. data/lib/neo4j_asciidoctor_extensions/revealjs_speaker_notes_aggregator.rb +8 -0
  24. data/lib/neo4j_asciidoctor_extensions/revealjs_speaker_notes_aggregator/extension.rb +50 -0
  25. data/neo4j-asciidoctor-extensions.gemspec +29 -0
  26. data/spec/.rubocop.yml +5 -0
  27. data/spec/cypher_syntax_role_spec.rb +29 -0
  28. data/spec/document_metadata_generator_spec.rb +78 -0
  29. data/spec/inline_highlighter_rouge_spec.rb +30 -0
  30. data/spec/revealjs_linear_navigation_spec.rb +52 -0
  31. data/spec/revealjs_speaker_notes_aggregator_spec.rb +33 -0
  32. data/tasks/bundler.rake +6 -0
  33. data/tasks/lint.rake +5 -0
  34. data/tasks/rspec.rake +8 -0
  35. metadata +182 -0
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'neo4j-asciidoctor-extensions'
5
+ s.version = '0.0.1'
6
+ s.summary = 'Asciidoctor extensions by Neo4j.'
7
+ s.description = 'Asciidoctor extensions by Neo4j.'
8
+
9
+ s.authors = ['Guillaume Grossetie']
10
+ s.email = ['ggrossetie@yuzutech.fr']
11
+ s.homepage = 'https://github.com/neo4j-contrib/neo4j-asciidoctor-extensions'
12
+ s.license = 'Apache'
13
+ s.metadata = {
14
+ 'bug_tracker_uri' => 'https://github.com/neo4j-contrib/neo4j-asciidoctor-extensions/issues',
15
+ 'source_code_uri' => 'https://github.com/neo4j-contrib/neo4j-asciidoctor-extensions'
16
+ }
17
+ s.files = `git ls-files`.split($RS)
18
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
+ s.require_paths = ['lib']
20
+
21
+ s.add_runtime_dependency 'asciidoctor', '~> 2.0.0'
22
+ s.add_runtime_dependency 'asciidoctor-pdf', '1.5.3'
23
+ s.add_runtime_dependency 'rouge', '~> 3.18.0'
24
+
25
+ s.add_development_dependency 'asciidoctor-revealjs', '~> 4.0'
26
+ s.add_development_dependency 'rake', '~> 12.3.2'
27
+ s.add_development_dependency 'rspec', '~> 3.8.0'
28
+ s.add_development_dependency 'rubocop', '~> 0.74.0'
29
+ end
data/spec/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ inherit_from:
2
+ - ../.rubocop.yml
3
+
4
+ Metrics/BlockLength:
5
+ Max: 500
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'asciidoctor'
4
+ require_relative '../lib/neo4j_asciidoctor_extensions/cypher_syntax_role'
5
+
6
+ describe Neo4j::AsciidoctorExtensions::CypherSyntaxRoleTreeProcessor do
7
+ context 'convert to html5' do
8
+ it 'should add role syntax on cypher-syntax source block' do
9
+ input = <<~'ADOC'
10
+ [source,cypher-syntax]
11
+ ----
12
+ ()
13
+ (p)
14
+ (l)
15
+ (n)
16
+ ----
17
+ ADOC
18
+ output = Asciidoctor.convert(input, standalone: false)
19
+ (expect output).to eql %(<div class="listingblock syntax">
20
+ <div class="content">
21
+ <pre class="highlight"><code class="language-cypher-syntax" data-lang="cypher-syntax">()
22
+ (p)
23
+ (l)
24
+ (n)</code></pre>
25
+ </div>
26
+ </div>)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'asciidoctor'
4
+ require_relative '../lib/neo4j_asciidoctor_extensions/document_metadata_generator'
5
+
6
+ RSpec.configure do |config|
7
+ config.after(:each) do
8
+ FileUtils.rm_rf('spec/output') unless ENV['DEBUG']
9
+ end
10
+
11
+ config.before(:each) do
12
+ FileUtils.mkdir_p('spec/output')
13
+ end
14
+ end
15
+
16
+ describe Neo4j::AsciidoctorExtensions::DocumentMetadataGeneratorPostProcessor do
17
+ context 'convert to html5' do
18
+ it 'should generate default metadata' do
19
+ input = <<~'ADOC'
20
+ = Introduction to Neo4j 4.0
21
+ :document-metadata-attrs-include:
22
+
23
+ This is a paragraph.
24
+ ADOC
25
+ Asciidoctor.convert(input, safe: 'safe', to_file: 'spec/output/test.html')
26
+ metadata = YAML.load_file('spec/output/test.yml')
27
+ expect(metadata['title']).to eql('Introduction to Neo4j 4.0')
28
+ end
29
+ it 'should generate metadata with slug (string)' do
30
+ input = <<~'ADOC'
31
+ = Introduction to Neo4j 4.0
32
+ :document-metadata-attrs-include: slug
33
+ :slug: introduction-neo4j-4-0
34
+
35
+ This is a paragraph.
36
+ ADOC
37
+ Asciidoctor.convert(input, safe: 'safe', to_file: 'spec/output/test.html')
38
+ metadata = YAML.load_file('spec/output/test.yml')
39
+ expect(metadata['title']).to eql('Introduction to Neo4j 4.0')
40
+ expect(metadata['slug']).to eql('introduction-neo4j-4-0')
41
+ end
42
+ it 'should generate metadata with tags (list of strings)' do
43
+ input = <<~'ADOC'
44
+ = Introduction to Neo4j 4.0
45
+ :document-metadata-attrs-include: slug,tags*
46
+ :slug: introduction-neo4j-4-0
47
+ :tags: intro , neo4j,,
48
+
49
+ This is a paragraph.
50
+ ADOC
51
+ Asciidoctor.convert(input, safe: 'safe', to_file: 'spec/output/test.html')
52
+ metadata = YAML.load_file('spec/output/test.yml')
53
+ expect(metadata['title']).to eql('Introduction to Neo4j 4.0')
54
+ expect(metadata['slug']).to eql('introduction-neo4j-4-0')
55
+ expect(metadata['tags']).to eql(%w[intro neo4j])
56
+ end
57
+ it 'should generate metadata with taxonomies (list of tuples)' do
58
+ input = <<~'ADOC'
59
+ = Introduction to Neo4j 4.0
60
+ :document-metadata-attrs-include: slug,tags*,taxonomies*<>
61
+ :slug: introduction-neo4j-4-0
62
+ :tags: intro , neo4j,,
63
+ :taxonomies: os= linux,,programming_language =java, neo4j_version=3-5; 3-6;
64
+
65
+ This is a paragraph.
66
+ ADOC
67
+ Asciidoctor.convert(input, safe: 'safe', to_file: 'spec/output/test.html')
68
+ metadata = YAML.load_file('spec/output/test.yml')
69
+ expect(metadata['title']).to eql('Introduction to Neo4j 4.0')
70
+ expect(metadata['slug']).to eql('introduction-neo4j-4-0')
71
+ expect(metadata['tags']).to eql(%w[intro neo4j])
72
+ taxonomies = metadata['taxonomies']
73
+ expect(taxonomies.detect { |taxonomy| taxonomy['key'] == 'os' }['values']).to eql(%w[linux])
74
+ expect(taxonomies.detect { |taxonomy| taxonomy['key'] == 'programming_language' }['values']).to eql(%w[java])
75
+ expect(taxonomies.detect { |taxonomy| taxonomy['key'] == 'neo4j_version' }['values']).to eql(%w[3-5 3-6])
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'asciidoctor'
4
+ require_relative '../lib/neo4j_asciidoctor_extensions/inline_highlighter_rouge'
5
+
6
+ # rubocop:disable Metrics/LineLength
7
+ describe Neo4j::AsciidoctorExtensions::InlineHighlighter::MonospacedTextInlineMacro do
8
+ context 'convert to html5' do
9
+ it 'should apply syntax highlighting on monospaced text cypher' do
10
+ input = <<~'ADOC'
11
+ [src-cypher]`MATCH (c:Customer {customerName: 'ABCCO'}) RETURN c.BOUGHT.productName`
12
+ ADOC
13
+ output = Asciidoctor.convert(input, doctype: 'inline')
14
+ expect(output).to eql '<code class="rouge"><span style="color: #000000;font-weight: bold">MATCH</span><span style="color: #bbbbbb"> </span><span style="color: #990073">(</span><span style="background-color: #f8f8f8">c:</span><span style="background-color: #f8f8f8">Customer</span> <span style="color: #990073">{</span><span style="background-color: #f8f8f8">customerName:</span> <span style="color: #d14">\'ABCCO\'</span><span style="color: #990073">})</span> <span style="color: #000000;font-weight: bold">RETURN</span> <span style="background-color: #f8f8f8">c.BOUGHT.productName</span></code>'
15
+ end
16
+ end
17
+ end
18
+
19
+ describe Neo4j::AsciidoctorExtensions::InlineHighlighter::SrcInlineMacro do
20
+ context 'convert to html5' do
21
+ it 'should apply syntax highlighting on src inline macro' do
22
+ input = <<~'ADOC'
23
+ src:cypher[MATCH (c:Customer {customerName: 'ABCCO'}) RETURN c.BOUGHT.productName]
24
+ ADOC
25
+ output = Asciidoctor.convert(input, doctype: 'inline')
26
+ expect(output).to eql '<code class="rouge"><span style="color: #000000;font-weight: bold">MATCH</span><span style="color: #bbbbbb"> </span><span style="color: #990073">(</span><span style="background-color: #f8f8f8">c:</span><span style="background-color: #f8f8f8">Customer</span> <span style="color: #990073">{</span><span style="background-color: #f8f8f8">customerName:</span> <span style="color: #d14">\'ABCCO\'</span><span style="color: #990073">})</span> <span style="color: #000000;font-weight: bold">RETURN</span> <span style="background-color: #f8f8f8">c.BOUGHT.productName</span></code>'
27
+ end
28
+ end
29
+ end
30
+ # rubocop:enable Metrics/LineLength
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'asciidoctor'
4
+ require 'asciidoctor-revealjs'
5
+ require_relative '../lib/neo4j_asciidoctor_extensions/revealjs_linear_navigation'
6
+
7
+ describe Neo4j::AsciidoctorExtensions::RevealJsLinearNavigationTreeProcessor do
8
+ context 'convert to reveal.js' do
9
+ it 'should produce a linear navigation' do
10
+ input = <<~'ADOC'
11
+ = Introduction to Neo4j 4.0
12
+
13
+ == a
14
+
15
+ === b
16
+
17
+ ==== c
18
+
19
+ === d
20
+
21
+ == e
22
+
23
+ === f
24
+
25
+ == g
26
+
27
+ == h
28
+
29
+ === i
30
+
31
+ ==== j
32
+
33
+ ==== k
34
+
35
+ == l
36
+ ADOC
37
+ output = Asciidoctor.convert(input, backend: 'revealjs')
38
+ expect(output).to eql %(<section id="_a"><h2>a</h2></section>
39
+ <section id="_b"><h2>b</h2></section>
40
+ <section id="_c"><h2>c</h2></section>
41
+ <section id="_d"><h2>d</h2></section>
42
+ <section id="_e"><h2>e</h2></section>
43
+ <section id="_f"><h2>f</h2></section>
44
+ <section id="_g"><h2>g</h2></section>
45
+ <section id="_h"><h2>h</h2></section>
46
+ <section id="_i"><h2>i</h2></section>
47
+ <section id="_j"><h2>j</h2></section>
48
+ <section id="_k"><h2>k</h2></section>
49
+ <section id="_l"><h2>l</h2></section>)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'asciidoctor'
4
+ require 'asciidoctor-revealjs'
5
+ require_relative '../lib/neo4j_asciidoctor_extensions/revealjs_speaker_notes_aggregator'
6
+
7
+ describe Neo4j::AsciidoctorExtensions::RevealJsSpeakerNotesAggregatorTreeProcessor do
8
+ context 'convert to reveal.js' do
9
+ it 'should aggregate speaker notes' do
10
+ input = <<~'ADOC'
11
+ = Presentation
12
+
13
+ == Introduction
14
+
15
+ [.notes]
16
+ --
17
+ This is a speaker note.
18
+ --
19
+
20
+ Hello!
21
+
22
+ [.notes]
23
+ --
24
+ This is another speaker note.
25
+ --
26
+ ADOC
27
+ output = Asciidoctor.convert(input, backend: 'revealjs')
28
+ expect(output).to eql %(<section id="_introduction"><h2>Introduction</h2><div class="slide-content"><div class="paragraph"><p>Hello!</p></div>
29
+ <aside class="notes"><div class="openblock"><div class="content"><div class="paragraph"><p>This is a speaker note.</p></div></div></div>
30
+ <div class="openblock"><div class="content"><div class="paragraph"><p>This is another speaker note.</p></div></div></div></aside></div></section>)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ begin
3
+ require 'bundler/gem_tasks'
4
+ rescue LoadError
5
+ warn $!.message
6
+ end
data/tasks/lint.rake ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubocop/rake_task'
4
+
5
+ RuboCop::RakeTask.new :lint
data/tasks/rspec.rake ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new :spec
6
+ rescue LoadError
7
+ warn $ERROR_INFO.message
8
+ end
metadata ADDED
@@ -0,0 +1,182 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: neo4j-asciidoctor-extensions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Guillaume Grossetie
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-04-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: asciidoctor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: asciidoctor-pdf
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.5.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.5.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: rouge
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.18.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.18.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: asciidoctor-revealjs
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 12.3.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 12.3.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.8.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 3.8.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.74.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.74.0
111
+ description: Asciidoctor extensions by Neo4j.
112
+ email:
113
+ - ggrossetie@yuzutech.fr
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".editorconfig"
119
+ - ".github/workflows/ci.yml"
120
+ - ".gitignore"
121
+ - ".rakeTasks"
122
+ - ".rubocop.yml"
123
+ - Gemfile
124
+ - Gemfile.lock
125
+ - LICENSE
126
+ - README.adoc
127
+ - Rakefile
128
+ - lib/neo4j_asciidoctor_extensions.rb
129
+ - lib/neo4j_asciidoctor_extensions/course_document_attributes.rb
130
+ - lib/neo4j_asciidoctor_extensions/course_document_attributes/extension.rb
131
+ - lib/neo4j_asciidoctor_extensions/cypher_syntax_role.rb
132
+ - lib/neo4j_asciidoctor_extensions/cypher_syntax_role/extension.rb
133
+ - lib/neo4j_asciidoctor_extensions/document_metadata_generator.rb
134
+ - lib/neo4j_asciidoctor_extensions/document_metadata_generator/extension.rb
135
+ - lib/neo4j_asciidoctor_extensions/inline_highlighter_rouge.rb
136
+ - lib/neo4j_asciidoctor_extensions/inline_highlighter_rouge/extension.rb
137
+ - lib/neo4j_asciidoctor_extensions/revealjs_linear_navigation.rb
138
+ - lib/neo4j_asciidoctor_extensions/revealjs_linear_navigation/extension.rb
139
+ - lib/neo4j_asciidoctor_extensions/revealjs_speaker_notes_aggregator.rb
140
+ - lib/neo4j_asciidoctor_extensions/revealjs_speaker_notes_aggregator/extension.rb
141
+ - neo4j-asciidoctor-extensions.gemspec
142
+ - spec/.rubocop.yml
143
+ - spec/cypher_syntax_role_spec.rb
144
+ - spec/document_metadata_generator_spec.rb
145
+ - spec/inline_highlighter_rouge_spec.rb
146
+ - spec/revealjs_linear_navigation_spec.rb
147
+ - spec/revealjs_speaker_notes_aggregator_spec.rb
148
+ - tasks/bundler.rake
149
+ - tasks/lint.rake
150
+ - tasks/rspec.rake
151
+ homepage: https://github.com/neo4j-contrib/neo4j-asciidoctor-extensions
152
+ licenses:
153
+ - Apache
154
+ metadata:
155
+ bug_tracker_uri: https://github.com/neo4j-contrib/neo4j-asciidoctor-extensions/issues
156
+ source_code_uri: https://github.com/neo4j-contrib/neo4j-asciidoctor-extensions
157
+ post_install_message:
158
+ rdoc_options: []
159
+ require_paths:
160
+ - lib
161
+ required_ruby_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ requirements: []
172
+ rubygems_version: 3.0.6
173
+ signing_key:
174
+ specification_version: 4
175
+ summary: Asciidoctor extensions by Neo4j.
176
+ test_files:
177
+ - spec/.rubocop.yml
178
+ - spec/cypher_syntax_role_spec.rb
179
+ - spec/document_metadata_generator_spec.rb
180
+ - spec/inline_highlighter_rouge_spec.rb
181
+ - spec/revealjs_linear_navigation_spec.rb
182
+ - spec/revealjs_speaker_notes_aggregator_spec.rb