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
1313 at_css('p').remove
1414 at_css('ol').remove
1515
16+ # Remove horizontal lines
17+ css('hr').remove
18+
1619 # Remove everything after Appendix B
1720 # This includes the license text, the document changelog, the compiler changelog and the footnote
1821 start_element = at_css('a[name="Appendix-C-_002d-GNU-Free-Documentation-License"]').previous_element
@@ -25,27 +28,40 @@ module Docs · 6 unmodified lines
2528
2629 # Make headers bigger
2730 css('h4').each {|node| node.name = 'h3'}
31+ css('h3.unnumberedsec').each {|node| node.name = 'h2'}
2832
2933 # Remove the newlines
3034 # All paragraphs are inside <p> tags already anyways
3135 css('br').remove
3236
3337 # The original document contains sub-headers surrounded by equal signs
34− # Convert that to actual header elements
38+ # Convert those to actual header elements
3539 css('div[align="center"]').each do |node|
3640 if node.content.include?('=' * 50)
37− node.replace('<hr>')
38− else
39− node.remove_attribute('align')
40− node.name = 'h4'
41+ previous = node.previous_element
42+ if !previous.nil? && previous.name == 'div' && previous['align'] == 'center'
43+ previous.name = 'h4'
44+ end
45+
46+ node.remove
4147 end
4248 end
4349
44− # Remove all hr's after h4's
45− css('h4').each do |node|
46− next_element = node.next_element
47− if !next_element.nil? && next_element.name == 'hr'
48− next_element.remove
50+ # Remove align="center" attributes
51+ css('[align="center"]').remove_attribute('align')
52+
53+ # Convert tt tags into inline code blocks and remove any surrounding quotes
54+ 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("[^"]?)/, '')
4965 end
5066 end
5167

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