wcc-contentful-app 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 847b51e62b8b74d6d2d41af8b69db98fc53341bb80423e84e586433398f5d151
4
- data.tar.gz: 1fc55b4e5dac3db2e62ade4bc5abadb5cb5217bac8af0a225b67bd0157e81ede
3
+ metadata.gz: 90e14d9120bf9e13feaac1b38d6de53374798a9b384bcc6b4acf099ffd83b183
4
+ data.tar.gz: f4276cdb1f6f466dd8252a5316ca0bb0a86310cabdf96e889a66bc68b8084194
5
5
  SHA512:
6
- metadata.gz: 5f93bb72ceb5ead8a965da22d9f5de330efd18243086e0f64684c38e8de3d1bd034dee6368473386eb9120554e617c77d60280566b7de28b6fe350c87eaa58d2
7
- data.tar.gz: 8b0cf60b8f3d5374c1371f0684cc08896e6b05b82f0b30192e343be58c43c6f94b6a8f88dedfb4c31b8510e9634175836ae78615eae415a2c197e33ba439f85e
6
+ metadata.gz: c14a98f65f94a006d19b36b9ffd731ae0973190e12ef78be4188da0bc9429975a6657e04c7548ee3950d70d2d41105ceed703815754e87fc32abee2a90d19583
7
+ data.tar.gz: '09e349ec2bf158a6c6c5dbc7cf281e6850d35397c85bd9fd99bdfdb7acbca7bac28a7e83945bb2543f186e1f1ac388c00abf697ad9fd54615d7337a19f2dc4d3'
@@ -34,8 +34,11 @@ module WCC::Contentful::App::SectionHelper
34
34
  CGI.escape(title.gsub(/\W+/, '-')) if title.present?
35
35
  end
36
36
 
37
- def markdown(text)
38
- html_to_render = WCC::Contentful::App::MarkdownRenderer.new.markdown(text)
37
+ def markdown(text, options = {})
38
+ renderer = WCC::Contentful::App::MarkdownRenderer.new(
39
+ options
40
+ )
41
+ html_to_render = renderer.markdown(text)
39
42
 
40
43
  content_tag(:div,
41
44
  CGI.unescapeHTML(html_to_render).html_safe,
@@ -3,33 +3,42 @@
3
3
  require_relative './custom_markdown_render'
4
4
 
5
5
  class WCC::Contentful::App::MarkdownRenderer
6
- def markdown(text)
7
- raise ArgumentError, 'markdown method requires text' unless text
6
+ attr_reader :options, :extensions
8
7
 
9
- markdown_links = links_within_markdown(text)
10
- links_with_classes, raw_classes = gather_links_with_classes_data(markdown_links)
8
+ def initialize(options = nil)
9
+ @extensions = {
10
+ autolink: true,
11
+ superscript: true,
12
+ disable_indented_code_blocks: true,
13
+ tables: true
14
+ }.merge!(options&.delete(:extensions) || {})
11
15
 
12
- options = {
16
+ @options = {
13
17
  filter_html: true,
14
18
  hard_wrap: true,
15
19
  link_attributes: { target: '_blank' },
16
20
  space_after_headers: true,
17
- fenced_code_blocks: true,
18
- links_with_classes: links_with_classes
19
- }
21
+ fenced_code_blocks: true
22
+ }.merge!(options || {})
23
+ end
20
24
 
21
- extensions = {
22
- autolink: true,
23
- superscript: true,
24
- disable_indented_code_blocks: true,
25
- tables: true
26
- }
25
+ def markdown(text)
26
+ raise ArgumentError, 'markdown method requires text' unless text
27
+
28
+ markdown_links = links_within_markdown(text)
29
+ links_with_classes, raw_classes = gather_links_with_classes_data(markdown_links)
30
+
31
+ options = @options.merge({
32
+ links_with_classes: links_with_classes
33
+ })
27
34
 
28
35
  renderer = ::WCC::Contentful::App::CustomMarkdownRender.new(options)
29
36
  markdown = ::Redcarpet::Markdown.new(renderer, extensions)
30
37
  markdown.render(remove_markdown_href_class_syntax(raw_classes, text))
31
38
  end
32
39
 
40
+ alias_method :call, :markdown
41
+
33
42
  private
34
43
 
35
44
  def remove_markdown_href_class_syntax(raw_classes, text)
@@ -3,7 +3,7 @@
3
3
  module WCC
4
4
  module Contentful
5
5
  module App
6
- VERSION = '1.0.7'
6
+ VERSION = '1.0.8'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wcc-contentful-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Watermark Dev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-21 00:00:00.000000000 Z
11
+ date: 2022-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -352,14 +352,14 @@ dependencies:
352
352
  requirements:
353
353
  - - "~>"
354
354
  - !ruby/object:Gem::Version
355
- version: 1.0.7
355
+ version: 1.0.8
356
356
  type: :runtime
357
357
  prerelease: false
358
358
  version_requirements: !ruby/object:Gem::Requirement
359
359
  requirements:
360
360
  - - "~>"
361
361
  - !ruby/object:Gem::Version
362
- version: 1.0.7
362
+ version: 1.0.8
363
363
  description: Models, Controllers, and Views common to Watermark Church apps
364
364
  email:
365
365
  - dev@watermark.org
@@ -459,7 +459,7 @@ licenses:
459
459
  - MIT
460
460
  metadata:
461
461
  documentation_uri: https://watermarkchurch.github.io/wcc-contentful/1.0/wcc-contentful-app
462
- post_install_message:
462
+ post_install_message:
463
463
  rdoc_options: []
464
464
  require_paths:
465
465
  - lib
@@ -474,9 +474,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
474
474
  - !ruby/object:Gem::Version
475
475
  version: '0'
476
476
  requirements: []
477
- rubyforge_project:
477
+ rubyforge_project:
478
478
  rubygems_version: 2.7.6.2
479
- signing_key:
479
+ signing_key:
480
480
  specification_version: 4
481
481
  summary: "[![Gem Version](https://badge.fury.io/rb/wcc-contentful-app.svg)](https://rubygems.org/gems/wcc-contentful-app)
482
482
  [![Build Status](https://circleci.com/gh/watermarkchurch/wcc-contentful.svg?style=svg)](https://circleci.com/gh/watermarkchurch/wcc-contentful)