Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds input of style for background-color rgba alpha channel #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions jquery.highlight-within-textarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@
}
});
}
if (custom.style) {
ranges.forEach(function(range) {
// persist class name as a property of the array
if (range.style) {
range.style = custom.style + ' ' + range.style;
} else {
range.style = custom.style;
}
});
}
return ranges;
},

Expand All @@ -252,7 +262,8 @@
boundaries.push({
type: 'start',
index: range[0],
className: range.className
className: range.className,
style: range.style
});
boundaries.push({
type: 'stop',
Expand Down Expand Up @@ -304,9 +315,13 @@

// replace start tokens with opening <mark> tags with class name
input = input.replace(/\{\{hwt-mark-start\|(\d+)\}\}/g, function(match, submatch) {
var className = boundaries[+submatch].className;
if (className) {
return '<mark class="' + className + '">';
let attrs = []
var className = boundaries[+submatch].className;
if (className) attrs.push( 'class="' + className + '"');
var style = boundaries[+submatch].style;
if (style) attrs.push( 'style="' + style + '"');
if (attrs.length > 0) {
return '<mark '+ attrs.join(' ') +'>';
} else {
return '<mark>';
}
Expand Down