html-pipeline-auto-correct 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 75c1f48846f86c2153cd7b78bd456f0ec3e6ee829a8a3762d1d44155d1762c57
4
+ data.tar.gz: 04fe1fa5d97f6872da0b71e8334ec45a199f554fd74dbfad5ad747d94bf9addc
5
+ SHA512:
6
+ metadata.gz: 5a74e43cf5aa994b7f4a3c6c9d5b5e7772e19ac49c953dfbe5a65275064e7a6e57532f074affe98925b4ce40426c0afd5a69923425591c62434ab3a73c21e044
7
+ data.tar.gz: 14018bbcc438de58091b12c40aae7d025566455c8ff0b5514eb0c6e86aabf88d13076563744d83606397000f59d1e024372c15262435778a1ef666d6509f1acd
@@ -0,0 +1,32 @@
1
+ # html-pipeline-auto-correct
2
+
3
+ [auto-correct](https://github.com/huacnlee/auto-correct) plugin for [html-pipeline](https://github.com/jch/html-pipeline).
4
+
5
+
6
+ [![Gem Version](https://badge.fury.io/rb/html-pipeline-auto-correct.svg)](https://rubygems.org/gems/html-pipeline-auto-correct) [![Build
7
+ Status](https://api.travis-ci.org/huacnlee/html-pipeline-auto-correct.svg?branch=master&.svg)](http://travis-ci.org/huacnlee/html-pipeline-auto-correct)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application’s Gemfile:
12
+
13
+ ```rb
14
+ gem "html-pipeline"
15
+ gem "html-pipeline-auto-correct"
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ You can add `HTML::Pipeline::AutoCorrectFilter` into your pipeline like this:
21
+
22
+ ```rb
23
+ pipeline = HTML::Pipeline.new [
24
+ HTML::Pipeline::MarkdownFilter,
25
+ HTML::Pipeline::AutoCorrectFilter,
26
+ ]
27
+ result = pipeline.call(text)
28
+ ```
29
+
30
+ ## License
31
+
32
+ The gem is available as open source under the terms of the MIT License.
@@ -0,0 +1 @@
1
+ require "html/pipeline/auto_correct_filter"
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ require "auto-correct"
3
+
4
+ module HTML
5
+ class Pipeline
6
+ class AutoCorrectFilter < HTML::Pipeline::Filter
7
+ def call
8
+ doc.xpath(".//text()").each do |node|
9
+ content = node.to_html
10
+ next if has_ancestor?(node, %w[pre code])
11
+
12
+ html = ::AutoCorrect.format(content)
13
+
14
+ next if html == content
15
+ node.replace(html)
16
+ end
17
+ doc
18
+ end
19
+ end
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: html-pipeline-auto-correct
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jason Lee
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-01-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: html-pipeline
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: auto-correct
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.0
41
+ description: AutoCorrect for html-pipeline
42
+ email:
43
+ - huacnlee@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - README.md
49
+ - lib/html-pipeline-auto-correct.rb
50
+ - lib/html/pipeline/auto_correct_filter.rb
51
+ homepage: https://github.com/huacnlee/html-pipeline-auto-correct
52
+ licenses: []
53
+ metadata: {}
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubygems_version: 3.0.3
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: AutoCorrect for html-pipeline
73
+ test_files: []