Giter Club home page Giter Club logo

xpath-range's People

Contributors

aron avatar csillag avatar nickstenning avatar rufuspollock avatar tilgovi avatar weihanglo avatar wjt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xpath-range's Issues

Extend the README file

As explained by @aron:

For documentation I generally like the readme to have at least the following:

  • Introduction (what is this repo and why does it exist)
  • Usage (how do I install and use this in my project)
  • Development (steps to pulling down and getting started working on the repo)
  • Testing (how to setup and run the tests, and how to add more).
  • Maintainers (or point of contact, e.g. the mailing list)

The current version is missing out on most of the above.

Element boundaries

Right now the offsets are assumed to be text offsets.

The implementation could evaluate whether the container expression evaluates to a Text or Element and then treat the offset as appropriate.

jQuery and ES6 questions

Hi all,

I hope you're well :).

I was wondering if you would consider PRs with:

  • vanilla JS instead of jQuery, and
  • ES6/7 instead of coffee code.

Thanks :)

IE8: selection methods not available.

In IE8, things like document.createRange and window.getSelection don't exist. Per the discussion over on Annotator openannotation/annotator#412 (comment) we're suggesting users use the Rangy plugin to fill these gaps - but that doesn't polyfill window or document, it just provides a standard interface instead a la jQuery.

For instances like this and this I think it would make sense to test if rangy is being used and if not, default to the current methods. E.g.:

win = rangy ? Util.getGlobal()
sel = win.getSelection() # Get the browser selection object

Relates to openannotation/annotator#428

Finalize 1.0 API

  • Decide whether ignoreSelector belongs here. Is something simpler possible?
  • Decide whether to remove limit which doesn't seem to belong here.

Build not working.

It looks like /tools/build was designed for annotator and hasn't been modified since, maybe? Just running it without flags doesn't appear to build anything, and most of the flags I see listed just throw errors (e.g. using -p throws plugin is not defined).

toNode method cannot find node for xpath with / or : in attribute selector

The toNode method has a bug.

# Public: Finds an Element Node using an XPath relative to the document root.
#
# If the document is served as application/xhtml+xml it will try and resolve
# any namespaces within the XPath.
#
# path - An XPath String to query.
#
# Examples
#
#   node = toNode('/html/body/div/p[2]')
#   if node
#     # Do something with the node.
#
# Returns the Node if found otherwise null.
toNode = (path, root = document) ->

It will not find the node if the attribute selector has / or : in it. Example:
toNode("//p[@resource='http://purl.org/pearson/asset/adb19cb3a588ab58cbc0db272048aed6d60a29db5']") and toNode("//p[@resource='asset:adb4afbb2c91461765201bd8eb32f54aad1bb3800']") will not work. However toNode("//p[@resource='adb4afbb2c91461765201bd8eb32f54aad1bb3800']") works.

The problem is with the following code (line 161 in xpath.coffee):

      path = (for segment in path.split '/'
        if segment and segment.indexOf(':') == -1
          segment.replace(/^([a-z]+)/, 'xhtml:$1')
        else segment
      ).join('/')

This will convert the //p[@resource='http://purl.org/pearson/asset/adb19cb3a588ab58cbc0db272048aed6d60a29db5'] into
//xhtml:p[@resource='http://xhtml:purl.org/xhtml:pearson/xhtml:asset/xhtml:adb19cb3a588ab58cbc0db272048aed6d60a29db5'] instead of converting to //xhtml:p[@resource='http://purl.org/pearson/asset/adb19cb3a588ab58cbc0db272048aed6d60a29db5']

I have never worked on coffee script and it took me a while to find the coffee script... by that time I made a code change to the generated code to fix the issue I am facing... Here is the screenshot of diff (which may not be useful):
http://content.screencast.com/users/harinair/folders/Jing/media/fac08329-05bf-4b51-8bba-cea25913dc15/00000064.png

Test with an XML document

The test suite no longer tests XML since 03205bf made isXML a private utility of the xpath module.

A better option would be to run the entire test suite on an XML document.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.