Module: Iev::Utilities
- Included in:
- SourceParser, TermBuilder
- Defined in:
- lib/iev/utilities.rb
Constant Summary collapse
- IMAGE_PATH_PREFIX =
"image::/assets/images/parts"- IEV_CODE_RE =
/\A(IEV)?\s*(\d{2,3}-\d{2,3}-\d{2,3})\z/- SIMG_PATH_REGEX =
SIMG/Figure patterns — custom IEV XML, pre-processed before Nokogiri. Uses [^>] and [^<] instead of . to avoid polynomial backtracking.
/<simg [^>]*\/\$file\/([\d\-\w.]+)>/- FIGURE_ONE_REGEX =
'<p><b>\\s*Figure\\s+(\\d)\\s+[–-]\\s+([^<]+)\\s*<\\/b>(<\\/p>)?'- FIGURE_TWO_REGEX =
"#{FIGURE_ONE_REGEX}\\s*#{FIGURE_ONE_REGEX}".freeze
Instance Method Summary collapse
Instance Method Details
#parse_anchor_tag(text, term_domain) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/iev/utilities.rb', line 14 def parse_anchor_tag(text, term_domain) return nil if text.nil? text = process_simg_figures(text, term_domain) text = fix_unquoted_href(text) doc = Nokogiri::HTML::DocumentFragment.parse(text) nodes_to_adoc(doc.children, term_domain) end |
#replace_newlines(input) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/iev/utilities.rb', line 24 def replace_newlines(input) input .gsub('\n', "\n\n") .gsub(/<[pbr]+>/, "\n\n") .gsub(/<br\s*\/?>/, "\n\n") .gsub(/\s*\n[\n\s]+/, "\n\n") .strip end |