nexmo_markdown_renderer 0.4.2 → 0.5.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 +4 -4
- data/README.md +1 -1
- data/config/code_languages.yml +9 -0
- data/lib/nexmo_markdown_renderer.rb +3 -0
- data/lib/nexmo_markdown_renderer/filters/code_snippet/renderable.rb +2 -0
- data/lib/nexmo_markdown_renderer/filters/i18n/frontmatter_filter.rb +1 -2
- data/lib/nexmo_markdown_renderer/filters/i18n/smartling/code_block_filter.rb +20 -0
- data/lib/nexmo_markdown_renderer/filters/i18n/smartling/escape_filter.rb +13 -0
- data/lib/nexmo_markdown_renderer/filters/i18n/smartling/frontmatter_filter.rb +22 -0
- data/lib/nexmo_markdown_renderer/filters/markdown_filter.rb +3 -1
- data/lib/nexmo_markdown_renderer/filters/tooltip_filter.rb +1 -1
- data/lib/nexmo_markdown_renderer/pipelines/smartling/download.rb +17 -0
- data/lib/nexmo_markdown_renderer/pipelines/smartling/preprocessor.rb +15 -0
- data/lib/nexmo_markdown_renderer/services/code_snippet_renderer/go.rb +23 -0
- data/lib/nexmo_markdown_renderer/views/code_snippets/_application_messages_dispatch.html.erb +4 -4
- data/lib/nexmo_markdown_renderer/views/code_snippets/_application_rtc.html.erb +4 -4
- data/lib/nexmo_markdown_renderer/views/code_snippets/_application_voice.html.erb +4 -4
- data/lib/nexmo_markdown_renderer/views/code_snippets/_configure_client.html.erb +5 -5
- data/lib/nexmo_markdown_renderer/views/code_snippets/_dependencies.html.erb +3 -3
- data/lib/nexmo_markdown_renderer/views/code_snippets/_import_dependencies.html.erb +4 -4
- data/lib/version.rb +1 -1
- metadata +8 -3
- data/lib/nexmo_markdown_renderer/filters/i18n/smartling_converter_filter.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c9303cbd50b27ad02c68444daff15f65f3c3150f052bbfae839ee83e208f2f3
|
4
|
+
data.tar.gz: 6598a455b0b1a5bc07e5f05b0425db82bcfd1d980f9a43e7b6455ec73e5c8258
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c2bb7bf7351edeee752c0ee34f93c7ac2610df41ad78aa0642b7070b3f5a3675254343c52285de3f879c195a5ff78c186f2e7bcee60a712661b4b704a2d25dc
|
7
|
+
data.tar.gz: d82606e5cb6920496674fd3aba4888e5b874b5dcbdad38f35f6c24ccbe1ef24c8069acb84afb338477df6068404f9c4b283ad9fdb694652cb6d689329110cf56
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Nexmo Markdown Renderer
|
2
2
|
|
3
|
-
|
3
|
+

