Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
e529f34b
Commit
e529f34b
authored
Jul 15, 2015
by
Randall Leeds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add clarifying comments
parent
23a681a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
html.coffee
h/static/scripts/annotator/anchoring/html.coffee
+3
-2
pdf.coffee
h/static/scripts/annotator/anchoring/pdf.coffee
+5
-1
No files found.
h/static/scripts/annotator/anchoring/html.coffee
View file @
e529f34b
...
...
@@ -22,7 +22,7 @@ querySelector = (type, root, selector, options) ->
###*
# Anchor a set of selectors.
#
# This function converts a set of selectors into a document range
using
.
# This function converts a set of selectors into a document range.
# It encapsulates the core anchoring algorithm, using the selectors alone or
# in combination to establish the best anchor within the document.
#
...
...
@@ -59,7 +59,8 @@ exports.anchor = (root, selectors, options = {}) ->
else
return
range
# Until we successfully anchor, we fail.
# From a default of failure, we build up catch clauses to try selectors in
# order, from simple to complex.
promise
=
Promise
.
reject
(
'unable to anchor'
)
if
fragment
?
...
...
h/static/scripts/annotator/anchoring/pdf.coffee
View file @
e529f34b
...
...
@@ -32,6 +32,10 @@ getPageTextContent = (pageIndex) ->
return
Promise
.
resolve
(
pageTextCache
[
pageIndex
])
else
joinItems
=
({
items
})
->
# Skip empty items since PDF-js leaves their text layer divs blank.
# Excluding them makes our measurements match the rendered text layer.
# Otherwise, the selectors we generate would not match this stored text.
# See the appendText method of TextLayerBuilder in pdf.js.
nonEmpty
=
(
item
.
str
for
item
in
items
when
/\S/
.
test
(
item
.
str
))
textContent
=
nonEmpty
.
join
(
''
)
pageTextCache
[
pageIndex
]
=
textContent
...
...
@@ -74,7 +78,7 @@ findPage = (offset) ->
###*
# Anchor a set of selectors.
#
# This function converts a set of selectors into a document range
using
.
# This function converts a set of selectors into a document range.
# It encapsulates the core anchoring algorithm, using the selectors alone or
# in combination to establish the best anchor within the document.
#
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment