0.1.4 • Published 8 years ago
hocr-dom v0.1.4
hocr-dom
- API
HocrDOM
HocrDOM.isHocrElement(context, options, cache)HocrDOM.getHocrProperties(context, options, cache)HocrDOM.queryHocr(context, query, options)HocrDOM.queryHocrAll(context, query, options)HocrDOM.extendPrototypes({Element, Document}, options)el.queryHocr(query, options)el.queryHocrAll(query, options)el.isHocrElementel.hocrPropertyParsernew HocrPropertyParser(opts)*parse(str)
API
HocrDOM
HocrDOM.isHocrElement(context, options, cache)
true if this has an ocr_* class, false otherwise
@param {Document|Element}context Context element@param {Object}options See Options@param {Object}cache If provided, will cache the properties in this object with key_hocr
HocrDOM.getHocrProperties(context, options, cache)
List the properties of this hOCR element as an object
@param {Document|Element}context Context element@param {Object}options See Options@param {Object}cache If provided, will cache the properties in this object with key_hocr
HocrDOM.queryHocr(context, query, options)
Find the first hOCR element matching query
See queryHocrAll for options
HocrDOM.queryHocrAll(context, query, options)
@param {Document|Element}context Context element@param {String|Object}query Object of query parameters. If a string -> query.class@param {String} query.tagtag names to look for. Default '*'@param {String} query.titletitleattribute must contain this string@param {String} query.clausesString of clauses for querySelector@param {String|Array}class Elements with this class (if string) or any of these classes (if array)@param {String} query.contextcontext element to query below. Otherwise root element of DOM.@param {String} query.terminalReturn only hocr-elements containing no hocr-elements themselves@param {String} query.nonTerminalOpposite ofterminal@param {String} query.filterArbitrary filter to prune resulting element set
HocrDOM.extendPrototypes({Element, Document}, options)
Extend the prototypes of Element and Document with hOCR-specific
methods and properties.
el.queryHocr(query, options)
Same as HocrDOM.queryHocr but with context set to el
el.queryHocrAll(query, options)
Same as HocrDOM.queryHocrAll but with context set to el
el.isHocrElement
Property containing whether this is an hOCR element
el.hocr
Property containing the hOCR properties
PropertyParser
new HocrPropertyParser(opts)
@param {Object} optsAll options arefalseby default@param {Object} opts.debugWhether to log debug output@param {Object} opts.allowUnknownWhether to silently ignore properties not in the spec@param {Object} opts.allowInvalidNumbersWhether to silently ignore invalid number (wrong type e.g.)@param {Object} opts.disableCardinalityChecksWhether to silently ignore invalid argument cardinality
parse(str)
Tokenize and Parse the hOCR properties in a title string