markdown-ui 0.1.16 → 0.1.17

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.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/Changelog +14 -0
  4. data/Gemfile +3 -0
  5. data/components/collections/markdown-ui-grid/lib/grid/column/column.rb +6 -9
  6. data/components/collections/markdown-ui-grid/lib/grid/grid.rb +6 -9
  7. data/components/collections/markdown-ui-grid/lib/grid/row/row.rb +6 -9
  8. data/components/collections/markdown-ui-grid/markdown-ui-grid.gemspec +1 -1
  9. data/components/collections/markdown-ui-menu/lib/menu/custom.rb +12 -12
  10. data/components/collections/markdown-ui-menu/lib/menu/element.rb +54 -52
  11. data/components/collections/markdown-ui-menu/lib/menu/pagination.rb +11 -10
  12. data/components/collections/markdown-ui-menu/lib/menu/pointing.rb +11 -10
  13. data/components/collections/markdown-ui-menu/lib/menu/secondary.rb +11 -10
  14. data/components/collections/markdown-ui-menu/lib/menu/standard.rb +11 -10
  15. data/components/collections/markdown-ui-menu/lib/menu/tabular.rb +11 -10
  16. data/components/collections/markdown-ui-menu/lib/menu/text.rb +11 -10
  17. data/components/collections/markdown-ui-menu/lib/menu/vertical.rb +11 -10
  18. data/components/collections/markdown-ui-message/lib/message/custom_message.rb +11 -11
  19. data/components/collections/markdown-ui-message/lib/message/list_message.rb +10 -9
  20. data/components/collections/markdown-ui-message/lib/message/message.rb +32 -29
  21. data/components/collections/markdown-ui-message/lib/message/standard_message.rb +10 -9
  22. data/components/collections/markdown-ui-message/lib/message/version.rb +1 -1
  23. data/components/collections/markdown-ui-message/markdown-ui-message.gemspec +2 -2
  24. data/components/elements/markdown-ui-button/lib/button/animated.rb +24 -22
  25. data/components/elements/markdown-ui-button/lib/button/basic.rb +14 -12
  26. data/components/elements/markdown-ui-button/lib/button/custom.rb +16 -14
  27. data/components/elements/markdown-ui-button/lib/button/element.rb +55 -53
  28. data/components/elements/markdown-ui-button/lib/button/focusable.rb +14 -12
  29. data/components/elements/markdown-ui-button/lib/button/group/buttons/custom.rb +14 -12
  30. data/components/elements/markdown-ui-button/lib/button/group/buttons/element.rb +22 -20
  31. data/components/elements/markdown-ui-button/lib/button/group/buttons/icon.rb +14 -12
  32. data/components/elements/markdown-ui-button/lib/button/group/buttons/standard.rb +14 -12
  33. data/components/elements/markdown-ui-button/lib/button/icon.rb +14 -12
  34. data/components/elements/markdown-ui-button/lib/button/labeled_icon.rb +19 -17
  35. data/components/elements/markdown-ui-button/lib/button/standard.rb +14 -12
  36. data/components/elements/markdown-ui-container/lib/container/alignment/center.rb +1 -1
  37. data/components/elements/markdown-ui-container/lib/container/alignment/left.rb +1 -1
  38. data/components/elements/markdown-ui-container/lib/container/alignment/right.rb +1 -1
  39. data/components/elements/markdown-ui-container/lib/container/custom.rb +1 -1
  40. data/components/elements/markdown-ui-container/lib/container/element.rb +5 -5
  41. data/components/elements/markdown-ui-container/lib/container/standard.rb +1 -1
  42. data/components/elements/markdown-ui-container/lib/container/text.rb +1 -1
  43. data/components/elements/markdown-ui-content/lib/content/basic_block.rb +19 -0
  44. data/components/elements/markdown-ui-content/lib/content/content_block.rb +1 -1
  45. data/components/elements/markdown-ui-content/lib/content/custom.rb +1 -1
  46. data/components/elements/markdown-ui-content/lib/content/divider_block.rb +1 -1
  47. data/components/elements/markdown-ui-content/lib/content/field_block.rb +1 -1
  48. data/components/elements/markdown-ui-content/lib/content/flag.rb +2 -2
  49. data/components/elements/markdown-ui-content/lib/content/form_block.rb +1 -1
  50. data/components/elements/markdown-ui-content/lib/content/header.rb +2 -2
  51. data/components/elements/markdown-ui-content/lib/content/header_block.rb +1 -1
  52. data/components/elements/markdown-ui-content/lib/content/icon.rb +2 -2
  53. data/components/elements/markdown-ui-content/lib/content/input_block.rb +1 -1
  54. data/components/elements/markdown-ui-content/lib/content/item.rb +4 -4
  55. data/components/elements/markdown-ui-content/lib/content/item_block.rb +1 -1
  56. data/components/elements/markdown-ui-content/lib/content/list.rb +6 -6
  57. data/components/elements/markdown-ui-content/lib/content/parser.rb +17 -17
  58. data/components/elements/markdown-ui-content/lib/content/span_block.rb +1 -1
  59. data/components/elements/markdown-ui-content/lib/content/text.rb +6 -6
  60. data/components/elements/markdown-ui-header/lib/header/header.rb +3 -3
  61. data/components/elements/markdown-ui-input/lib/input/custom.rb +4 -4
  62. data/components/elements/markdown-ui-input/lib/input/element.rb +10 -10
  63. data/components/elements/markdown-ui-label/lib/label/custom.rb +2 -2
  64. data/components/elements/markdown-ui-label/lib/label/element.rb +9 -16
  65. data/components/elements/markdown-ui-segment/lib/segment/custom_segment.rb +1 -1
  66. data/components/elements/markdown-ui-segment/lib/segment/horizontal_segment.rb +1 -1
  67. data/components/elements/markdown-ui-segment/lib/segment/padded_segment.rb +1 -1
  68. data/components/elements/markdown-ui-segment/lib/segment/piled_segment.rb +1 -1
  69. data/components/elements/markdown-ui-segment/lib/segment/segment.rb +6 -6
  70. data/components/elements/markdown-ui-segment/lib/segment/stacked_segment.rb +1 -1
  71. data/components/elements/markdown-ui-segment/lib/segment/standard_segment.rb +1 -1
  72. data/components/elements/markdown-ui-segment/lib/segment/vertical_segment.rb +1 -1
  73. data/components/shared/markdown-ui-shared/Gemfile +2 -0
  74. data/components/shared/markdown-ui-shared/lib/markdown-ui-shared.rb +3 -0
  75. data/components/shared/markdown-ui-shared/lib/shared/tag_klass.rb +77 -0
  76. data/components/shared/markdown-ui-shared/lib/shared/version.rb +5 -0
  77. data/components/shared/markdown-ui-shared/markdown-ui-shared.gemspec +37 -0
  78. data/lib/markdown-ui.rb +10 -132
  79. data/lib/markdown-ui/renderers/block_quote.rb +47 -0
  80. data/lib/markdown-ui/renderers/double_emphasis.rb +97 -0
  81. data/lib/markdown-ui/renderers/emphasis.rb +23 -0
  82. data/lib/markdown-ui/renderers/header.rb +9 -0
  83. data/lib/markdown-ui/renderers/horizontal_rule.rb +19 -0
  84. data/lib/markdown-ui/renderers/link.rb +10 -0
  85. data/lib/markdown-ui/renderers/list.rb +10 -0
  86. data/lib/markdown-ui/renderers/paragraph.rb +9 -0
  87. data/lib/markdown-ui/renderers/quote.rb +9 -0
  88. data/lib/markdown-ui/shared.rb +7 -0
  89. data/lib/markdown-ui/tag/article_tag.rb +14 -0
  90. data/lib/markdown-ui/tag/button_tag.rb +6 -19
  91. data/lib/markdown-ui/tag/custom_tag.rb +11 -10
  92. data/lib/markdown-ui/tag/focusable_button_tag.rb +6 -19
  93. data/lib/markdown-ui/tag/footer_tag.rb +14 -0
  94. data/lib/markdown-ui/tag/header_tag.rb +14 -0
  95. data/lib/markdown-ui/tag/input_tag.rb +7 -27
  96. data/lib/markdown-ui/tag/item_tag.rb +6 -14
  97. data/lib/markdown-ui/tag/label_tag.rb +6 -19
  98. data/lib/markdown-ui/tag/list_tag.rb +18 -21
  99. data/lib/markdown-ui/tag/section_tag.rb +14 -0
  100. data/lib/markdown-ui/tag/span_tag.rb +7 -7
  101. data/lib/markdown-ui/tag/standard_tag.rb +6 -19
  102. data/lib/markdown-ui/tag/tag.rb +18 -20
  103. data/lib/markdown-ui/tools/html_formatter.rb +11 -0
  104. data/lib/markdown-ui/utils/klass_util.rb +13 -3
  105. data/lib/markdown-ui/version.rb +1 -1
  106. data/website/docs/flag.html +1 -1
  107. data/website/docs/icon.html +609 -0
  108. data/website/docs/icon.md +691 -0
  109. data/website/docs/toc.html +4 -0
  110. data/website/docs/toc.md +5 -2
  111. data/website/index.html +2 -2
  112. metadata +25 -2
