himekami-markdown 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +57 -0
- data/README.md +1 -5
- data/himekami-markdown.gemspec +1 -0
- data/lib/himekami/markdown.rb +3 -0
- data/lib/himekami/markdown/base_processor.rb +27 -0
- data/lib/himekami/markdown/filters/outline.rb +24 -0
- data/lib/himekami/markdown/outline_processor.rb +20 -0
- data/lib/himekami/markdown/processor.rb +1 -13
- data/lib/himekami/markdown/version.rb +1 -1
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4e76879ce81b43377888c7d2446b6c49381b9f7
|
4
|
+
data.tar.gz: 7ba3eb8c52d5713dd40f299547a5a103aaa6b776
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcf805355b1ea91fcae5148f4250115eb37f0d9a526bfd30116f229759e94726672683fb52f27497eda71320e30c8c6a23262d116160b96664ce55d9b949d55c
|
7
|
+
data.tar.gz: 2e1f8f02d7ba1128ecf78da20b45f38368f359239050253294e2dd6a28a4dca5512f09a71629b866c7fe7d2a7ec5dac4edca169a9b290fb1433ebe75d98d25a3
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Ruby CircleCI 2.0 configuration file
|
2
|
+
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
3
|
+
#
|
4
|
+
version: 2
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
docker:
|
8
|
+
# specify the version you desire here
|
9
|
+
- image: ruby:2.4.1
|
10
|
+
|
11
|
+
# Specify service dependencies here if necessary
|
12
|
+
# CircleCI maintains a library of pre-built images
|
13
|
+
# documented at https://circleci.com/docs/2.0/circleci-images/
|
14
|
+
# - image: circleci/postgres:9.4
|
15
|
+
|
16
|
+
working_directory: src
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- checkout
|
20
|
+
- run:
|
21
|
+
name: Install System Dependencies
|
22
|
+
command: apt-get update -qq && apt-get install -y build-essential libpq-dev libicu-dev cmake
|
23
|
+
|
24
|
+
# Download and cache dependencies
|
25
|
+
- restore_cache:
|
26
|
+
keys:
|
27
|
+
- v1-dependencies-{{ checksum "himekami-markdown.gemspec" }}
|
28
|
+
# fallback to using the latest cache if no exact match is found
|
29
|
+
- v1-dependencies-
|
30
|
+
|
31
|
+
- run:
|
32
|
+
name: install dependencies
|
33
|
+
command: |
|
34
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
35
|
+
|
36
|
+
- save_cache:
|
37
|
+
paths:
|
38
|
+
- vendor/bundle/
|
39
|
+
key: v1-dependencies-{{ checksum "himekami-markdown.gemspec" }}
|
40
|
+
|
41
|
+
# run tests!
|
42
|
+
- run:
|
43
|
+
name: run tests
|
44
|
+
command: |
|
45
|
+
mkdir /tmp/test-results
|
46
|
+
|
47
|
+
bundle exec rspec --format progress \
|
48
|
+
--format RspecJunitFormatter \
|
49
|
+
--out /tmp/test-results/rspec.xml \
|
50
|
+
--format progress
|
51
|
+
|
52
|
+
# collect reports
|
53
|
+
- store_test_results:
|
54
|
+
path: /tmp/test-results
|
55
|
+
- store_artifacts:
|
56
|
+
path: /tmp/test-results
|
57
|
+
destination: test-results
|
data/README.md
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/himekami/markdown`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
1
|
+
# Custamable Markdown Parser [![Gem Version](https://badge.fury.io/rb/himekami-markdown.svg)](https://badge.fury.io/rb/himekami-markdown) [![CircleCI](https://circleci.com/gh/otukutun/himekami-markdown/tree/master.svg?style=svg)](https://circleci.com/gh/otukutun/himekami-markdown/tree/master)
|
6
2
|
|
7
3
|
## Installation
|
8
4
|
|
data/himekami-markdown.gemspec
CHANGED
@@ -28,5 +28,6 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_dependency 'github-linguist', '~> 5.0'
|
29
29
|
spec.add_development_dependency "rake", "~> 10.0"
|
30
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
+
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.3.0'
|
31
32
|
spec.add_development_dependency 'pry', '~> 0'
|
32
33
|
end
|
data/lib/himekami/markdown.rb
CHANGED
@@ -4,5 +4,8 @@ require "commonmarker"
|
|
4
4
|
require "linguist"
|
5
5
|
|
6
6
|
require "himekami/markdown/version"
|
7
|
+
require "himekami/markdown/base_processor"
|
7
8
|
require "himekami/markdown/processor"
|
9
|
+
require "himekami/markdown/outline_processor"
|
8
10
|
require "himekami/markdown/filters/checkbox"
|
11
|
+
require "himekami/markdown/filters/outline"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Himekami
|
2
|
+
module Markdown
|
3
|
+
class BaseProcessor
|
4
|
+
class << self
|
5
|
+
def default_context
|
6
|
+
raise NotImplementedError
|
7
|
+
end
|
8
|
+
|
9
|
+
def default_filters
|
10
|
+
raise NotImplementedError
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(context = {})
|
15
|
+
@context = self.class.default_context.merge(context)
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(input, context = {})
|
19
|
+
HTML::Pipeline.new(filters, @context).call(input, context)
|
20
|
+
end
|
21
|
+
|
22
|
+
def filters
|
23
|
+
@filters ||= self.class.default_filters
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Himekami
|
2
|
+
module Markdown
|
3
|
+
module Filters
|
4
|
+
class Outline < HTML::Pipeline::Filter
|
5
|
+
HEADING_LEVELS = %w(h1).freeze
|
6
|
+
|
7
|
+
def call
|
8
|
+
doc.children.each do |node|
|
9
|
+
next if node.is_a?(Nokogiri::XML::Element) && HEADING_LEVELS.include?(node.name)
|
10
|
+
node.remove
|
11
|
+
end
|
12
|
+
|
13
|
+
doc.children.each do |node|
|
14
|
+
br = Nokogiri::XML::Text.new "\n", @doc
|
15
|
+
node.add_next_sibling(br)
|
16
|
+
end
|
17
|
+
|
18
|
+
doc
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Himekami
|
2
|
+
module Markdown
|
3
|
+
class OutlineProcessor < BaseProcessor
|
4
|
+
class << self
|
5
|
+
def default_context
|
6
|
+
{
|
7
|
+
asset_root: "/images"
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
def default_filters
|
12
|
+
[
|
13
|
+
HTML::Pipeline::MarkdownFilter,
|
14
|
+
Filters::Outline,
|
15
|
+
]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Himekami
|
2
2
|
module Markdown
|
3
|
-
class Processor
|
3
|
+
class Processor < BaseProcessor
|
4
4
|
class << self
|
5
5
|
def default_context
|
6
6
|
{
|
@@ -16,18 +16,6 @@ module Himekami
|
|
16
16
|
]
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
20
|
-
def initialize(context = {})
|
21
|
-
@context = self.class.default_context.merge(context)
|
22
|
-
end
|
23
|
-
|
24
|
-
def call(input, context = {})
|
25
|
-
HTML::Pipeline.new(filters, @context).call(input, context)
|
26
|
-
end
|
27
|
-
|
28
|
-
def filters
|
29
|
-
@filters ||= self.class.default_filters
|
30
|
-
end
|
31
19
|
end
|
32
20
|
end
|
33
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: himekami-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- otukutun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec_junit_formatter
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.3.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.3.0
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: pry
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,6 +143,7 @@ executables: []
|
|
129
143
|
extensions: []
|
130
144
|
extra_rdoc_files: []
|
131
145
|
files:
|
146
|
+
- ".circleci/config.yml"
|
132
147
|
- ".gitignore"
|
133
148
|
- ".rspec"
|
134
149
|
- ".travis.yml"
|
@@ -141,7 +156,10 @@ files:
|
|
141
156
|
- bin/setup
|
142
157
|
- himekami-markdown.gemspec
|
143
158
|
- lib/himekami/markdown.rb
|
159
|
+
- lib/himekami/markdown/base_processor.rb
|
144
160
|
- lib/himekami/markdown/filters/checkbox.rb
|
161
|
+
- lib/himekami/markdown/filters/outline.rb
|
162
|
+
- lib/himekami/markdown/outline_processor.rb
|
145
163
|
- lib/himekami/markdown/processor.rb
|
146
164
|
- lib/himekami/markdown/version.rb
|
147
165
|
homepage: https://github.com/otukutun/himekami-markdown
|