nora_mark 0.2beta16 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/FUNDING.yml +3 -0
- data/.github/dependabot.yml +8 -0
- data/.github/workflows/test.yml +19 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +3 -0
- data/.travis.yml +2 -2
- data/CHANGELOG.md +5 -0
- data/Gemfile +0 -1
- data/README.md +1 -2
- data/Rakefile +1 -4
- data/lib/nora_mark/document.rb +14 -14
- data/lib/nora_mark/extensions.rb +6 -6
- data/lib/nora_mark/html/abstract_node_writer.rb +2 -1
- data/lib/nora_mark/html/context.rb +18 -16
- data/lib/nora_mark/html/default_transformer.rb +41 -38
- data/lib/nora_mark/html/frontmatter_writer.rb +2 -2
- data/lib/nora_mark/html/generator.rb +22 -22
- data/lib/nora_mark/html/pages.rb +13 -14
- data/lib/nora_mark/html/paragraph_writer.rb +24 -26
- data/lib/nora_mark/html/raw_text_block_writer.rb +13 -0
- data/lib/nora_mark/html/tag_writer.rb +14 -13
- data/lib/nora_mark/html/util.rb +5 -5
- data/lib/nora_mark/node.rb +46 -56
- data/lib/nora_mark/node_set.rb +1 -1
- data/lib/nora_mark/node_util.rb +7 -8
- data/lib/nora_mark/parser.kpeg.rb +16 -16
- data/lib/nora_mark/parser.rb +1 -3
- data/lib/nora_mark/rake_task.rb +23 -23
- data/lib/nora_mark/transformer.rb +13 -15
- data/lib/nora_mark/version.rb +1 -1
- data/lib/nora_mark.rb +0 -4
- data/lib/tilt/nora_mark.rb +1 -1
- data/nora_mark.gemspec +7 -6
- data/spec/extensions_spec.rb +1 -2
- data/spec/fixtures/test-plugins/nora_mark_tester.rb +3 -1
- data/spec/node_spec.rb +69 -49
- data/spec/nokogiri_test_helper.rb +9 -7
- data/spec/nora_mark_spec.rb +467 -491
- data/spec/spec_helper.rb +2 -6
- data/spec/tilt_spec.rb +1 -1
- data/spec/transformer_spec.rb +16 -18
- metadata +39 -29
@@ -3,18 +3,18 @@ module Nokogiri
|
|
3
3
|
class Element
|
4
4
|
def selector remove_id: true
|
5
5
|
sel = name
|
6
|
-
if !remove_id && !self['id'].nil?
|
6
|
+
if !remove_id && !self['id'].nil?
|
7
7
|
sel = sel + '#' + self['id'].split(' ').join('#')
|
8
8
|
end
|
9
9
|
if !self['class'].nil?
|
10
10
|
sel = sel + '.' + self['class'].split(' ').join('.')
|
11
11
|
end
|
12
|
-
attributes.select{|k,
|
13
|
-
|name, value|
|
12
|
+
attributes.select { |k, _v| k != 'class' && k != 'id' }.each { |name, value|
|
14
13
|
sel = sel + "[#{name}='#{value}']"
|
15
14
|
}
|
16
15
|
sel
|
17
16
|
end
|
17
|
+
|
18
18
|
def selector_and_text remove_id: true
|
19
19
|
[selector(remove_id: remove_id), text]
|
20
20
|
end
|
@@ -22,18 +22,20 @@ module Nokogiri
|
|
22
22
|
def child_loop
|
23
23
|
yield self
|
24
24
|
end
|
25
|
+
|
25
26
|
def child_a(index)
|
26
27
|
element_children[index].selector_and_text
|
27
|
-
end
|
28
|
+
end
|
29
|
+
|
28
30
|
def selector_and_children remove_id: true
|
29
|
-
[selector(remove_id: remove_id)] + children.select{|c| c.elem? || c.text.strip.size > 0}.map{|c|
|
30
|
-
if !c.elem?
|
31
|
+
[selector(remove_id: remove_id)] + children.select { |c| c.elem? || c.text.strip.size > 0 }.map { |c|
|
32
|
+
if !c.elem?
|
31
33
|
c.text
|
32
34
|
elsif c.element_children.size == 0
|
33
35
|
c.selector_and_text remove_id: remove_id
|
34
36
|
else
|
35
37
|
c.selector_and_children remove_id: remove_id
|
36
|
-
end
|
38
|
+
end
|
37
39
|
}
|
38
40
|
end
|
39
41
|
end
|