Method: Dphil::TeiXML#crop
- Defined in:
- lib/dphil/tei_xml.rb
#crop(expr) ⇒ Object
Public: Return a portion of the document as a new document
expr - a CSS selector or XPath expression
Returns a new document.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dphil/tei_xml.rb', line 40 def crop(expr) segment = xml.search(expr) pb = page_of(segment) lb = line_of(segment) source = <<~EOS <TEI version="5.0" xmlns="http://www.tei-c.org/ns/1.0"> <pre>#{pb&.to_xml}#{lb&.to_xml}</pre> #{segment.to_xml} <post></post> </TEI> EOS self.class.new(source) end |