Unified · Split
| @@ -13,6 +13,9 @@ module Docs · 12 unmodified lines | |||
| 13 | at_css('p').remove | 13 | at_css('p').remove |
| 14 | at_css('ol').remove | 14 | at_css('ol').remove |
| 15 | 15 | ||
| 16 | # Remove horizontal lines | ||
| 17 | css('hr').remove | ||
| 18 | |||
| 16 | # Remove everything after Appendix B | 19 | # Remove everything after Appendix B |
| 17 | # This includes the license text, the document changelog, the compiler changelog and the footnote | 20 | # 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_element | 21 | 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 bigger | 29 | # 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 newlines | 33 | # Remove the newlines |
| 30 | # All paragraphs are inside <p> tags already anyways | 34 | # All paragraphs are inside <p> tags already anyways |
| 31 | css('br').remove | 35 | css('br').remove |
| 32 | 36 | ||
| 33 | # The original document contains sub-headers surrounded by equal signs | 37 | # The original document contains sub-headers surrounded by equal signs |
| 34 | # Convert that to actual header elements | 38 | # 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 | else | 42 | 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 | end | 47 | end |
| 42 | end | 48 | end |
| 43 | 49 | ||
| 44 | # Remove all hr's after h4's | 50 | # Remove align="center" attributes |
| 45 | css('h4').each do |node| | 51 | css('[align="center"]').remove_attribute('align') |
| 46 | next_element = node.next_element | 52 | |
| 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.remove | 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("[^"]?)/, '') | ||
| 49 | end | 65 | end |
| 50 | end | 66 | end |
| 51 | 67 | ||