Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Describe and resolve DOM Range objects using XPath

License

NotificationsYou must be signed in to change notification settings

openannotation/xpath-range

Repository files navigation

Build StatusNPM PackageCoverage

This module is for describing and resolving a DOMRange using XPath.

Installation

Using npm:

npm install xpath-range

Usage

The module provides functions for converting to and from DOM Range objectsusing a combination of XPath expressions and text offsets.

The presence of a working XPath evaluator is not strictly required. Without it,the library will only support XPath expressions that use a child axis andnode names with number literal positions. All XPath expressions generated bythis library fit this description. For instance, the library can generate andconsume an expression like/html/body/article/p[3].

API

fromRange(range, [root])

Convert aRange to a pair of XPath expressions and offsets.

If the optional parameterroot is supplied, the computed XPath expressionswill be relative to it.

Returns an object with the following properties:

  • start
  • startOffset
  • end
  • endOffset

toRange(start, startOffset, end, endOffset, [root])

Construct aRange from the given XPath expressions and offsets.

If the optional parameterroot is supplied, the XPath expressions areevaluated as relative to it.

Returns aRange object.

Compatibility

This library should work with any browser implementing basicRange support.

Internet Explorer version 8

  • Basic support can be achieved with therangy shim.
  • There is no support for namespaces in X(HT)ML documents (issue #17).

Community

Originally, this code was part of theAnnotator project.

Any discussion should happen on theannotator-dev mailinglist.

Development

To contribute, fork this repository and send a pull request with your changes,including any necessary test and documentation updates.

Testing

You can run the command-line test suite by executingnpm test.

To run the test suite, install the karma test runner with the commandnpm install -g karma-cli and then runkarma start. Karma will printinstructions for debugging the tests in a browser.

About

Describe and resolve DOM Range objects using XPath

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors8


[8]ページ先頭

©2009-2025 Movatter.jp