@@ -0,0 +1,7 @@
1
+ module MarkdownUI
2
+ module Shared
3
+ ['../../components/shared/**/*.rb'].each do |dir|
4
+ Dir[File.join(File.dirname(__FILE__), dir)].sort.each { |f| require_relative f }
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ module MarkdownUI
2
+ class ArticleTag < MarkdownUI::Shared::TagKlass
3
+ def initialize(_content, _klass = nil, __id = nil, _data = nil)
4
+ @klass = _klass
5
+ @content = _content
6
+ @data = _data
7
+ @id = __id
8
+ end
9
+
10
+ def render
11
+ "<article#{_id}#{klass}#{data}>#{content}</article>"
12
+ end
13
+ end
14
+ end
@@ -1,26 +1,13 @@
1
1
  module MarkdownUI
2
- class ButtonTag
3
- def initialize(content, klass = nil, _id = nil, data = nil)
4
- @klass = klass
5
- @content = content
6
- @data = data
7
- @id = _id
2
+ class ButtonTag < MarkdownUI::Shared::TagKlass
3
+ def initialize(_content, _klass = nil, __id = nil, _data = nil)
4
+ @klass = _klass
5
+ @content = _content
6
+ @data = _data
7
+ @id = __id
8
8
  end
9
9
 
10
10
  def render
11
- content = @content.strip unless @content.nil?
12
- klass = MarkdownUI::KlassUtil.new(@klass).klass unless @klass.nil?
13
- _id = if @id
14
- " id=\'#{@id.split.join('-')}\'"
15
- end
16
-
17
- data = if @data
18
- _data, attribute, value = @data.split(':')
19
- " data-#{attribute}=\'#{value}\'"
20
- else
21
- nil
22
- end
23
-
24
11
  "<button#{_id}#{klass}#{data}>#{content}</button>"
25
12
  end
26
13
  end
@@ -1,18 +1,13 @@
1
1
  # coding: UTF-8
2
-
3
2
  module MarkdownUI
4
- class CustomTag
5
- def initialize(tag, content, klass = nil)
6
- @tag = tag
7
- @klass = klass
8
- @content = content
3
+ class CustomTag < MarkdownUI::Shared::TagKlass
4
+ def initialize(_tag, _content, _klass = nil)
5
+ @tag = _tag
6
+ @klass = _klass
7
+ @content = _content
9
8
  end
10
9
 
11
10
  def render
12
- klass = MarkdownUI::KlassUtil.new("#{@klass}").klass
13
- tag = @tag.downcase.strip
14
- content = MarkdownUI::Content::Parser.new(@content).parse
15
-
16
11
  output = []
17
12
  output << "<#{tag}"
18
13
  output << "#{klass}>"
@@ -21,5 +16,11 @@ module MarkdownUI
21
16
 
22
17
  output.join(' ')
23
18
  end
19
+
20
+ protected
21
+
22
+ def tag
23
+ @tag.downcase.strip
24
+ end
24
25
  end
25
26
  end
@@ -1,26 +1,13 @@
1
1
  module MarkdownUI
2
- class FocusableButtonTag
3
- def initialize(content, klass = nil, _id = nil, data = nil)
4
- @klass = klass
5
- @content = content
6
- @data = data
7
- @id = _id
2
+ class FocusableButtonTag < MarkdownUI::Shared::TagKlass
3
+ def initialize(_content, _klass = nil, __id = nil, _data = nil)
4
+ @klass = _klass
5
+ @content = _content
6
+ @data = _data
7
+ @id = __id
8
8
  end
9
9
 
10
10
  def render
11
- content = @content.strip unless @content.nil?
12
- klass = MarkdownUI::KlassUtil.new(@klass).klass unless @klass.nil?
13
- _id = if @id
14
- " id=\'#{@id.split.join('-')}\'"
15
- end
16
-
17
- data = if @data
18
- _data, attribute, value = @data.split(':')
19
- " data-#{attribute}=\'#{value}\'"
20
- else
21
- nil
22
- end
23
-
24
11
  "<div#{_id}#{klass}#{data} tabindex=\'0\'>#{content}</div>"
25
12
  end
26
13
  end
@@ -0,0 +1,14 @@
1
+ module MarkdownUI
2
+ class FooterTag < MarkdownUI::Shared::TagKlass
3
+ def initialize(_content, _klass = nil, __id = nil, _data = nil)
4
+ @klass = _klass
5
+ @content = _content
6
+ @data = _data
7
+ @id = __id
8
+ end
9
+
10
+ def render
11
+ "<footer#{_id}#{klass}#{data}>#{content}</footer>"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module MarkdownUI
2
+ class HeaderTag < MarkdownUI::Shared::TagKlass
3
+ def initialize(_content, _klass = nil, __id = nil, _data = nil)
4
+ @klass = _klass
5
+ @content = _content
6
+ @data = _data
7
+ @id = __id
8
+ end
9
+
10
+ def render
11
+ "<header#{_id}#{klass}#{data}>#{content}</header>"
12
+ end
13
+ end
14
+ end
@@ -1,34 +1,14 @@
1
1
  module MarkdownUI
2
- class InputTag
3
- def initialize(content, klass = nil, _id = nil, data = nil)
4
- @klass = klass
5
- @content = content
6
- @data = data
7
- @id = _id
2
+ class InputTag < MarkdownUI::Shared::TagKlass
3
+ def initialize(_content, _klass = nil, __id = nil, _data = nil)
4
+ @klass = _klass
5
+ @content = _content
6
+ @data = _data
7
+ @id = __id
8
8
  end
9
9
 
10
10
  def render
11
- content = if @content
12
- " type=\'#{@content.strip.downcase}\'"
13
- else
14
- nil
15
- end
16
-
17
- klass = MarkdownUI::KlassUtil.new(@klass).klass unless @klass.nil?
18
-
19
- _id = if @id
20
- " placeholder=\'#{@id.capitalize}\'"
21
- end
22
-
23
- data = if @data
24
- _data, attribute, value = @data.split(':')
25
- " data-#{attribute}=\'#{value}\'"
26
- else
27
- nil
28
- end
29
-
30
-
31
- "<input#{content}#{_id}#{klass}#{data} />"
11
+ "<input#{input_content}#{_input_id}#{klass}#{data} />"
32
12
  end
33
13
  end
34
14
  end
@@ -1,22 +1,14 @@
1
1
  module MarkdownUI
2
- class ItemTag
3
- def initialize(content, klass = nil, link = nil)
4
- @klass = klass
5
- @content = content
6
- @link = link
2
+ class ItemTag < MarkdownUI::Shared::TagKlass
3
+ def initialize(_content, _klass = nil, _link = nil)
4
+ @klass = _klass
5
+ @content = _content
6
+ @link = _link
7
7
  end
8
8
 
9
9
  def render
10
10
  content, @data = @content.split(';')
11
- klass = MarkdownUI::KlassUtil.new(@klass).klass if @klass
12
- link = " href=\'#{@link.strip}\'" if @link
13
-
14
- data = if @data
15
- _data, attribute, value = @data.split(':')
16
- " data-#{attribute}=\'#{value}\'"
17
- else
18
- nil
19
- end
11
+ link = " href=\'#{@link.strip}\'" if @link
20
12
 
21
13
  "<a#{klass}#{data}#{link}>#{content}</a>"
22
14
  end
@@ -1,26 +1,13 @@
1
1
  module MarkdownUI
2
- class LabelTag
3
- def initialize(content, klass = nil, _id = nil, data = nil)
4
- @klass = klass
5
- @content = content
6
- @data = data
7
- @id = _id
2
+ class LabelTag < MarkdownUI::Shared::TagKlass
3
+ def initialize(_content, _klass = nil, __id = nil, _data = nil)
4
+ @klass = _klass
5
+ @content = _content
6
+ @data = _data
7
+ @id = __id
8
8
  end
9
9
 
10
10
  def render
11
- content = @content.strip unless @content.nil?
12
- klass = MarkdownUI::KlassUtil.new(@klass).klass unless @klass.nil?
13
- _id = if @id
14
- " id=\'#{@id.split.join('-')}\'"
15
- end
16
-
17
- data = if @data
18
- _data, attribute, value = @data.split(':')
19
- " data-#{attribute}=\'#{value}\'"
20
- else
21
- nil
22
- end
23
-
24
11
  "<label#{_id}#{klass}#{data}>#{content}</label>"
25
12
  end
26
13
  end
@@ -1,23 +1,28 @@
1
1
  module MarkdownUI
2
- class ListTag
3
- def initialize(content, klass = nil, type = nil, data = nil)
4
- @klass = klass
5
- @content = content
6
- @type = type
7
- @data = data
2
+ class ListTag < MarkdownUI::Shared::TagKlass
3
+ def initialize(_content, _klass = nil, _type = nil, _data = nil)
4
+ @klass = _klass
5
+ @content = _content
6
+ @type = _type
7
+ @data = _data
8
8
  end
9
9
 
10
10
  def render
11
11
  content = @content.split(';')
12
- klass = MarkdownUI::KlassUtil.new(@klass).klass
13
12
 
14
- data = if @data
15
- _data, attribute, value = @data.split(':')
16
- " data-#{attribute}=\'#{value}\'"
17
- else
18
- nil
13
+ @type = :unordered if @type.nil?
14
+
15
+ case @type
16
+ when :ordered
17
+ "<ol#{klass}#{data}>#{list(content)}</ol>"
18
+ when :unordered
19
+ "<ul#{klass}#{data}>#{list(content)}</ul>"
19
20
  end
21
+ end
22
+
23
+ protected
20
24
 
25
+ def list(content)
21
26
  list = ''
22
27
  if !content.grep(/^\<li\>.*/).empty?
23
28
  list = content.join
@@ -26,15 +31,7 @@ module MarkdownUI
26
31
  list += "<li>#{c}</li>"
27
32
  end
28
33
  end
29
-
30
- @type = :unordered if @type.nil?
31
-
32
- case @type
33
- when :ordered
34
- "<ol#{klass}#{data}>#{list}</ol>"
35
- when :unordered
36
- "<ul#{klass}#{data}>#{list}</ul>"
37
- end
34
+ list
38
35
  end
39
36
  end
40
37
  end
@@ -0,0 +1,14 @@
1
+ module MarkdownUI
2
+ class SectionTag < MarkdownUI::Shared::TagKlass
3
+ def initialize(_content, _klass = nil, __id = nil, _data = nil)
4
+ @klass = _klass
5
+ @content = _content
6
+ @data = _data
7
+ @id = __id
8
+ end
9
+
10
+ def render
11
+ "<section#{_id}#{klass}#{data}>#{content}</section>"
12
+ end
13
+ end
14
+ end
@@ -1,14 +1,14 @@
1
1
  module MarkdownUI