|
4
4
|
[](./LICENSE.txt)
|
5
5
|
|
6
6
|
This gem facilitates the presentation of markdown documents in a Rails app by applying custom filters for tabs, code snippets, icons, indentation and more. It is used in the [Nexmo Developer Platform](https://developer.nexmo.com).
|
data/config/code_languages.yml
CHANGED
@@ -109,6 +109,15 @@ languages:
|
|
109
109
|
icon: ios
|
110
110
|
dependencies: []
|
111
111
|
|
112
|
+
go:
|
113
|
+
weight: 12
|
114
|
+
label: Go
|
115
|
+
lexer: go
|
116
|
+
icon: curl
|
117
|
+
dependencies:
|
118
|
+
- 'vonage/vonage-go-sdk'
|
119
|
+
run_command: 'go run {filename}'
|
120
|
+
|
112
121
|
platforms:
|
113
122
|
ios:
|
114
123
|
languages:
|
@@ -24,6 +24,7 @@ require_relative 'nexmo_markdown_renderer/services/code_snippet_renderer/php'
|
|
24
24
|
require_relative 'nexmo_markdown_renderer/services/code_snippet_renderer/python'
|
25
25
|
require_relative 'nexmo_markdown_renderer/services/code_snippet_renderer/ruby'
|
26
26
|
require_relative 'nexmo_markdown_renderer/services/code_snippet_renderer/swift'
|
27
|
+
require_relative 'nexmo_markdown_renderer/services/code_snippet_renderer/go'
|
27
28
|
|
28
29
|
require_relative 'nexmo_markdown_renderer/services/doc_finder'
|
29
30
|
require_relative 'nexmo_markdown_renderer/services/doc_finder/doc'
|
@@ -50,4 +51,6 @@ require_relative 'nexmo_markdown_renderer/filters/code_snippet/run'
|
|
50
51
|
Dir[File.join(__dir__, 'nexmo_markdown_renderer/filters/concerns', '*.rb')].each { |file| require_relative file }
|
51
52
|
Dir[File.join(__dir__, 'nexmo_markdown_renderer/filters', '*.rb')].each { |file| require_relative file }
|
52
53
|
Dir[File.join(__dir__, 'nexmo_markdown_renderer/filters/i18n', '*.rb')].each { |file| require_relative file }
|
54
|
+
Dir[File.join(__dir__, 'nexmo_markdown_renderer/filters/i18n/smartling', '*.rb')].each { |file| require_relative file }
|
55
|
+
Dir[File.join(__dir__, 'nexmo_markdown_renderer/pipelines/smartling', '*.rb')].each { |file| require_relative file }
|
53
56
|
require_relative 'nexmo_markdown_renderer/markdown_renderer'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Nexmo
|
2
|
+
module Markdown
|
3
|
+
module I18n
|
4
|
+
module Smartling
|
5
|
+
class CodeBlockFilter < Banzai::Filter
|
6
|
+
def call(input)
|
7
|
+
input.gsub(/\n\n\s{4}(.*?)\n\n/m) do
|
8
|
+
<<~CODE_BLOCK
|
9
|
+
|
10
|
+
````
|
11
|
+
#{$1.split(/\n\s{4}/).join("\n")}
|
12
|
+
````
|
13
|
+
CODE_BLOCK
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Nexmo
|
2
|
+
module Markdown
|
3
|
+
module I18n
|
4
|
+
module Smartling
|
5
|
+
class EscapeFilter < Banzai::Filter
|
6
|
+
def call(input)
|
7
|
+
input.gsub('\-', '-').gsub('\|', '|').gsub('\[', '[').gsub('\]', ']').gsub('\(', '(').gsub('\)', ')').gsub(/^>\s\n+/, "\n")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Nexmo
|
2
|
+
module Markdown
|
3
|
+
module I18n
|
4
|
+
module Smartling
|
5
|
+
class FrontmatterFilter < Banzai::Filter
|
6
|
+
def call(input)
|
7
|
+
input.gsub(/\A\*\*\* \*\* \* \*\* \*\*\*\n*([^-]*)\n*-+/m) do |_frontmatter|
|
8
|
+
front = $1.gsub(/`(.*):`(.*)/) do |_config|
|
9
|
+
"#{$1}: #{$2}"
|
10
|
+
end
|
11
|
+
<<~FRONTMATTER
|
12
|
+
---
|
13
|
+
#{front}
|
14
|
+
---
|
15
|
+
FRONTMATTER
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -2,7 +2,7 @@ module Nexmo
|
|
2
2
|
module Markdown
|
3
3
|
class TooltipFilter < Banzai::Filter
|
4
4
|
def call(input)
|
5
|
-
input.gsub(/\^\[([a-zA-Z0-9\s:\-]+)\]\((.+?)\)/) do
|
5
|
+
input.gsub(/\^\[([\p{Han}a-zA-Z0-9\s:\-]+)\]\((.+?)\)/) do
|
6
6
|
tooltip = <<~HEREDOC
|
7
7
|
<span class="Vlt-tooltip Vlt-tooltip--top" title="#{$2}" tabindex="0">
|
8
8
|
#{$1}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Nexmo
|
2
|
+
module Markdown
|
3
|
+
module Pipelines
|
4
|
+
module Smartling
|
5
|
+
class Download < Banzai::Pipeline
|
6
|
+
def initialize(_options = {})
|
7
|
+
super(
|
8
|
+
I18n::Smartling::FrontmatterFilter,
|
9
|
+
I18n::Smartling::EscapeFilter,
|
10
|
+
I18n::Smartling::CodeBlockFilter
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Nexmo
|
2
|
+
module Markdown
|
3
|
+
module CodeSnippetRenderer
|
4
|
+
class Go < Base
|
5
|
+
def self.dependencies(deps, _version)
|
6
|
+
{ 'code' => "go get #{deps.join(' ')}" }
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.run_command(command, _filename, _file_path)
|
10
|
+
::I18n.t('services.code_snippet_renderer.run_command', command: command)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.create_instructions(filename)
|
14
|
+
::I18n.t('services.code_snippet_renderer.create_instructions', filename: filename)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.add_instructions(_filename)
|
18
|
+
::I18n.t('services.code_snippet_renderer.add_instructions_to_code')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/nexmo_markdown_renderer/views/code_snippets/_application_messages_dispatch.html.erb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
<div class="Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis">
|
2
|
-
<
|
1
|
+
<div class="Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis Vlt-accordion">
|
2
|
+
<button class="Vlt-accordion__trigger" data-accordion="acc<%= id %>" tabindex="0">
|
3
3
|
<%= app['use_existing'] ? ::I18n.t('.code_snippets.use_your_app') : ::I18n.t('.code_snippets.create_an_app') %>
|
4
|
-
</
|
4
|
+
</button>
|
5
5
|
|
6
|
-
<div id="acc<%=id %>"
|
6
|
+
<div id="acc<%=id %>" class="Vlt-accordion__content Vlt-accordion__content--noborder">
|
7
7
|
<%= ::I18n.t('.code_snippets.application_messages_dispatch.no_application_html') %>
|
8
8
|
</div>
|
9
9
|
</div>
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<div class="Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis">
|
2
|
-
<
|
1
|
+
<div class="Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis Vlt-accordion">
|
2
|
+
<button class="Vlt-accordion__trigger" data-accordion="acc<%= id %>" tabindex="0">
|
3
3
|
<%= ::I18n.t('.code_snippets.create_an_app') %>
|
4
|
-
</
|
4
|
+
</button>
|
5
5
|
|
6
|
-
<div id="acc<%=id %>" class="Vlt-
|
6
|
+
<div id="acc<%=id %>" class="Vlt-accordion__content Vlt-accordion__content--noborder">
|
7
7
|
<p><%= ::I18n.t('.code_snippets.nexmo_application_contains_html') %></p>
|
8
8
|
<h4><%= ::I18n.t('.code_snippets.install_the_cli') %></h4>
|
9
9
|
<pre class="Vlt-prism--dark dependencies command-line Vlt-prism--copy-disabled language-bash" data-prompt='$'><code>npm install -g nexmo-cli</code></pre>
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<div class="Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis">
|
2
|
-
<
|
1
|
+
<div class="Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis Vlt-accordion">
|
2
|
+
<button class="Vlt-accordion__trigger" data-accordion="acc<%= id %>" tabindex="0">
|
3
3
|
<%= app['use_existing'] ? ::I18n.t('.code_snippets.use_your_app') : ::I18n.t('.code_snippets.create_an_app') %>
|
4
|
-
</
|
4
|
+
</button>
|
5
5
|
|
6
|
-
<div id="acc<%=id %>"
|
6
|
+
<div id="acc<%=id %>" class="Vlt-accordion__content Vlt-accordion__content--noborder">
|
7
7
|
<% if app['use_existing'] %>
|
8
8
|
<p><%= app['use_existing'] %></p>
|
9
9
|
<% else %>
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<div class="Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis">
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
<div class="Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis Vlt-accordion">
|
2
|
+
<button class="Vlt-accordion__trigger" data-accordion="acc<%= id %>" tabindex="0">
|
3
|
+
<%= ::I18n.t('.code_snippets.configure_client.initialize_dependencies') %>
|
4
|
+
</button>
|
5
5
|
|
6
|
-
|
6
|
+
<div id="acc<%=id %>" class="Vlt-accordion__content Vlt-accordion__content--noborder">
|
7
7
|
<%= create_instructions %>
|
8
8
|
<div class="copy-wrapper">
|
9
9
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
<div class="Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis">
|
2
|
-
<
|
1
|
+
<div class="Vlt-box Vlt-box--lesspadding Vlt-accordion Nxd-accordion-emphasis">
|
2
|
+
<button class="Vlt-accordion__trigger" data-accordion="acc<%= id %>" tabindex="0"><%= title %></button>
|
3
3
|
|
4
|
-
<div id="acc<%= id %>" class="Vlt-
|
4
|
+
<div id="acc<%= id %>" class="Vlt-accordion__content Vlt-accordion__content--noborder">
|
5
5
|
<p><%=deps['text']%></p>
|
6
6
|
<% if deps['code'] %>
|
7
7
|
<pre class="Vlt-prism--dark language-<%= deps['type'] || 'bash' %> dependencies command-line Vlt-prism--copy-disabled" data-prompt='$'><code><%=deps['code']%></code></pre>
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<div class="Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis">
|
2
|
-
<
|
1
|
+
<div class="Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis Vlt-accordion">
|
2
|
+
<button class="Vlt-accordion__trigger" data-accordion="acc<%= id %>" tabindex="0">
|
3
3
|
<%= ::I18n.t('.code_snippets.configure_client.import_dependencies') %>
|
4
|
-
</
|
4
|
+
</button>
|
5
5
|
|
6
|
-
<div id="acc<%=id %>"
|
6
|
+
<div id="acc<%=id %>" class="Vlt-accordion__content Vlt-accordion__content--noborder">
|
7
7
|
<%= create_instructions %>
|
8
8
|
<div class="copy-wrapper">
|
9
9
|
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexmo_markdown_renderer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nexmo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: banzai
|
@@ -260,7 +260,9 @@ files:
|
|
260
260
|
- lib/nexmo_markdown_renderer/filters/frontmatter_filter.rb
|
261
261
|
- lib/nexmo_markdown_renderer/filters/heading_filter.rb
|
262
262
|
- lib/nexmo_markdown_renderer/filters/i18n/frontmatter_filter.rb
|
263
|
-
- lib/nexmo_markdown_renderer/filters/i18n/
|
263
|
+
- lib/nexmo_markdown_renderer/filters/i18n/smartling/code_block_filter.rb
|
264
|
+
- lib/nexmo_markdown_renderer/filters/i18n/smartling/escape_filter.rb
|
265
|
+
- lib/nexmo_markdown_renderer/filters/i18n/smartling/frontmatter_filter.rb
|
264
266
|
- lib/nexmo_markdown_renderer/filters/icon_filter.rb
|
265
267
|
- lib/nexmo_markdown_renderer/filters/indent_filter.rb
|
266
268
|
- lib/nexmo_markdown_renderer/filters/inline_escape_filter.rb
|
@@ -293,10 +295,13 @@ files:
|
|
293
295
|
- lib/nexmo_markdown_renderer/models/tutorial/prerequisite.rb
|
294
296
|
- lib/nexmo_markdown_renderer/models/tutorial/task.rb
|
295
297
|
- lib/nexmo_markdown_renderer/models/use_case.rb
|
298
|
+
- lib/nexmo_markdown_renderer/pipelines/smartling/download.rb
|
299
|
+
- lib/nexmo_markdown_renderer/pipelines/smartling/preprocessor.rb
|
296
300
|
- lib/nexmo_markdown_renderer/services/code_snippet_renderer/android.rb
|
297
301
|
- lib/nexmo_markdown_renderer/services/code_snippet_renderer/base.rb
|
298
302
|
- lib/nexmo_markdown_renderer/services/code_snippet_renderer/curl.rb
|
299
303
|
- lib/nexmo_markdown_renderer/services/code_snippet_renderer/dotnet.rb
|
304
|
+
- lib/nexmo_markdown_renderer/services/code_snippet_renderer/go.rb
|
300
305
|
- lib/nexmo_markdown_renderer/services/code_snippet_renderer/java.rb
|
301
306
|
- lib/nexmo_markdown_renderer/services/code_snippet_renderer/javascript.rb
|
302
307
|
- lib/nexmo_markdown_renderer/services/code_snippet_renderer/kotlin.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Nexmo
|
2
|
-
module Markdown
|
3
|
-
module I18n
|
4
|
-
class SmartlingConverterFilter < Banzai::Filter
|
5
|
-
def call(input)
|
6
|
-
input = input.gsub(/\A\*\*\* \*\* \* \*\* \*\*\*\n*(.*)\n*------------------------------------------/m) do |_frontmatter|
|
7
|
-
front = $1.gsub(/`(.*):`(.*)/) do |_config|
|
8
|
-
"#{$1}:#{$2}"
|
9
|
-
end
|
10
|
-
<<~FRONTMATTER
|
11
|
-
---
|
12
|
-
#{front}
|
13
|
-
---
|
14
|
-
FRONTMATTER
|
15
|
-
end
|
16
|
-
input.gsub('\-', '-').gsub('\|', '|')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|