worte 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/lib/worte/filter/markdown.rb +6 -0
- data/lib/worte/version.rb +1 -1
- data/spec/markdown_filter_spec.rb +64 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ed4216e14fb2dd728c12b322d3807ba1d945dbd
|
4
|
+
data.tar.gz: 7e77062be7c5567f1874dcced979b079e420e61f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c8ec45a27f2b63c585fd5a7fe75f935ee893c86d19f343ab9f8faae3e4ceb36c15d94197fb91dec7c504e4a1cffc3f9dada9b210cbce2edb0d9fe365abd9ab7
|
7
|
+
data.tar.gz: f9d85a3b00813a0456d52a6cba18dfb056439b67f895428f11af937d5844917a6a710ba129075adf28fe75fbf0145aa3bf9ec86d8c0d22e08f9dca57cbaa7dc1
|
@@ -2,9 +2,15 @@ module Worte
|
|
2
2
|
module Filter
|
3
3
|
class Markdown
|
4
4
|
def filter(str)
|
5
|
+
str = str.gsub(/^---$\n.*?\n^---$/m) { |c| "\n" * c.split("\n").length }
|
6
|
+
str = str.gsub(/^```[a-z]*$\n.*?\n^```$/m) { |c| "\n" * (c.split("\n").length - 1) }
|
7
|
+
str = str.gsub(/^\t.*$/) { |c| '' }
|
5
8
|
str = str.gsub(/^([ \t]*[#]+)/) { |c| ' ' * c.length }
|
6
9
|
str = str.gsub(/\*\*(.*?)\*\*/) { |c| ' ' + c[2..-3] + ' ' }
|
7
10
|
str = str.gsub(/\*(.*?)\*/) { |c| ' ' + c[1..-2] + ' ' }
|
11
|
+
str = str.gsub(/\_\_(.*?)\_\_/) { |c| ' ' + c[2..-3] + ' ' }
|
12
|
+
str = str.gsub(/\_(.*?)\_/) { |c| ' ' + c[1..-2] + ' ' }
|
13
|
+
str = str.gsub(/`.*?`/) { |c| ' ' * c.length }
|
8
14
|
str = str.gsub(/[!]?\[.*\]\(.*\)/) { |c| ' ' * c.length }
|
9
15
|
end
|
10
16
|
end
|
data/lib/worte/version.rb
CHANGED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Worte::Filter::Markdown do
|
4
|
+
it "filters out star emphasis" do
|
5
|
+
f = Worte::Filter::Markdown.new
|
6
|
+
t = f.filter('Test *test* test')
|
7
|
+
expect(t).to eq('Test test test')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "filters out star bold" do
|
11
|
+
f = Worte::Filter::Markdown.new
|
12
|
+
t = f.filter('Test **test** test')
|
13
|
+
expect(t).to eq('Test test test')
|
14
|
+
end
|
15
|
+
|
16
|
+
it "filters out underline emphasis" do
|
17
|
+
f = Worte::Filter::Markdown.new
|
18
|
+
t = f.filter('Test _test_ test')
|
19
|
+
expect(t).to eq('Test test test')
|
20
|
+
end
|
21
|
+
|
22
|
+
it "filters out underline bold" do
|
23
|
+
f = Worte::Filter::Markdown.new
|
24
|
+
t = f.filter('Test __test__ test')
|
25
|
+
expect(t).to eq('Test test test')
|
26
|
+
end
|
27
|
+
|
28
|
+
it "filters heading marks" do
|
29
|
+
f = Worte::Filter::Markdown.new
|
30
|
+
t = f.filter('### Test')
|
31
|
+
expect(t).to eq(' Test')
|
32
|
+
end
|
33
|
+
|
34
|
+
it "filters out Jekyll property block" do
|
35
|
+
f = Worte::Filter::Markdown.new
|
36
|
+
t = f.filter(<<-EOF
|
37
|
+
---
|
38
|
+
title: Test test test
|
39
|
+
category: ---test
|
40
|
+
---
|
41
|
+
Hello, World
|
42
|
+
EOF
|
43
|
+
)
|
44
|
+
expect(t).to eq("\n\n\n\n\nHello, World\n")
|
45
|
+
end
|
46
|
+
|
47
|
+
it "filters out inline backticks" do
|
48
|
+
f = Worte::Filter::Markdown.new
|
49
|
+
t = f.filter("Test `test` Test")
|
50
|
+
expect(t).to eq("Test Test")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "filters out fenced code blocks" do
|
54
|
+
f = Worte::Filter::Markdown.new
|
55
|
+
t = f.filter("Test\n```ruby\nx = 1 + 2\nputs(x)\n```\nHello, World!")
|
56
|
+
expect(t).to eq("Test\n\n\n\n\nHello, World!")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "filters out indented pre blocks" do
|
60
|
+
f = Worte::Filter::Markdown.new
|
61
|
+
t = f.filter("Test\n\tThis\n\tis\n\ta pre block\nHello, World")
|
62
|
+
expect(t).to eq("Test\n\n\n\nHello, World")
|
63
|
+
end
|
64
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: worte
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Oberschweiber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi-aspell
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- lib/worte/version.rb
|
49
49
|
- lib/worte/worte.rb
|
50
50
|
- spec/colorized_printer_spec.rb
|
51
|
+
- spec/markdown_filter_spec.rb
|
51
52
|
- spec/simple_printer_spec.rb
|
52
53
|
- spec/spec_helper.rb
|
53
54
|
- spec/tokenizer_spec.rb
|
@@ -79,6 +80,7 @@ specification_version: 4
|
|
79
80
|
summary: Simple spell checker based on ffi-aspell
|
80
81
|
test_files:
|
81
82
|
- spec/colorized_printer_spec.rb
|
83
|
+
- spec/markdown_filter_spec.rb
|
82
84
|
- spec/simple_printer_spec.rb
|
83
85
|
- spec/spec_helper.rb
|
84
86
|
- spec/tokenizer_spec.rb
|