kramdown-mermaid 0.1.1 → 0.1.2

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: bb6576c262717d42ee9dc158bcaae66c361dc9aba99df5366336aa989f5d63d8
4
- data.tar.gz: d84e471413cbfb32b7070f63c511d5bdcccc642def6bc899d3f571815eec9fa5
3
+ metadata.gz: 5747e6858851060ab6e6e1af8b5cf6357a05c2902119f0eebb63e57ebf6bb1bd
4
+ data.tar.gz: 55a617e2987f41d40073c170ceaf2751657d447b875fc625c2d01bb4ddd98b2f
5
5
  SHA512:
6
- metadata.gz: 32406f8c3d83c82a8f18e6f80f00f03c75f61ef498c2e200fad1923ce3082c0c8c164bc515332b78d1d72b3a0698dced5b5645d4da352d59a267f0b58051eefc
7
- data.tar.gz: 37f569ea4c51cec12a256b99e7b897e5d028f3014d25f8d6fd2ed81e7cce52eaacf1cf91419438ff62e63a42fa3d3fcfe6a6fd0ccf55c53dd1eabdf9603af5b2
6
+ metadata.gz: 1bf3e87b1f9ca73a7b0a3637547334b20491c3d4bb8398b2e5b8863532d6749ad0a4bc292c8e41b39df3dae7cf93ea1ede874a345b856bb1e0c8f7079de14d7f
7
+ data.tar.gz: 31ce574c0b2df3410c279f212bdc27c1b0c72277efaf78a18c36e24ed308fe3a1c41ae033803051198d792caec176a460175a91cc390ae501f6bbb5296c98889
data/README.md CHANGED
@@ -1,32 +1,116 @@
1
- # [WIP] Kramdown::Mermaid
1
+ # kramdown-mermaid
2
2
 
