nexmo_markdown_renderer 0.6.0 → 0.7.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/lib/nexmo_markdown_renderer/filters/concerns/prism_code_snippet.rb +8 -1
- data/lib/nexmo_markdown_renderer/filters/i18n/frontmatter_filter.rb +13 -2
- data/lib/nexmo_markdown_renderer/filters/i18n/smartling/frontmatter_filter.rb +18 -2
- data/lib/nexmo_markdown_renderer/filters/markdown_filter.rb +4 -2
- data/lib/nexmo_markdown_renderer/pipelines/smartling/preprocessor.rb +1 -1
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77ca5e9a51e8e1d8d1e0d3e0fad14c48fb01ab3fc67e893e2c2e45f1061b0d5d
|
4
|
+
data.tar.gz: d83bcc9efe2cd831553a5dc9c362f2f6db75fd3553ebad6d312172571fdcf23a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 951a51a1bdebc045a64769796ce16aaa1262c3f889730485aff1051a320f4b21c658505ace846cfc0b7dd9ed6db75d8cb1046eba2481c4b4ec79b623980ce6c7
|
7
|
+
data.tar.gz: 4b93e1a292a403cc32726d63ff18eba1ebb6f26fc6e28e944fa4fb87eebd5682466edfa83620d21d6e1b3bf5386da4963900b620e9ec65e439552fc63b244871
|
@@ -2,9 +2,16 @@ module Nexmo
|
|
2
2
|
module Markdown
|
3
3
|
module Concerns
|
4
4
|
module PrismCodeSnippet
|
5
|
+
include OcticonsHelper
|
6
|
+
|
5
7
|
def code_snippet_body(lexer, body)
|
6
8
|
<<~HEREDOC
|
7
|
-
<
|
9
|
+
<div class="copy-wrapper">
|
10
|
+
<div class="copy-button" data-lang="#{code_language_to_prism(lexer.tag)}" data-section="code">
|
11
|
+
#{octicon "clippy", :class => 'top left'} <span>#{::I18n.t('code_snippets.copy_to_clipboard') }</span>
|
12
|
+
</div>
|
13
|
+
<pre class="#{prism_css_classes(lexer)}"><code>#{body}</code></pre>
|
14
|
+
</div>
|
8
15
|
HEREDOC
|
9
16
|
end
|
10
17
|
|
@@ -4,9 +4,20 @@ module Nexmo
|
|
4
4
|
class FrontmatterFilter < Banzai::Filter
|
5
5
|
def call(input)
|
6
6
|
input.gsub(/\A(---.+?---)/mo) do |frontmatter|
|
7
|
-
frontmatter.gsub(
|
8
|
-
|
7
|
+
output = frontmatter.gsub(/^languages:\n(^\s+- ([a-zA-Z]+)\n)+/) do |languages|
|
8
|
+
languages.gsub(/^\s+- ([a-zA-Z]+)\n+/) do |language|
|
9
|
+
" - ```#{$1}```\n\n"
|
10
|
+
end
|
9
11
|
end
|
12
|
+
output = output.gsub(/^(\w*:)(.*)\n/) do |_key|
|
13
|
+
if $1 == "products:"
|
14
|
+
"```#{$1}#{$2}```\n\n"
|
15
|
+
else
|
16
|
+
"```#{$1}```#{$2}\n\n"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
output
|
10
21
|
end
|
11
22
|
end
|
12
23
|
end
|
@@ -4,14 +4,30 @@ module Nexmo
|
|
4
4
|
module Smartling
|
5
5
|
class FrontmatterFilter < Banzai::Filter
|
6
6
|
def call(input)
|
7
|
-
input.gsub(/\A\*\*\* \*\* \* \*\* \*\*\*\n*(
|
8
|
-
front = $1.gsub(/`(.*)
|
7
|
+
input.gsub(/\A\*\*\* \*\* \* \*\* \*\*\*\n*(.*\n)!?(----+|\*\*\* \*\* \* \*\* \*\*\*)\n*/m) do |_frontmatter|
|
8
|
+
front = $1.gsub(/`products: (.*)`\n\n/) do |products|
|
9
|
+
"products: #{$1}\n\n"
|
10
|
+
end
|
11
|
+
|
12
|
+
front = front.gsub(/`(.*):`(.*)/) do |_config|
|
9
13
|
"#{$1}: #{$2}"
|
10
14
|
end
|
15
|
+
|
16
|
+
front = front.gsub(/languages: \n\n(.*)\n/m) do |_languages|
|
17
|
+
languages = $1.split("\n\n").map do |lang|
|
18
|
+
lang.gsub(/\* `(.*)`/) { |_l| " - #{$1}" }
|
19
|
+
end
|
20
|
+
<<~LANGUAGES
|
21
|
+
languages:
|
22
|
+
#{languages.join("\n")}
|
23
|
+
LANGUAGES
|
24
|
+
end
|
25
|
+
|
11
26
|
<<~FRONTMATTER
|
12
27
|
---
|
13
28
|
#{front}
|
14
29
|
---
|
30
|
+
|
15
31
|
FRONTMATTER
|
16
32
|
end
|
17
33
|
end
|
@@ -91,8 +91,10 @@ module Nexmo
|
|
91
91
|
code.gsub! /^ /, "\t"
|
92
92
|
end
|
93
93
|
|
94
|
-
formatter
|
95
|
-
formatter.format(lexer.lex(code))
|
94
|
+
formatter ||= Rouge::Formatters::HTML.new
|
95
|
+
highlighted_source = formatter.format(lexer.lex(code))
|
96
|
+
|
97
|
+
code_snippet_body(lexer, highlighted_source)
|
96
98
|
end
|
97
99
|
end
|
98
100
|
end
|
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.7.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-
|
11
|
+
date: 2020-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: banzai
|