gnu_cobol: process review comments

pull/928/head
Jasper van Merle 6 years ago
parent e61f3f7202
commit 054fde3303

@ -13,6 +13,9 @@ module Docs
at_css('p').remove at_css('p').remove
at_css('ol').remove at_css('ol').remove
# Remove horizontal lines
css('hr').remove
# Remove everything after Appendix B # Remove everything after Appendix B
# This includes the license text, the document changelog, the compiler changelog and the footnote # This includes the license text, the document changelog, the compiler changelog and the footnote
start_element = at_css('a[name="Appendix-C-_002d-GNU-Free-Documentation-License"]').previous_element start_element = at_css('a[name="Appendix-C-_002d-GNU-Free-Documentation-License"]').previous_element
@ -25,27 +28,40 @@ module Docs
# Make headers bigger # Make headers bigger
css('h4').each {|node| node.name = 'h3'} css('h4').each {|node| node.name = 'h3'}
css('h3.unnumberedsec').each {|node| node.name = 'h2'}
# Remove the newlines # Remove the newlines
# All paragraphs are inside <p> tags already anyways # All paragraphs are inside <p> tags already anyways
css('br').remove css('br').remove
# The original document contains sub-headers surrounded by equal signs # The original document contains sub-headers surrounded by equal signs
# Convert that to actual header elements # Convert those to actual header elements
css('div[align="center"]').each do |node| css('div[align="center"]').each do |node|
if node.content.include?('=' * 50) if node.content.include?('=' * 50)
node.replace('<hr>') previous = node.previous_element
else if !previous.nil? && previous.name == 'div' && previous['align'] == 'center'
node.remove_attribute('align') previous.name = 'h4'
node.name = 'h4' end
node.remove
end end
end end
# Remove all hr's after h4's # Remove align="center" attributes
css('h4').each do |node| css('[align="center"]').remove_attribute('align')
next_element = node.next_element
if !next_element.nil? && next_element.name == 'hr' # Convert tt tags into inline code blocks and remove any surrounding quotes
next_element.remove css('tt').each do |node|
node.name = 'code'
previous_node = node.previous
if !previous_node.nil? && previous_node.text?
previous_node.content = previous_node.content.sub(/([^"]?")\Z/, '')
end
next_node = node.next
if !next_node.nil? && next_node.text?
next_node.content = next_node.content.sub(/\A("[^"]?)/, '')
end end
end end

Loading…
Cancel
Save