3
- This gem is now work in progress.
3
+ This is a gem for parsing [Mermaid syntax](https://mermaid.js.org/), and is an extension of [kramdown](https://kramdown.gettalong.org/).
4
+
5
+ Currently, only parsing of [Entity Relationship Diagrams](https://mermaid.js.org/syntax/entityRelationshipDiagram.html) is supported, but we hope to support parsing of Class Diagrams and Sequence Diagrams and more in the future.
4
6
 
5
7
  ## Installation
6
8
 
7
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'kramdown-mermaid'
8
12
 
9
- Install the gem and add to the application's Gemfile by executing:
13
+ And then execute:
10
14
 
11
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
15
+ $ bundle install
12
16
 
13
- If bundler is not being used to manage dependencies, install the gem by executing:
17
+ Or install it yourself as:
14
18
 
15
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
19
+ $ gem install kramdown-mermaid
16
20
 
17
21
  ## Usage
18
22
 
19
- TODO: Write usage instructions here
23
+ require 'kramdown'
24
+ require 'kramdown-mermaid'
25
+
26
+ text = <<EOS
27
+
28
+ # some title
29
+ ccc **ddd** eee
30
+
31
+ # Image
32
+ ![Wikimedia](https://en.wikipedia.org/wiki/Wikimedia_Commons#/media/File:Commons-logo-en.svg "Wikimedia")
33
+
34
+ some comments
35
+
36
+ erDiagram %% some comment
37
+ hoges {
38
+ bigint id PK
39
+ int price
40
+ date start_on
41
+ datetime created_at
42
+ datetime updated_at
43
+ }
44
+
45
+ fugas {
46
+ bigint id PK
47
+ int price
48
+ datetime created_at
49
+ datetime updated_at
50
+ }
51
+
52
+ hoges |o--o{ fugas: "some comment"**
53
+ EOS
54
+
55
+ Kramdown::Document.new(text, input: 'KramdownMermaid').to_hash_ast
56
+
57
+ # =>
58
+ {:type=>:root,
59
+ :options=>{:encoding=>#<Encoding:UTF-8>, :location=>1, :options=>{}, :abbrev_defs=>{}, :abbrev_attr=>{}, :footnote_count=>0},
60
+ :children=>
61
+ [{:type=>:header,
62
+ :options=>{:level=>1, :raw_text=>"some title", :location=>1},
63
+ :children=>[{:type=>:text, :value=>"some title", :options=>{:location=>1}}]},
64
+ {:type=>:p,
65
+ :options=>{:location=>2},
66
+ :children=>
67
+ [{:type=>:text, :value=>"ccc ", :options=>{:location=>2}},
68
+ {:type=>:strong, :options=>{:location=>2}, :children=>[{:type=>:text, :value=>"ddd", :options=>{:location=>2}}]},
69
+ {:type=>:text, :value=>" eee", :options=>{:location=>2}}]},
70
+ {:type=>:blank, :value=>"\n"},
71
+ {:type=>:header, :options=>{:level=>1, :raw_text=>"Image", :location=>4}, :children=>[{:type=>:text, :value=>"Image", :options=>{:location=>4}}]},
72
+ {:type=>:p,
73
+ :options=>{:location=>5},
74
+ :children=>
75
+ [{:type=>:img,
76
+ :attr=>{"src"=>"https://en.wikipedia.org/wiki/Wikimedia_Commons#/media/File:Commons-logo-en.svg", "alt"=>"Wikimedia", "title"=>"Wikimedia"},
77
+ :options=>{:location=>5, :ial=>nil}}]},
78
+ {:type=>:blank, :value=>"\n"},
79
+ {:type=>:p, :options=>{:location=>7}, :children=>[{:type=>:text, :value=>"some comments", :options=>{:location=>7}}]},
80
+ {:type=>:blank, :value=>"\n"},
81
+ {:type=>:er_diagram, :value=>"erDiagram %% some comment \n", :options=>{:location=>10}},
82
+ {:type=>:p,
83
+ :options=>{:location=>10},
84
+ :children=>
85
+ [{:type=>:text,
86
+ :value=>"hoges { \n bigint id PK\n int price\n date start_on\n datetime created_at\n datetime updated_at\n }",
87
+ :options=>{:location=>10}}]},
88
+ {:type=>:entity,
89
+ :value=>" \n fugas {\n bigint id PK\n int price\n datetime created_at\n datetime updated_at\n }",
90
+ :options=>
91
+ {:entity=>"fugas",
92
+ :attributes=>
93
+ [{:type=>"bigint", :name=>"id", :constraint=>"PK"},
94
+ {:type=>"int", :name=>"price", :constraint=>nil},
95
+ {:type=>"datetime", :name=>"created_at", :constraint=>nil},
96
+ {:type=>"datetime", :name=>"updated_at", :constraint=>nil}],
97
+ :location=>24}},
98
+ {:type=>:relation,
99
+ :value=>"\n\nhoges |o--o{ fugas: \"some comment\"\n",
100
+ :options=>{:left_entity=>"hoges", :left_relation=>"|o", :right_relation=>"o{", :right_entity=>"fugas", :location=>26}}]}
101
+
20
102
 
21
103
  ## Development
22
104
 
23
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
105
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` or `bundle exec rspec` on root to run the tests.
106
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
107
 
25
108
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
109
 
27
110
  ## Contributing
28
111
 
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/kramdown-mermaid. 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/[USERNAME]/kramdown-mermaid/blob/master/CODE_OF_CONDUCT.md).
112
+ PRs and issues are always welcomed on GitHub at https://github.com/38tter/kramdown-mermaid.
113
+ 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/[USERNAME]/kramdown-mermaid/blob/master/CODE_OF_CONDUCT.md).
30
114
 
31
115
  ## License
32
116
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kramdown
4
4
  module Parser
5
- KRAMDOWN_MERMAID_VERSION = '0.1.1'
5
+ KRAMDOWN_MERMAID_VERSION = '0.1.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kramdown-mermaid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seiya Miyata