SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
e80bea52
Commit
e80bea52
authored
7 years ago
by
Jorran de Wit
Browse files
Options
Downloads
Patches
Plain Diff
Unwanted file added
parent
505f74a4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scipost/static/scipost/assets/js/highlight.js
+0
-108
0 additions, 108 deletions
scipost/static/scipost/assets/js/highlight.js
with
0 additions
and
108 deletions
scipost/static/scipost/assets/js/highlight.js
deleted
100644 → 0
+
0
−
108
View file @
505f74a4
/*
* jQuery Highlight plugin
*
* Based on highlight v3 by Johann Burkard
* http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html
*
* Code a little bit refactored and cleaned (in my humble opinion).
* Most important changes:
* - has an option to highlight only entire words (wordsOnly - false by default),
* - has an option to be case sensitive (caseSensitive - false by default)
* - highlight element tag and class names can be specified in options
*
* Usage:
* // wrap every occurrance of text 'lorem' in content
* // with <span class='highlight'> (default options)
* $('#content').highlight('lorem');
*
* // search for and highlight more terms at once
* // so you can save some time on traversing DOM
* $('#content').highlight(['lorem', 'ipsum']);
* $('#content').highlight('lorem ipsum');
*
* // search only for entire word 'lorem'
* $('#content').highlight('lorem', { wordsOnly: true });
*
* // don't ignore case during search of term 'lorem'
* $('#content').highlight('lorem', { caseSensitive: true });
*
* // wrap every occurrance of term 'ipsum' in content
* // with <em class='important'>
* $('#content').highlight('ipsum', { element: 'em', className: 'important' });
*
* // remove default highlight
* $('#content').unhighlight();
*
* // remove custom highlight
* $('#content').unhighlight({ element: 'em', className: 'important' });
*
*
* Copyright (c) 2009 Bartek Szopka
*
* Licensed under MIT license.
*
*/
jQuery
.
extend
({
highlight
:
function
(
node
,
re
,
nodeName
,
className
)
{
if
(
node
.
nodeType
===
3
)
{
var
match
=
node
.
data
.
match
(
re
);
if
(
match
)
{
var
highlight
=
document
.
createElement
(
nodeName
||
'
span
'
);
highlight
.
className
=
className
||
'
highlight
'
;
var
wordNode
=
node
.
splitText
(
match
.
index
);
wordNode
.
splitText
(
match
[
0
].
length
);
var
wordClone
=
wordNode
.
cloneNode
(
true
);
highlight
.
appendChild
(
wordClone
);
wordNode
.
parentNode
.
replaceChild
(
highlight
,
wordNode
);
return
1
;
//skip added node in parent
}
}
else
if
((
node
.
nodeType
===
1
&&
node
.
childNodes
)
&&
// only element nodes that have children
!
/
(
script|style
)
/i
.
test
(
node
.
tagName
)
&&
// ignore script and style nodes
!
(
node
.
tagName
===
nodeName
.
toUpperCase
()
&&
node
.
className
===
className
))
{
// skip if already highlighted
for
(
var
i
=
0
;
i
<
node
.
childNodes
.
length
;
i
++
)
{
i
+=
jQuery
.
highlight
(
node
.
childNodes
[
i
],
re
,
nodeName
,
className
);
}
}
return
0
;
}
});
jQuery
.
fn
.
unhighlight
=
function
(
options
)
{
var
settings
=
{
className
:
'
highlight
'
,
element
:
'
span
'
};
jQuery
.
extend
(
settings
,
options
);
return
this
.
find
(
settings
.
element
+
"
.
"
+
settings
.
className
).
each
(
function
()
{
var
parent
=
this
.
parentNode
;
parent
.
replaceChild
(
this
.
firstChild
,
this
);
parent
.
normalize
();
}).
end
();
};
jQuery
.
fn
.
highlight
=
function
(
words
,
options
)
{
var
settings
=
{
className
:
'
highlight
'
,
element
:
'
span
'
,
caseSensitive
:
false
,
wordsOnly
:
false
};
jQuery
.
extend
(
settings
,
options
);
if
(
words
.
constructor
===
String
)
{
words
=
[
words
];
}
words
=
jQuery
.
grep
(
words
,
function
(
word
,
i
){
return
word
!=
''
;
});
words
=
jQuery
.
map
(
words
,
function
(
word
,
i
)
{
return
word
.
replace
(
/
[
-[
\]
{}()*+?.,
\\
^$|#
\s]
/g
,
"
\\
$&
"
);
});
if
(
words
.
length
==
0
)
{
return
this
;
};
var
flag
=
settings
.
caseSensitive
?
""
:
"
i
"
;
var
pattern
=
"
(
"
+
words
.
join
(
"
|
"
)
+
"
)
"
;
if
(
settings
.
wordsOnly
)
{
pattern
=
"
\\
b
"
+
pattern
+
"
\\
b
"
;
}
var
re
=
new
RegExp
(
pattern
,
flag
);
// var self = this
return
this
.
each
(
function
()
{
return
jQuery
.
highlight
(
this
,
re
,
settings
.
element
,
settings
.
className
);
});
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment