kramdown-metadata-parsers 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dfbcd236202b415d4e114eeb06ae1a097bcaf47d
4
+ data.tar.gz: 6d8158fdc5b62d9c54e194ee834b0178a3eb08b2
5
+ SHA512:
6
+ metadata.gz: 6d0f72f39cd2741d6183d8093d3b493de3e007cfb561a5b7bd189246bbbe680edb8f23a466638bc55620d0b843db2610ef21969badf57fc2e6dbf065a727ca06
7
+ data.tar.gz: 7d04ce25f809a9bdedbb5a638eaaab6c0dfe6537b254a21f2c11cc625c8e7b73706b0a0ea6bc2bf21e9775a1ac2f32fc2af6f00d3f0107474e498df6c7b55676
@@ -0,0 +1,22 @@
1
+ # Kramdown Metadata Parsers
2
+
3
+ Kramdown extension for parsing Markdown with a YAML preamble, for example
4
+
5
+ ``` md
6
+ ---
7
+ title: Now With Fresh Metadata
8
+ date: 2014-10-11
9
+ ---
10
+
11
+ ## Good stuff
12
+
13
+ *right*?
14
+ ```
15
+
16
+ Adds four new parsers, analogous with the ones included with Kramdown: `MetadataKramdown`, `MetadataMarkdown`, `MetadataGFM`, `MetadataHTML`. Use as you would use built-in formats, just make sure this gem is in your load path (i.e. add it to your Gemfile)
17
+
18
+ ``` ruby
19
+ doc = Kramdown::Document.new(markdown, input: 'MetadataKramdown')
20
+ doc.root.metadata # => {:title => 'Now With Fresh Metadata', :date => '2014-10-11'}
21
+ doc.to_html
22
+ ```
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = 'kramdown-metadata-parsers'
5
+ gem.version = "0.9.0"
6
+ gem.authors = [ 'Arne Brasseur' ]
7
+ gem.email = [ 'arne@arnebrasseur.net' ]
8
+ gem.description = 'Parse Markdown/Kramdown with YAML metadata'
9
+ gem.summary = gem.description
10
+ gem.homepage = 'https://github.com/plexus/kramdown-metadata-parsers'
11
+ gem.license = 'MIT'
12
+
13
+ gem.require_paths = %w[lib]
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.test_files = `git ls-files -- spec`.split($/)
16
+ gem.extra_rdoc_files = %w[README.md]
17
+
18
+ gem.add_runtime_dependency 'kramdown', '>= 1.4'
19
+ end
@@ -0,0 +1,23 @@
1
+ require 'delegate'
2
+ require 'yaml'
3
+
4
+ require 'kramdown'
5
+
6
+ module KramdownMetadataParsers
7
+ class MetadataElement < DelegateClass(::Kramdown::Element)
8
+ attr_accessor :metadata
9
+ end
10
+
11
+ module MetadataParser
12
+ def initialize(source, options)
13
+ if source =~ /\A---/
14
+ preamble = source[/\A---.*?^---/m]
15
+ source = source[preamble.size..-1]
16
+ metadata = YAML.load(preamble)
17
+ end
18
+ super(source, options)
19
+ @root = MetadataElement.new(@root)
20
+ @root.metadata = metadata || {}
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ require 'kramdown-metadata-parsers'
2
+ require 'kramdown/parser/gfm'
3
+
4
+ module Kramdown
5
+ module Parser
6
+ class MetadataGFM < GFM
7
+ include KramdownMetadataParsers::MetadataParser
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require 'kramdown-metadata-parsers'
2
+ require 'kramdown/parser/html'
3
+
4
+ module Kramdown
5
+ module Parser
6
+ class MetadataHTML < HTML
7
+ include KramdownMetadataParsers::MetadataParser
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require 'kramdown-metadata-parsers'
2
+ require 'kramdown/parser/kramdown'
3
+
4
+ module Kramdown
5
+ module Parser
6
+ class MetadataKramdown < Kramdown
7
+ include KramdownMetadataParsers::MetadataParser
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require 'kramdown-metadata-parsers'
2
+ require 'kramdown/parser/markdown'
3
+
4
+ module Kramdown
5
+ module Parser
6
+ class MetadataMarkdown < Markdown
7
+ include KramdownMetadataParsers::MetadataParser
8
+ end
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kramdown-metadata-parsers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Arne Brasseur
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: kramdown
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.4'
27
+ description: Parse Markdown/Kramdown with YAML metadata
28
+ email:
29
+ - arne@arnebrasseur.net
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files:
33
+ - README.md
34
+ files:
35
+ - README.md
36
+ - kramdown-metadata-parsers.gemspec
37
+ - lib/kramdown-metadata-parsers.rb
38
+ - lib/kramdown/parser/metadata_gfm.rb
39
+ - lib/kramdown/parser/metadata_html.rb
40
+ - lib/kramdown/parser/metadata_kramdown.rb
41
+ - lib/kramdown/parser/metadata_markdown.rb
42
+ homepage: https://github.com/plexus/kramdown-metadata-parsers
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 2.4.2
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Parse Markdown/Kramdown with YAML metadata
66
+ test_files: []