fuji_markdown 0.4.0 → 0.4.1

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
  SHA256:
3
- metadata.gz: 0e641373ec793135f6072dc2525b081db86b590618260ced757ba79a9e92604c
4
- data.tar.gz: 52ea47ffb8b02107bc7071c9895ec111d1763d38c46bbde0f1d37e99509f3aab
3
+ metadata.gz: d596f7b5a4ffb1833c3b305c0fc86ff89ca9fc76c1659135c9f2c39245429221
4
+ data.tar.gz: 89c48f513b16677073e88aca5f86384e432d681f2bb588819fd970cf5df044e3
5
5
  SHA512:
6
- metadata.gz: 10eb84854b743bdf5d17af4b386a974b9523f106c2d8d905a14df9dbef7bc3571fcad4823f3fc473dd12529a9223deb3b8f461eb97f4c6e594bbb828ea42ec92
7
- data.tar.gz: 9d6a3ddc3b9518b967f7ce4afa02a6de998d323c779dcdbba24d2ff41f43997b2dd5b492dcc01fe8adbe7450ab4ee78a40bf40b026dae7dd565c38cc399f05cb
6
+ metadata.gz: 40015bf7c0be7a04298d60f52540d0210a20143fb11d95f5a8d2e8a9016458dce72f6806455fd84bf2c195bdc895ecc121c0a95d08fa44f51def93291c63b1e9
7
+ data.tar.gz: '09ce44473e30d5fc2b1c785dadfa6a38f09c7cff2fda858af8eb93dda1cc8ce5b5846819245e3a7551c000edc52656ee3737ea1b529a862fff66e241d0c3bf51'
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.4.1]
11
+
12
+ ### Fixed
13
+
14
+ - Stop holding presets as constants.
15
+
10
16
  ## [0.4.0] - 2020-10-12
11
17
 
12
18
  ### Added
@@ -18,5 +24,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
18
24
  - Specify required_ruby_version to '>= 2.6'.
19
25
  - Make preprocessors not to change given text destructively.
20
26
 
21
- [Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.4.0...HEAD
22
- [0.4.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.3.1...v0.4.0
27
+ [Unreleased]: https://github.com/fuji-nakahara/fuji_markdown/compare/v0.4.1...HEAD
28
+ [0.4.1]: https://github.com/fuji-nakahara/fuji_markdown/compare/v0.4.0...v0.4.1
29
+ [0.4.0]: https://github.com/fuji-nakahara/fuji_markdown/compare/v0.3.1...v0.4.0
@@ -68,7 +68,7 @@ members of the project's leadership.
68
68
  ## Attribution
69
69
 
70
70
  This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
72
 
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/README.md CHANGED
@@ -50,7 +50,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
50
50
 
51
51
  ## Contributing
52
52
 
53
- Bug reports and pull requests are welcome on GitHub at https://github.com/fuji-nakahara/fuji_markdown. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
53
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fuji-nakahara/fuji_markdown. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/fuji-nakahara/fuji_markdown/blob/master/CODE_OF_CONDUCT.md).
54
54
 
55
55
  ## License
56
56
 
@@ -58,4 +58,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
58
58
 
59
59
  ## Code of Conduct
60
60
 
61
- Everyone interacting in the FujiMarkdown projects codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fuji-nakahara/fuji_markdown/blob/master/CODE_OF_CONDUCT.md).
61
+ Everyone interacting in the FujiMarkdown project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fuji-nakahara/fuji_markdown/blob/master/CODE_OF_CONDUCT.md).
@@ -10,36 +10,41 @@ require_relative 'fuji_markdown/renderers/kakuyomu_renderer'
10
10
  require_relative 'fuji_markdown/renderers/narou_renderer'
11
11
 
12
12
  module FujiMarkdown
13
- PRESETS = {
14
- HTML: {
15
- preprocessors: [Preprocessors::Ruby.new],
16
- renderer: CommonMarker::HtmlRenderer.new(options: %i[HARDBREAKS UNSAFE])
17
- },
18
- KAKUYOMU: {
19
- preprocessors: [Preprocessors::Ruby.new, proc { |text| text.gsub(/《/, '|《') }],
20
- postprocessors: [Postprocessors::Ruby.new],
21
- renderer: Renderers::KakuyomuRenderer.new
22
- },
23
- NAROU: {
24
- preprocessors: [Preprocessors::Ruby.new, Preprocessors::EscapeNarou.new],
25
- postprocessors: [Postprocessors::Ruby.new],
26
- renderer: Renderers::NarouRenderer.new
27
- }
28
- }.freeze
29
-
30
13
  class << self
31
14
  def parse(text, preset = :HTML)
32
- options = PRESETS.fetch(preset)
15
+ options = build_options_from_preset(preset)
33
16
  Processor.new(**options).parse(text)
34
- rescue KeyError => e
35
- raise InvalidPresetError, "Invalid preset: #{e.key}"
36
17
  end
37
18
 
38
19
  def render(text, preset = :HTML)
39
- options = PRESETS.fetch(preset)
20
+ options = build_options_from_preset(preset)
40
21
  Processor.new(**options).render(text)
41
- rescue KeyError => e
42
- raise InvalidPresetError, "Invalid preset: #{e.key}"
22
+ end
23
+
24
+ private
25
+
26
+ def build_options_from_preset(preset) # rubocop:disable Metrics/MethodLength
27
+ case preset
28
+ when :HTML
29
+ {
30
+ preprocessors: [Preprocessors::Ruby.new],
31
+ renderer: CommonMarker::HtmlRenderer.new(options: %i[HARDBREAKS UNSAFE])
32
+ }
33
+ when :KAKUYOMU
34
+ {
35
+ preprocessors: [Preprocessors::Ruby.new, proc { |text| text.gsub(/《/, '|《') }],
36
+ postprocessors: [Postprocessors::Ruby.new],
37
+ renderer: Renderers::KakuyomuRenderer.new
38
+ }
39
+ when :NAROU
40
+ {
41
+ preprocessors: [Preprocessors::Ruby.new, Preprocessors::EscapeNarou.new],
42
+ postprocessors: [Postprocessors::Ruby.new],
43
+ renderer: Renderers::NarouRenderer.new
44
+ }
45
+ else
46
+ raise InvalidPresetError, "Invalid preset: #{preset}"
47
+ end
43
48
  end
44
49
  end
45
50
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FujiMarkdown
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuji_markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fuji Nakahara
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-12 00:00:00.000000000 Z
11
+ date: 2020-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commonmarker