History

gnu_cobol: process review comments

Jasper van Merle committed 7 years ago

Commit 054fde31 parent e61f3f71 file · +26 −10Browse files

Unified · Split

lib/docs/filters/gnu_cobol/clean_html.rb+26−10
@@ -13,6 +13,9 @@ module Docs · 12 unmodified lines
13 at_css('p').remove13 at_css('p').remove
14 at_css('ol').remove14 at_css('ol').remove
15 15
16 # Remove horizontal lines
17 css('hr').remove
18
16 # Remove everything after Appendix B19 # Remove everything after Appendix B
17 # This includes the license text, the document changelog, the compiler changelog and the footnote20 # This includes the license text, the document changelog, the compiler changelog and the footnote
18 start_element = at_css('a[name="Appendix-C-_002d-GNU-Free-Documentation-License"]').previous_element21 start_element = at_css('a[name="Appendix-C-_002d-GNU-Free-Documentation-License"]').previous_element
@@ -25,27 +28,40 @@ module Docs · 6 unmodified lines
25 28
26 # Make headers bigger29 # Make headers bigger
27 css('h4').each {|node| node.name = 'h3'}30 css('h4').each {|node| node.name = 'h3'}
31 css('h3.unnumberedsec').each {|node| node.name = 'h2'}
28 32
29 # Remove the newlines33 # Remove the newlines
30 # All paragraphs are inside <p> tags already anyways34 # All paragraphs are inside <p> tags already anyways
31 css('br').remove35 css('br').remove
32 36
33 # The original document contains sub-headers surrounded by equal signs37 # The original document contains sub-headers surrounded by equal signs
34 # Convert that to actual header elements38 # Convert those to actual header elements
35 css('div[align="center"]').each do |node|39 css('div[align="center"]').each do |node|
36 if node.content.include?('=' * 50)40 if node.content.include?('=' * 50)
37 node.replace('<hr>')41 previous = node.previous_element
38 else42 if !previous.nil? && previous.name == 'div' && previous['align'] == 'center'
39 node.remove_attribute('align')43 previous.name = 'h4'
40 node.name = 'h4'44 end
45
46 node.remove
41 end47 end
42 end48 end
43 49
44 # Remove all hr's after h4's50 # Remove align="center" attributes
45 css('h4').each do |node|51 css('[align="center"]').remove_attribute('align')
46 next_element = node.next_element52
47 if !next_element.nil? && next_element.name == 'hr'53 # Convert tt tags into inline code blocks and remove any surrounding quotes
48 next_element.remove54 css('tt').each do |node|
55 node.name = 'code'
56
57 previous_node = node.previous
58 if !previous_node.nil? && previous_node.text?
59 previous_node.content = previous_node.content.sub(/([^"]?")\Z/, '')
60 end
61
62 next_node = node.next
63 if !next_node.nil? && next_node.text?
64 next_node.content = next_node.content.sub(/\A("[^"]?)/, '')
49 end65 end
50 end66 end
51 67

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t