2
- class SpanTag
3
- def initialize(content, klass = nil)
4
- @klass = klass
5
- @content = content
2
+ class SpanTag < MarkdownUI::Shared::TagKlass
3
+ def initialize(_content, _klass = nil, __id = nil, _data = nil)
4
+ @klass = _klass
5
+ @content = _content
6
+ @data = _data
7
+ @id = __id
6
8
  end
7
9
 
8
10
  def render
9
- klass = "#{@klass}".downcase.split(' ').uniq
10
-
11
- "<span class=\'#{klass.join(' ').strip}\'>#{@content}</span>"
11
+ "<span#{_id}#{klass}#{data}>#{content}</span>"
12
12
  end
13
13
  end
14
14
  end
@@ -1,26 +1,13 @@
1
1
  module MarkdownUI
2
- class StandardTag
3
- def initialize(content, klass = nil, _id = nil, data = nil)
4
- @klass = klass
5
- @content = content
6
- @data = data
7
- @id = _id
2
+ class StandardTag < MarkdownUI::Shared::TagKlass
3
+ def initialize(_content, _klass = nil, __id = nil, _data = nil)
4
+ @klass = _klass
5
+ @content = _content
6
+ @data = _data
7
+ @id = __id
8
8
  end
9
9
 
10
10
  def render
11
- content = @content.strip unless @content.nil?
12
- klass = MarkdownUI::KlassUtil.new(@klass).klass unless @klass.nil?
13
- _id = if @id
14
- " id=\'#{@id.split.join('-')}\'"
15
- end
16
-
17
- data = if @data
18
- _data, attribute, value = @data.split(':')
19
- " data-#{attribute}=\'#{value}\'"
20
- else
21
- nil
22
- end
23
-
24
11
  "<div#{_id}#{klass}#{data}>#{content}</div>"
25
12
  end
26
13
  end
@@ -1,28 +1,26 @@
1
1
  module MarkdownUI
2
- class Tag
3
- def initialize(tag, content, klass = nil, data = nil)
4
- @mode = OpenStruct.new(
5
- :div? => !(tag =~ /div/i).nil?,
6
- :label? => !(tag =~ /label/i).nil?,
7
- :span? => !(tag =~ /span/i).nil?,
8
- :article? => !(tag =~ /article/i).nil?,
9
- :section? => !(tag =~ /section/i).nil?,
10
- :header? => !(tag =~ /header/i).nil?,
11
- :footer? => !(tag =~ /footer/i).nil?
2
+ class Tag < MarkdownUI::Shared::TagKlass
3
+ def initialize(_tag, _content, _klass = nil, _data = nil)
4
+ @elements = Hash.new(MarkdownUI::StandardTag).merge(
5
+ div: MarkdownUI::StandardTag,
6
+ label: MarkdownUI::LabelTag,
7
+ span: MarkdownUI::SpanTag,
8
+ article: MarkdownUI::ArticleTag,
9
+ section: MarkdownUI::SectionTag,
10
+ header: MarkdownUI::HeaderTag,
11
+ footer: MarkdownUI::FooterTag
12
12
  )
13
- @tag = tag
14
- @content = content
15
- @klass = klass
16
- @data = data
13
+
14
+ @tag = _tag
15
+ @content = _content
16
+ @klass = _klass
17
+ @data = _data
17
18
  end
18
19
 
19
20
  def render
20
- if @mode.div?
21
- MarkdownUI::StandardTag.new(@content, @klass, nil, @data).render
22
- elsif @mode.label?
23
- MarkdownUI::LabelTag.new(@content, @klass, nil, @data).render
24
- end
25
- end
21
+ @params = @tag.split
26
22
 
23
+ html { @elements[key].new(content, klass_text, _id, data).render } if content
24
+ end
27
25
  end
28
26
  end
@@ -0,0 +1,11 @@
1
+ module MarkdownUI
2
+ class HTMLFormatter
3
+ def initialize(text)
4
+ @doc = Nokogiri::XML(text, &:noblanks).to_xhtml(indent: 2)
5
+ end
6
+
7
+ def to_html
8
+ @doc
9
+ end
10
+ end
11
+ end