repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
emmetio/emmet | lib/editTree/css.js | extractPropertiesFromSource | function extractPropertiesFromSource(source, offset) {
offset = offset || 0;
source = source.replace(reSpaceEnd, '');
var out = [];
if (!source) {
return out;
}
var tokens = cssParser.parse(source);
var it = tokenIterator.create(tokens);
var property;
while ((property = consumeSingleProperty(it,... | javascript | function extractPropertiesFromSource(source, offset) {
offset = offset || 0;
source = source.replace(reSpaceEnd, '');
var out = [];
if (!source) {
return out;
}
var tokens = cssParser.parse(source);
var it = tokenIterator.create(tokens);
var property;
while ((property = consumeSingleProperty(it,... | [
"function",
"extractPropertiesFromSource",
"(",
"source",
",",
"offset",
")",
"{",
"offset",
"=",
"offset",
"||",
"0",
";",
"source",
"=",
"source",
".",
"replace",
"(",
"reSpaceEnd",
",",
"''",
")",
";",
"var",
"out",
"=",
"[",
"]",
";",
"if",
"(",
... | Parses given CSS source and returns list of ranges of located CSS properties.
Normally, CSS source must contain properties only, it must be,
for example, a content of CSS selector or text between nested
CSS sections
@param {String} source CSS source
@param {Number} offset Offset of properties subset from original sour... | [
"Parses",
"given",
"CSS",
"source",
"and",
"returns",
"list",
"of",
"ranges",
"of",
"located",
"CSS",
"properties",
".",
"Normally",
"CSS",
"source",
"must",
"contain",
"properties",
"only",
"it",
"must",
"be",
"for",
"example",
"a",
"content",
"of",
"CSS",
... | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/css.js#L237-L264 | train |
emmetio/emmet | lib/editTree/css.js | function(name, value, pos) {
var list = this.list();
var start = this._positions.contentStart;
var styles = utils.pick(this.options, 'styleBefore', 'styleSeparator');
if (typeof pos === 'undefined') {
pos = list.length;
}
/** @type CSSEditProperty */
var donor = list[pos];
if (donor)... | javascript | function(name, value, pos) {
var list = this.list();
var start = this._positions.contentStart;
var styles = utils.pick(this.options, 'styleBefore', 'styleSeparator');
if (typeof pos === 'undefined') {
pos = list.length;
}
/** @type CSSEditProperty */
var donor = list[pos];
if (donor)... | [
"function",
"(",
"name",
",",
"value",
",",
"pos",
")",
"{",
"var",
"list",
"=",
"this",
".",
"list",
"(",
")",
";",
"var",
"start",
"=",
"this",
".",
"_positions",
".",
"contentStart",
";",
"var",
"styles",
"=",
"utils",
".",
"pick",
"(",
"this",
... | Adds new CSS property
@param {String} name Property name
@param {String} value Property value
@param {Number} pos Position at which to insert new property. By
default the property is inserted at the end of rule
@returns {CSSEditProperty} | [
"Adds",
"new",
"CSS",
"property"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/css.js#L392-L429 | train | |
emmetio/emmet | lib/editTree/css.js | function(isAbsolute) {
var parts = findParts(this.value());
if (isAbsolute) {
var offset = this.valuePosition(true);
parts.forEach(function(p) {
p.shift(offset);
});
}
return parts;
} | javascript | function(isAbsolute) {
var parts = findParts(this.value());
if (isAbsolute) {
var offset = this.valuePosition(true);
parts.forEach(function(p) {
p.shift(offset);
});
}
return parts;
} | [
"function",
"(",
"isAbsolute",
")",
"{",
"var",
"parts",
"=",
"findParts",
"(",
"this",
".",
"value",
"(",
")",
")",
";",
"if",
"(",
"isAbsolute",
")",
"{",
"var",
"offset",
"=",
"this",
".",
"valuePosition",
"(",
"true",
")",
";",
"parts",
".",
"f... | Returns ranges of complex value parts
@returns {Array} Returns <code>null</code> if value is not complex | [
"Returns",
"ranges",
"of",
"complex",
"value",
"parts"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/css.js#L450-L460 | train | |
emmetio/emmet | lib/editTree/css.js | function(val) {
var isUpdating = typeof val !== 'undefined';
var allItems = this.parent.list();
if (isUpdating && this.isIncomplete()) {
var self = this;
var donor = utils.find(allItems, function(item) {
return item !== self && !item.isIncomplete();
});
this.styleSeparator = donor
?... | javascript | function(val) {
var isUpdating = typeof val !== 'undefined';
var allItems = this.parent.list();
if (isUpdating && this.isIncomplete()) {
var self = this;
var donor = utils.find(allItems, function(item) {
return item !== self && !item.isIncomplete();
});
this.styleSeparator = donor
?... | [
"function",
"(",
"val",
")",
"{",
"var",
"isUpdating",
"=",
"typeof",
"val",
"!==",
"'undefined'",
";",
"var",
"allItems",
"=",
"this",
".",
"parent",
".",
"list",
"(",
")",
";",
"if",
"(",
"isUpdating",
"&&",
"this",
".",
"isIncomplete",
"(",
")",
"... | Sets of gets element value.
When setting value, this implementation will ensure that your have
proper name-value separator
@param {String} val New element value. If not passed, current
value is returned
@returns {String} | [
"Sets",
"of",
"gets",
"element",
"value",
".",
"When",
"setting",
"value",
"this",
"implementation",
"will",
"ensure",
"that",
"your",
"have",
"proper",
"name",
"-",
"value",
"separator"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/css.js#L470-L495 | train | |
emmetio/emmet | lib/editTree/css.js | function(css, pos) {
var cssProp = null;
/** @type EditContainer */
var cssRule = typeof css === 'string' ? this.parseFromPosition(css, pos, true) : css;
if (cssRule) {
cssProp = cssRule.itemFromPosition(pos, true);
if (!cssProp) {
// in case user just started writing CSS property
// and d... | javascript | function(css, pos) {
var cssProp = null;
/** @type EditContainer */
var cssRule = typeof css === 'string' ? this.parseFromPosition(css, pos, true) : css;
if (cssRule) {
cssProp = cssRule.itemFromPosition(pos, true);
if (!cssProp) {
// in case user just started writing CSS property
// and d... | [
"function",
"(",
"css",
",",
"pos",
")",
"{",
"var",
"cssProp",
"=",
"null",
";",
"/** @type EditContainer */",
"var",
"cssRule",
"=",
"typeof",
"css",
"===",
"'string'",
"?",
"this",
".",
"parseFromPosition",
"(",
"css",
",",
"pos",
",",
"true",
")",
":... | Locates CSS property in given CSS code fragment under specified character position
@param {String} css CSS code or parsed CSSEditContainer
@param {Number} pos Character position where to search CSS property
@return {CSSEditElement} | [
"Locates",
"CSS",
"property",
"in",
"given",
"CSS",
"code",
"fragment",
"under",
"specified",
"character",
"position"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/css.js#L577-L593 | train | |
emmetio/emmet | lib/assets/range.js | function(range) {
if (this.overlap(range)) {
var start = Math.max(range.start, this.start);
var end = Math.min(range.end, this.end);
return new Range(start, end - start);
}
return null;
} | javascript | function(range) {
if (this.overlap(range)) {
var start = Math.max(range.start, this.start);
var end = Math.min(range.end, this.end);
return new Range(start, end - start);
}
return null;
} | [
"function",
"(",
"range",
")",
"{",
"if",
"(",
"this",
".",
"overlap",
"(",
"range",
")",
")",
"{",
"var",
"start",
"=",
"Math",
".",
"max",
"(",
"range",
".",
"start",
",",
"this",
".",
"start",
")",
";",
"var",
"end",
"=",
"Math",
".",
"min",... | Finds intersection of two ranges
@param {Range} range
@returns {Range} <code>null</code> if ranges does not overlap | [
"Finds",
"intersection",
"of",
"two",
"ranges"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/assets/range.js#L93-L101 | train | |
emmetio/emmet | lib/assets/range.js | function(loc, left, right) {
var a, b;
if (loc instanceof Range) {
a = loc.start;
b = loc.end;
} else {
a = b = loc;
}
return cmp(this.start, a, left || '<=') && cmp(this.end, b, right || '>');
} | javascript | function(loc, left, right) {
var a, b;
if (loc instanceof Range) {
a = loc.start;
b = loc.end;
} else {
a = b = loc;
}
return cmp(this.start, a, left || '<=') && cmp(this.end, b, right || '>');
} | [
"function",
"(",
"loc",
",",
"left",
",",
"right",
")",
"{",
"var",
"a",
",",
"b",
";",
"if",
"(",
"loc",
"instanceof",
"Range",
")",
"{",
"a",
"=",
"loc",
".",
"start",
";",
"b",
"=",
"loc",
".",
"end",
";",
"}",
"else",
"{",
"a",
"=",
"b"... | Low-level comparision method
@param {Number} loc
@param {String} left Left comparison operator
@param {String} right Right comaprison operator | [
"Low",
"-",
"level",
"comparision",
"method"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/assets/range.js#L153-L163 | train | |
emmetio/emmet | lib/utils/common.js | function(strings) {
var lengths = strings.map(function(s) {
return typeof s === 'string' ? s.length : +s;
});
var max = lengths.reduce(function(prev, cur) {
return typeof prev === 'undefined' ? cur : Math.max(prev, cur);
});
return lengths.map(function(l) {
var pad = max - l;
return p... | javascript | function(strings) {
var lengths = strings.map(function(s) {
return typeof s === 'string' ? s.length : +s;
});
var max = lengths.reduce(function(prev, cur) {
return typeof prev === 'undefined' ? cur : Math.max(prev, cur);
});
return lengths.map(function(l) {
var pad = max - l;
return p... | [
"function",
"(",
"strings",
")",
"{",
"var",
"lengths",
"=",
"strings",
".",
"map",
"(",
"function",
"(",
"s",
")",
"{",
"return",
"typeof",
"s",
"===",
"'string'",
"?",
"s",
".",
"length",
":",
"+",
"s",
";",
"}",
")",
";",
"var",
"max",
"=",
... | Returns list of paddings that should be used to align passed string
@param {Array} strings
@returns {Array} | [
"Returns",
"list",
"of",
"paddings",
"that",
"should",
"be",
"used",
"to",
"align",
"passed",
"string"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/utils/common.js#L117-L129 | train | |
emmetio/emmet | lib/utils/common.js | function(text, pad) {
var result = [];
var lines = this.splitByLines(text);
var nl = '\n';
result.push(lines[0]);
for (var j = 1; j < lines.length; j++)
result.push(nl + pad + lines[j]);
return result.join('');
} | javascript | function(text, pad) {
var result = [];
var lines = this.splitByLines(text);
var nl = '\n';
result.push(lines[0]);
for (var j = 1; j < lines.length; j++)
result.push(nl + pad + lines[j]);
return result.join('');
} | [
"function",
"(",
"text",
",",
"pad",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"lines",
"=",
"this",
".",
"splitByLines",
"(",
"text",
")",
";",
"var",
"nl",
"=",
"'\\n'",
";",
"result",
".",
"push",
"(",
"lines",
"[",
"0",
"]",
")"... | Indents text with padding
@param {String} text Text to indent
@param {String} pad Padding size (number) or padding itself (string)
@return {String} | [
"Indents",
"text",
"with",
"padding"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/utils/common.js#L137-L147 | train | |
emmetio/emmet | lib/utils/common.js | function(str, pad) {
var padding = '';
var il = str.length;
while (pad > il++) padding += '0';
return padding + str;
} | javascript | function(str, pad) {
var padding = '';
var il = str.length;
while (pad > il++) padding += '0';
return padding + str;
} | [
"function",
"(",
"str",
",",
"pad",
")",
"{",
"var",
"padding",
"=",
"''",
";",
"var",
"il",
"=",
"str",
".",
"length",
";",
"while",
"(",
"pad",
">",
"il",
"++",
")",
"padding",
"+=",
"'0'",
";",
"return",
"padding",
"+",
"str",
";",
"}"
] | Pad string with zeroes
@param {String} str String to pad
@param {Number} pad Desired string length
@return {String} | [
"Pad",
"string",
"with",
"zeroes"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/utils/common.js#L155-L161 | train | |
emmetio/emmet | lib/utils/common.js | function(text, pad) {
var lines = this.splitByLines(text);
var pl = pad.length;
for (var i = 0, il = lines.length, line; i < il; i++) {
line = lines[i];
if (line.substr(0, pl) === pad) {
lines[i] = line.substr(pl);
}
}
return lines.join('\n');
} | javascript | function(text, pad) {
var lines = this.splitByLines(text);
var pl = pad.length;
for (var i = 0, il = lines.length, line; i < il; i++) {
line = lines[i];
if (line.substr(0, pl) === pad) {
lines[i] = line.substr(pl);
}
}
return lines.join('\n');
} | [
"function",
"(",
"text",
",",
"pad",
")",
"{",
"var",
"lines",
"=",
"this",
".",
"splitByLines",
"(",
"text",
")",
";",
"var",
"pl",
"=",
"pad",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"il",
"=",
"lines",
".",
"length",
",",
... | Removes padding at the beginning of each text's line
@param {String} text
@param {String} pad | [
"Removes",
"padding",
"at",
"the",
"beginning",
"of",
"each",
"text",
"s",
"line"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/utils/common.js#L168-L179 | train | |
emmetio/emmet | lib/utils/common.js | function(content, ranges, ch, noRepeat) {
if (ranges.length) {
var offset = 0, fragments = [];
ranges.forEach(function(r) {
var repl = noRepeat ? ch : this.repeatString(ch, r[1] - r[0]);
fragments.push(content.substring(offset, r[0]), repl);
offset = r[1];
}, this);
content = fragment... | javascript | function(content, ranges, ch, noRepeat) {
if (ranges.length) {
var offset = 0, fragments = [];
ranges.forEach(function(r) {
var repl = noRepeat ? ch : this.repeatString(ch, r[1] - r[0]);
fragments.push(content.substring(offset, r[0]), repl);
offset = r[1];
}, this);
content = fragment... | [
"function",
"(",
"content",
",",
"ranges",
",",
"ch",
",",
"noRepeat",
")",
"{",
"if",
"(",
"ranges",
".",
"length",
")",
"{",
"var",
"offset",
"=",
"0",
",",
"fragments",
"=",
"[",
"]",
";",
"ranges",
".",
"forEach",
"(",
"function",
"(",
"r",
"... | Fills substrings in `content`, defined by given ranges,
wich `ch` character
@param {String} content
@param {Array} ranges
@return {String} | [
"Fills",
"substrings",
"in",
"content",
"defined",
"by",
"given",
"ranges",
"wich",
"ch",
"character"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/utils/common.js#L412-L425 | train | |
emmetio/emmet | lib/utils/common.js | function(text, start, end) {
var rng = range.create(start, end);
var reSpace = /[\s\n\r\u00a0]/;
// narrow down selection until first non-space character
while (rng.start < rng.end) {
if (!reSpace.test(text.charAt(rng.start)))
break;
rng.start++;
}
while (rng.end > rng.start... | javascript | function(text, start, end) {
var rng = range.create(start, end);
var reSpace = /[\s\n\r\u00a0]/;
// narrow down selection until first non-space character
while (rng.start < rng.end) {
if (!reSpace.test(text.charAt(rng.start)))
break;
rng.start++;
}
while (rng.end > rng.start... | [
"function",
"(",
"text",
",",
"start",
",",
"end",
")",
"{",
"var",
"rng",
"=",
"range",
".",
"create",
"(",
"start",
",",
"end",
")",
";",
"var",
"reSpace",
"=",
"/",
"[\\s\\n\\r\\u00a0]",
"/",
";",
"// narrow down selection until first non-space character",
... | Narrows down text range, adjusting selection to non-space characters
@param {String} text
@param {Number} start Starting range in <code>text</code> where
slection should be adjusted. Can also be any object that is accepted
by <code>Range</code> class
@return {Range} | [
"Narrows",
"down",
"text",
"range",
"adjusting",
"selection",
"to",
"non",
"-",
"space",
"characters"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/utils/common.js#L435-L456 | train | |
emmetio/emmet | lib/assets/tabStops.js | function(node, offset) {
var maxNum = 0;
var options = {
tabstop: function(data) {
var group = parseInt(data.group, 10);
if (group > maxNum) maxNum = group;
if (data.placeholder)
return '${' + (group + offset) + ':' + data.placeholder + '}';
else
return '${' + (group + o... | javascript | function(node, offset) {
var maxNum = 0;
var options = {
tabstop: function(data) {
var group = parseInt(data.group, 10);
if (group > maxNum) maxNum = group;
if (data.placeholder)
return '${' + (group + offset) + ':' + data.placeholder + '}';
else
return '${' + (group + o... | [
"function",
"(",
"node",
",",
"offset",
")",
"{",
"var",
"maxNum",
"=",
"0",
";",
"var",
"options",
"=",
"{",
"tabstop",
":",
"function",
"(",
"data",
")",
"{",
"var",
"group",
"=",
"parseInt",
"(",
"data",
".",
"group",
",",
"10",
")",
";",
"if"... | Upgrades tabstops in output node in order to prevent naming conflicts
@param {AbbreviationNode} node
@param {Number} offset Tab index offset
@returns {Number} Maximum tabstop index in element | [
"Upgrades",
"tabstops",
"in",
"output",
"node",
"in",
"order",
"to",
"prevent",
"naming",
"conflicts"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/assets/tabStops.js#L223-L242 | train | |
emmetio/emmet | lib/assets/tabStops.js | function(text, node, type) {
var maxNum = 0;
var that = this;
var tsOptions = {
tabstop: function(data) {
var group = parseInt(data.group, 10);
if (group === 0)
return '${0}';
if (group > maxNum) maxNum = group;
if (data.placeholder) {
// respect nested placeholder... | javascript | function(text, node, type) {
var maxNum = 0;
var that = this;
var tsOptions = {
tabstop: function(data) {
var group = parseInt(data.group, 10);
if (group === 0)
return '${0}';
if (group > maxNum) maxNum = group;
if (data.placeholder) {
// respect nested placeholder... | [
"function",
"(",
"text",
",",
"node",
",",
"type",
")",
"{",
"var",
"maxNum",
"=",
"0",
";",
"var",
"that",
"=",
"this",
";",
"var",
"tsOptions",
"=",
"{",
"tabstop",
":",
"function",
"(",
"data",
")",
"{",
"var",
"group",
"=",
"parseInt",
"(",
"... | Output processor for abbreviation parser that will upgrade tabstops
of parsed node in order to prevent tabstop index conflicts | [
"Output",
"processor",
"for",
"abbreviation",
"parser",
"that",
"will",
"upgrade",
"tabstops",
"of",
"parsed",
"node",
"in",
"order",
"to",
"prevent",
"tabstop",
"index",
"conflicts"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/assets/tabStops.js#L336-L366 | train | |
emmetio/emmet | lib/filter/html.js | makeAttributesString | function makeAttributesString(node, profile) {
var attrQuote = profile.attributeQuote();
var cursor = profile.cursor();
return node.attributeList().map(function(a) {
var isBoolean = profile.isBoolean(a.name, a.value);
var attrName = profile.attributeName(a.name);
var attrValue = isBoolean ? attrName :... | javascript | function makeAttributesString(node, profile) {
var attrQuote = profile.attributeQuote();
var cursor = profile.cursor();
return node.attributeList().map(function(a) {
var isBoolean = profile.isBoolean(a.name, a.value);
var attrName = profile.attributeName(a.name);
var attrValue = isBoolean ? attrName :... | [
"function",
"makeAttributesString",
"(",
"node",
",",
"profile",
")",
"{",
"var",
"attrQuote",
"=",
"profile",
".",
"attributeQuote",
"(",
")",
";",
"var",
"cursor",
"=",
"profile",
".",
"cursor",
"(",
")",
";",
"return",
"node",
".",
"attributeList",
"(",... | Creates HTML attributes string from tag according to profile settings
@param {AbbreviationNode} node
@param {OutputProfile} profile | [
"Creates",
"HTML",
"attributes",
"string",
"from",
"tag",
"according",
"to",
"profile",
"settings"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/filter/html.js#L21-L34 | train |
emmetio/emmet | lib/utils/action.js | function(str) {
var curOffset = str.length;
var startIndex = -1;
var groupCount = 0;
var braceCount = 0;
var textCount = 0;
while (true) {
curOffset--;
if (curOffset < 0) {
// moved to the beginning of the line
startIndex = 0;
break;
}
var ch = str.charAt(curOff... | javascript | function(str) {
var curOffset = str.length;
var startIndex = -1;
var groupCount = 0;
var braceCount = 0;
var textCount = 0;
while (true) {
curOffset--;
if (curOffset < 0) {
// moved to the beginning of the line
startIndex = 0;
break;
}
var ch = str.charAt(curOff... | [
"function",
"(",
"str",
")",
"{",
"var",
"curOffset",
"=",
"str",
".",
"length",
";",
"var",
"startIndex",
"=",
"-",
"1",
";",
"var",
"groupCount",
"=",
"0",
";",
"var",
"braceCount",
"=",
"0",
";",
"var",
"textCount",
"=",
"0",
";",
"while",
"(",
... | Extracts abbreviations from text stream, starting from the end
@param {String} str
@return {String} Abbreviation or empty string
@memberOf emmet.actionUtils | [
"Extracts",
"abbreviations",
"from",
"text",
"stream",
"starting",
"from",
"the",
"end"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/utils/action.js#L37-L96 | train | |
emmetio/emmet | lib/utils/action.js | function(stream) {
var pngMagicNum = "\211PNG\r\n\032\n",
jpgMagicNum = "\377\330",
gifMagicNum = "GIF8",
pos = 0,
nextByte = function() {
return stream.charCodeAt(pos++);
};
if (stream.substr(0, 8) === pngMagicNum) {
// PNG. Easy peasy.
pos = stream.indexOf('IHDR') + 4;
... | javascript | function(stream) {
var pngMagicNum = "\211PNG\r\n\032\n",
jpgMagicNum = "\377\330",
gifMagicNum = "GIF8",
pos = 0,
nextByte = function() {
return stream.charCodeAt(pos++);
};
if (stream.substr(0, 8) === pngMagicNum) {
// PNG. Easy peasy.
pos = stream.indexOf('IHDR') + 4;
... | [
"function",
"(",
"stream",
")",
"{",
"var",
"pngMagicNum",
"=",
"\"\\211PNG\\r\\n\\032\\n\"",
",",
"jpgMagicNum",
"=",
"\"\\377\\330\"",
",",
"gifMagicNum",
"=",
"\"GIF8\"",
",",
"pos",
"=",
"0",
",",
"nextByte",
"=",
"function",
"(",
")",
"{",
"return",
"st... | Gets image size from image byte stream.
@author http://romeda.org/rePublish/
@param {String} stream Image byte stream (use <code>IEmmetFile.read()</code>)
@return {Object} Object with <code>width</code> and <code>height</code> properties | [
"Gets",
"image",
"size",
"from",
"image",
"byte",
"stream",
"."
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/utils/action.js#L104-L154 | train | |
emmetio/emmet | lib/utils/action.js | function(editor, pos) {
var allowedSyntaxes = {'html': 1, 'xml': 1, 'xsl': 1, 'jsx': 1};
var syntax = editor.getSyntax();
if (syntax in allowedSyntaxes) {
var content = editor.getContent();
if (typeof pos === 'undefined') {
pos = editor.getCaretPos();
}
var tag = htmlMatcher.find(content,... | javascript | function(editor, pos) {
var allowedSyntaxes = {'html': 1, 'xml': 1, 'xsl': 1, 'jsx': 1};
var syntax = editor.getSyntax();
if (syntax in allowedSyntaxes) {
var content = editor.getContent();
if (typeof pos === 'undefined') {
pos = editor.getCaretPos();
}
var tag = htmlMatcher.find(content,... | [
"function",
"(",
"editor",
",",
"pos",
")",
"{",
"var",
"allowedSyntaxes",
"=",
"{",
"'html'",
":",
"1",
",",
"'xml'",
":",
"1",
",",
"'xsl'",
":",
"1",
",",
"'jsx'",
":",
"1",
"}",
";",
"var",
"syntax",
"=",
"editor",
".",
"getSyntax",
"(",
")",... | Captures context XHTML element from editor under current caret position.
This node can be used as a helper for abbreviation extraction
@param {IEmmetEditor} editor
@returns {Object} | [
"Captures",
"context",
"XHTML",
"element",
"from",
"editor",
"under",
"current",
"caret",
"position",
".",
"This",
"node",
"can",
"be",
"used",
"as",
"a",
"helper",
"for",
"abbreviation",
"extraction"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/utils/action.js#L162-L196 | train | |
emmetio/emmet | lib/parser/css.js | tokener | function tokener(value, type) {
session.tokens.push({
value: value,
type: type || value,
start: null,
end: null
});
} | javascript | function tokener(value, type) {
session.tokens.push({
value: value,
type: type || value,
start: null,
end: null
});
} | [
"function",
"tokener",
"(",
"value",
",",
"type",
")",
"{",
"session",
".",
"tokens",
".",
"push",
"(",
"{",
"value",
":",
"value",
",",
"type",
":",
"type",
"||",
"value",
",",
"start",
":",
"null",
",",
"end",
":",
"null",
"}",
")",
";",
"}"
] | creates token objects and pushes them to a list | [
"creates",
"token",
"objects",
"and",
"pushes",
"them",
"to",
"a",
"list"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/parser/css.js#L76-L83 | train |
emmetio/emmet | lib/parser/css.js | tokenize | function tokenize() {
var ch = walker.ch;
if (ch === " " || ch === "\t") {
return white();
}
if (ch === '/') {
return comment();
}
if (ch === '"' || ch === "'") {
return str();
}
if (ch === '(') {
return brace();
}
if (ch === '-' || ch === '.' || isDigit(ch)) { // tricky - char... | javascript | function tokenize() {
var ch = walker.ch;
if (ch === " " || ch === "\t") {
return white();
}
if (ch === '/') {
return comment();
}
if (ch === '"' || ch === "'") {
return str();
}
if (ch === '(') {
return brace();
}
if (ch === '-' || ch === '.' || isDigit(ch)) { // tricky - char... | [
"function",
"tokenize",
"(",
")",
"{",
"var",
"ch",
"=",
"walker",
".",
"ch",
";",
"if",
"(",
"ch",
"===",
"\" \"",
"||",
"ch",
"===",
"\"\\t\"",
")",
"{",
"return",
"white",
"(",
")",
";",
"}",
"if",
"(",
"ch",
"===",
"'/'",
")",
"{",
"return"... | call the appropriate handler based on the first character in a token suspect | [
"call",
"the",
"appropriate",
"handler",
"based",
"on",
"the",
"first",
"character",
"in",
"a",
"token",
"suspect"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/parser/css.js#L324-L372 | train |
emmetio/emmet | lib/parser/css.js | function (source) {
walker.init(source);
session.tokens = [];
// for empty source, return single space token
if (!source) {
session.tokens.push(this.white());
} else {
while (walker.ch !== '') {
tokenize();
}
}
var tokens = session.tokens;
session.tokens = null;
return toke... | javascript | function (source) {
walker.init(source);
session.tokens = [];
// for empty source, return single space token
if (!source) {
session.tokens.push(this.white());
} else {
while (walker.ch !== '') {
tokenize();
}
}
var tokens = session.tokens;
session.tokens = null;
return toke... | [
"function",
"(",
"source",
")",
"{",
"walker",
".",
"init",
"(",
"source",
")",
";",
"session",
".",
"tokens",
"=",
"[",
"]",
";",
"// for empty source, return single space token",
"if",
"(",
"!",
"source",
")",
"{",
"session",
".",
"tokens",
".",
"push",
... | Sprits given source into tokens
@param {String} source
@returns {Array} | [
"Sprits",
"given",
"source",
"into",
"tokens"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/parser/css.js#L380-L396 | train | |
emmetio/emmet | lib/generator/lorem.js | paragraph | function paragraph(lang, wordCount, startWithCommon) {
var data = langs[lang];
if (!data) {
return '';
}
var result = [];
var totalWords = 0;
var words;
wordCount = parseInt(wordCount, 10);
if (startWithCommon && data.common) {
words = data.common.slice(0, wordCount);
if (words.length > ... | javascript | function paragraph(lang, wordCount, startWithCommon) {
var data = langs[lang];
if (!data) {
return '';
}
var result = [];
var totalWords = 0;
var words;
wordCount = parseInt(wordCount, 10);
if (startWithCommon && data.common) {
words = data.common.slice(0, wordCount);
if (words.length > ... | [
"function",
"paragraph",
"(",
"lang",
",",
"wordCount",
",",
"startWithCommon",
")",
"{",
"var",
"data",
"=",
"langs",
"[",
"lang",
"]",
";",
"if",
"(",
"!",
"data",
")",
"{",
"return",
"''",
";",
"}",
"var",
"result",
"=",
"[",
"]",
";",
"var",
... | Generate a paragraph of "Lorem ipsum" text
@param {Number} wordCount Words count in paragraph
@param {Boolean} startWithCommon Should paragraph start with common
"lorem ipsum" sentence.
@returns {String} | [
"Generate",
"a",
"paragraph",
"of",
"Lorem",
"ipsum",
"text"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/generator/lorem.js#L211-L240 | train |
emmetio/emmet | lib/generator/lorem.js | function(lang, data) {
if (typeof data === 'string') {
data = {
words: data.split(' ').filter(function(item) {
return !!item;
})
};
} else if (Array.isArray(data)) {
data = {words: data};
}
langs[lang] = data;
} | javascript | function(lang, data) {
if (typeof data === 'string') {
data = {
words: data.split(' ').filter(function(item) {
return !!item;
})
};
} else if (Array.isArray(data)) {
data = {words: data};
}
langs[lang] = data;
} | [
"function",
"(",
"lang",
",",
"data",
")",
"{",
"if",
"(",
"typeof",
"data",
"===",
"'string'",
")",
"{",
"data",
"=",
"{",
"words",
":",
"data",
".",
"split",
"(",
"' '",
")",
".",
"filter",
"(",
"function",
"(",
"item",
")",
"{",
"return",
"!",... | Adds new language words for Lorem Ipsum generator
@param {String} lang Two-letter lang definition
@param {Object} data Words for language. Maight be either a space-separated
list of words (String), Array of words or object with <code>text</code> and
<code>common</code> properties | [
"Adds",
"new",
"language",
"words",
"for",
"Lorem",
"Ipsum",
"generator"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/generator/lorem.js#L250-L262 | train | |
emmetio/emmet | lib/plugin/file.js | function(path, size, callback) {
var params = this._parseParams(arguments);
this._read(params, function(err, buf) {
params.callback(err, err ? '' : bts(buf));
});
} | javascript | function(path, size, callback) {
var params = this._parseParams(arguments);
this._read(params, function(err, buf) {
params.callback(err, err ? '' : bts(buf));
});
} | [
"function",
"(",
"path",
",",
"size",
",",
"callback",
")",
"{",
"var",
"params",
"=",
"this",
".",
"_parseParams",
"(",
"arguments",
")",
";",
"this",
".",
"_read",
"(",
"params",
",",
"function",
"(",
"err",
",",
"buf",
")",
"{",
"params",
".",
"... | Reads binary file content and return it
@param {String} path File's relative or absolute path
@return {String} | [
"Reads",
"binary",
"file",
"content",
"and",
"return",
"it"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/plugin/file.js#L116-L121 | train | |
emmetio/emmet | lib/action/lineBreaks.js | function(editor) {
var info = editorUtils.outputInfo(editor);
var caretPos = editor.getCaretPos();
var nl = '\n';
var pad = '\t';
if (~xmlSyntaxes.indexOf(info.syntax)) {
// let's see if we're breaking newly created tag
var tag = htmlMatcher.tag(info.content, caretPos);
if (tag && !tag.in... | javascript | function(editor) {
var info = editorUtils.outputInfo(editor);
var caretPos = editor.getCaretPos();
var nl = '\n';
var pad = '\t';
if (~xmlSyntaxes.indexOf(info.syntax)) {
// let's see if we're breaking newly created tag
var tag = htmlMatcher.tag(info.content, caretPos);
if (tag && !tag.in... | [
"function",
"(",
"editor",
")",
"{",
"var",
"info",
"=",
"editorUtils",
".",
"outputInfo",
"(",
"editor",
")",
";",
"var",
"caretPos",
"=",
"editor",
".",
"getCaretPos",
"(",
")",
";",
"var",
"nl",
"=",
"'\\n'",
";",
"var",
"pad",
"=",
"'\\t'",
";",
... | Inserts newline character with proper indentation in specific positions only.
@param {IEmmetEditor} editor
@return {Boolean} Returns <code>true</code> if line break was inserted | [
"Inserts",
"newline",
"character",
"with",
"proper",
"indentation",
"in",
"specific",
"positions",
"only",
"."
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/lineBreaks.js#L72-L124 | train | |
emmetio/emmet | lib/editTree/base.js | EditContainer | function EditContainer(source, options) {
this.options = utils.extend({offset: 0}, options);
/**
* Source code of edited structure. All changes in the structure are
* immediately reflected into this property
*/
this.source = source;
/**
* List of all editable children
* @private
*/
thi... | javascript | function EditContainer(source, options) {
this.options = utils.extend({offset: 0}, options);
/**
* Source code of edited structure. All changes in the structure are
* immediately reflected into this property
*/
this.source = source;
/**
* List of all editable children
* @private
*/
thi... | [
"function",
"EditContainer",
"(",
"source",
",",
"options",
")",
"{",
"this",
".",
"options",
"=",
"utils",
".",
"extend",
"(",
"{",
"offset",
":",
"0",
"}",
",",
"options",
")",
";",
"/**\n\t\t * Source code of edited structure. All changes in the structure are \n\... | Named container of edited source
@type EditContainer
@param {String} source
@param {Object} options | [
"Named",
"container",
"of",
"edited",
"source"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/base.js#L44-L67 | train |
emmetio/emmet | lib/editTree/base.js | function(value, start, end) {
// create modification range
var r = range.create(start, typeof end === 'undefined' ? 0 : end - start);
var delta = value.length - r.length();
var update = function(obj) {
Object.keys(obj).forEach(function(k) {
if (obj[k] >= r.end) {
obj[k] += delta;
}
... | javascript | function(value, start, end) {
// create modification range
var r = range.create(start, typeof end === 'undefined' ? 0 : end - start);
var delta = value.length - r.length();
var update = function(obj) {
Object.keys(obj).forEach(function(k) {
if (obj[k] >= r.end) {
obj[k] += delta;
}
... | [
"function",
"(",
"value",
",",
"start",
",",
"end",
")",
"{",
"// create modification range",
"var",
"r",
"=",
"range",
".",
"create",
"(",
"start",
",",
"typeof",
"end",
"===",
"'undefined'",
"?",
"0",
":",
"end",
"-",
"start",
")",
";",
"var",
"delta... | Replace substring of tag's source
@param {String} value
@param {Number} start
@param {Number} end
@private | [
"Replace",
"substring",
"of",
"tag",
"s",
"source"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/base.js#L100-L128 | train | |
emmetio/emmet | lib/editTree/base.js | function(items) {
items.forEach(function(item) {
update(item._positions);
if (item.type == 'container') {
recursiveUpdate(item.list());
}
});
} | javascript | function(items) {
items.forEach(function(item) {
update(item._positions);
if (item.type == 'container') {
recursiveUpdate(item.list());
}
});
} | [
"function",
"(",
"items",
")",
"{",
"items",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"update",
"(",
"item",
".",
"_positions",
")",
";",
"if",
"(",
"item",
".",
"type",
"==",
"'container'",
")",
"{",
"recursiveUpdate",
"(",
"item",
".... | update affected positions of children | [
"update",
"affected",
"positions",
"of",
"children"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/base.js#L117-L124 | train | |
emmetio/emmet | lib/editTree/base.js | function(name, value, pos) {
// this is abstract implementation
var item = new EditElement(name, value);
this._children.push(item);
return item;
} | javascript | function(name, value, pos) {
// this is abstract implementation
var item = new EditElement(name, value);
this._children.push(item);
return item;
} | [
"function",
"(",
"name",
",",
"value",
",",
"pos",
")",
"{",
"// this is abstract implementation",
"var",
"item",
"=",
"new",
"EditElement",
"(",
"name",
",",
"value",
")",
";",
"this",
".",
"_children",
".",
"push",
"(",
"item",
")",
";",
"return",
"ite... | Adds new attribute
@param {String} name Property name
@param {String} value Property value
@param {Number} pos Position at which to insert new property. By
default the property is inserted at the end of rule
@returns {EditElement} Newly created element | [
"Adds",
"new",
"attribute"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/base.js#L139-L144 | train | |
emmetio/emmet | lib/editTree/base.js | function(name) {
if (typeof name === 'number') {
return this.list()[name];
}
if (typeof name === 'string') {
return utils.find(this.list(), function(prop) {
return prop.name() === name;
});
}
return name;
} | javascript | function(name) {
if (typeof name === 'number') {
return this.list()[name];
}
if (typeof name === 'string') {
return utils.find(this.list(), function(prop) {
return prop.name() === name;
});
}
return name;
} | [
"function",
"(",
"name",
")",
"{",
"if",
"(",
"typeof",
"name",
"===",
"'number'",
")",
"{",
"return",
"this",
".",
"list",
"(",
")",
"[",
"name",
"]",
";",
"}",
"if",
"(",
"typeof",
"name",
"===",
"'string'",
")",
"{",
"return",
"utils",
".",
"f... | Returns attribute object
@param {String} name Attribute name or its index
@returns {EditElement} | [
"Returns",
"attribute",
"object"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/base.js#L151-L163 | train | |
emmetio/emmet | lib/editTree/base.js | function(name) {
if (!Array.isArray(name))
name = [name];
// split names and indexes
var names = [], indexes = [];
name.forEach(function(item) {
if (typeof item === 'string') {
names.push(item);
} else if (typeof item === 'number') {
indexes.push(item);
}
});
return t... | javascript | function(name) {
if (!Array.isArray(name))
name = [name];
// split names and indexes
var names = [], indexes = [];
name.forEach(function(item) {
if (typeof item === 'string') {
names.push(item);
} else if (typeof item === 'number') {
indexes.push(item);
}
});
return t... | [
"function",
"(",
"name",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"name",
")",
")",
"name",
"=",
"[",
"name",
"]",
";",
"// split names and indexes",
"var",
"names",
"=",
"[",
"]",
",",
"indexes",
"=",
"[",
"]",
";",
"name",
".",
"... | Returns all children by name or indexes
@param {Object} name Element name(s) or indexes (<code>String</code>,
<code>Array</code>, <code>Number</code>)
@returns {Array} | [
"Returns",
"all",
"children",
"by",
"name",
"or",
"indexes"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/base.js#L171-L188 | train | |
emmetio/emmet | lib/editTree/base.js | function(name) {
var element = this.get(name);
if (element) {
this._updateSource('', element.fullRange());
var ix = this._children.indexOf(element);
if (~ix) {
this._children.splice(ix, 1);
}
}
} | javascript | function(name) {
var element = this.get(name);
if (element) {
this._updateSource('', element.fullRange());
var ix = this._children.indexOf(element);
if (~ix) {
this._children.splice(ix, 1);
}
}
} | [
"function",
"(",
"name",
")",
"{",
"var",
"element",
"=",
"this",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"element",
")",
"{",
"this",
".",
"_updateSource",
"(",
"''",
",",
"element",
".",
"fullRange",
"(",
")",
")",
";",
"var",
"ix",
"=",
... | Remove child element
@param {String} name Property name or its index | [
"Remove",
"child",
"element"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/base.js#L202-L211 | train | |
emmetio/emmet | lib/editTree/base.js | function(name, value, pos) {
var element = this.get(name);
if (element)
return element.value(value);
if (typeof value !== 'undefined') {
// no such element — create it
return this.add(name, value, pos);
}
} | javascript | function(name, value, pos) {
var element = this.get(name);
if (element)
return element.value(value);
if (typeof value !== 'undefined') {
// no such element — create it
return this.add(name, value, pos);
}
} | [
"function",
"(",
"name",
",",
"value",
",",
"pos",
")",
"{",
"var",
"element",
"=",
"this",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"element",
")",
"return",
"element",
".",
"value",
"(",
"value",
")",
";",
"if",
"(",
"typeof",
"value",
"!=... | Returns or updates element value. If such element doesn't exists,
it will be created automatically and added at the end of child list.
@param {String} name Element name or its index
@param {String} value New element value
@returns {String} | [
"Returns",
"or",
"updates",
"element",
"value",
".",
"If",
"such",
"element",
"doesn",
"t",
"exists",
"it",
"will",
"be",
"created",
"automatically",
"and",
"added",
"at",
"the",
"end",
"of",
"child",
"list",
"."
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/base.js#L229-L238 | train | |
emmetio/emmet | lib/editTree/base.js | function(val) {
if (typeof val !== 'undefined' && this._name !== (val = String(val))) {
this._updateSource(val, this._positions.name, this._positions.name + this._name.length);
this._name = val;
}
return this._name;
} | javascript | function(val) {
if (typeof val !== 'undefined' && this._name !== (val = String(val))) {
this._updateSource(val, this._positions.name, this._positions.name + this._name.length);
this._name = val;
}
return this._name;
} | [
"function",
"(",
"val",
")",
"{",
"if",
"(",
"typeof",
"val",
"!==",
"'undefined'",
"&&",
"this",
".",
"_name",
"!==",
"(",
"val",
"=",
"String",
"(",
"val",
")",
")",
")",
"{",
"this",
".",
"_updateSource",
"(",
"val",
",",
"this",
".",
"_position... | Sets or gets container name
@param {String} val New name. If not passed, current
name is returned
@return {String} | [
"Sets",
"or",
"gets",
"container",
"name"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/base.js#L259-L266 | train | |
emmetio/emmet | lib/editTree/base.js | function(pos, isAbsolute) {
return utils.find(this.list(), function(elem) {
return elem.range(isAbsolute).inside(pos);
});
} | javascript | function(pos, isAbsolute) {
return utils.find(this.list(), function(elem) {
return elem.range(isAbsolute).inside(pos);
});
} | [
"function",
"(",
"pos",
",",
"isAbsolute",
")",
"{",
"return",
"utils",
".",
"find",
"(",
"this",
".",
"list",
"(",
")",
",",
"function",
"(",
"elem",
")",
"{",
"return",
"elem",
".",
"range",
"(",
"isAbsolute",
")",
".",
"inside",
"(",
"pos",
")",... | Returns element that belongs to specified position
@param {Number} pos
@param {Boolean} isAbsolute
@returns {EditElement} | [
"Returns",
"element",
"that",
"belongs",
"to",
"specified",
"position"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/base.js#L292-L296 | train | |
emmetio/emmet | lib/editTree/base.js | function(val) {
if (typeof val !== 'undefined' && this._value !== (val = String(val))) {
this.parent._updateSource(val, this.valueRange());
this._value = val;
}
return this._value;
} | javascript | function(val) {
if (typeof val !== 'undefined' && this._value !== (val = String(val))) {
this.parent._updateSource(val, this.valueRange());
this._value = val;
}
return this._value;
} | [
"function",
"(",
"val",
")",
"{",
"if",
"(",
"typeof",
"val",
"!==",
"'undefined'",
"&&",
"this",
".",
"_value",
"!==",
"(",
"val",
"=",
"String",
"(",
"val",
")",
")",
")",
"{",
"this",
".",
"parent",
".",
"_updateSource",
"(",
"val",
",",
"this",... | Sets of gets element value
@param {String} val New element value. If not passed, current
value is returned
@returns {String} | [
"Sets",
"of",
"gets",
"element",
"value"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/base.js#L362-L369 | train | |
emmetio/emmet | lib/editTree/base.js | function(val) {
if (typeof val !== 'undefined' && this._name !== (val = String(val))) {
this.parent._updateSource(val, this.nameRange());
this._name = val;
}
return this._name;
} | javascript | function(val) {
if (typeof val !== 'undefined' && this._name !== (val = String(val))) {
this.parent._updateSource(val, this.nameRange());
this._name = val;
}
return this._name;
} | [
"function",
"(",
"val",
")",
"{",
"if",
"(",
"typeof",
"val",
"!==",
"'undefined'",
"&&",
"this",
".",
"_name",
"!==",
"(",
"val",
"=",
"String",
"(",
"val",
")",
")",
")",
"{",
"this",
".",
"parent",
".",
"_updateSource",
"(",
"val",
",",
"this",
... | Sets of gets element name
@param {String} val New element name. If not passed, current
name is returned
@returns {String} | [
"Sets",
"of",
"gets",
"element",
"name"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/editTree/base.js#L377-L384 | train | |
emmetio/emmet | lib/resolver/gradient/linear.js | function(colorStop) {
colorStop = normalizeSpace(colorStop);
// find color declaration
// first, try complex color declaration, like rgb(0,0,0)
var color = null;
colorStop = colorStop.replace(/^(\w+\(.+?\))\s*/, function(str, c) {
color = c;
return '';
});
if (!color) {
// try s... | javascript | function(colorStop) {
colorStop = normalizeSpace(colorStop);
// find color declaration
// first, try complex color declaration, like rgb(0,0,0)
var color = null;
colorStop = colorStop.replace(/^(\w+\(.+?\))\s*/, function(str, c) {
color = c;
return '';
});
if (!color) {
// try s... | [
"function",
"(",
"colorStop",
")",
"{",
"colorStop",
"=",
"normalizeSpace",
"(",
"colorStop",
")",
";",
"// find color declaration",
"// first, try complex color declaration, like rgb(0,0,0)",
"var",
"color",
"=",
"null",
";",
"colorStop",
"=",
"colorStop",
".",
"replac... | Parses color stop definition
@param {String} colorStop
@returns {Object} | [
"Parses",
"color",
"stop",
"definition"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/resolver/gradient/linear.js#L94-L133 | train | |
emmetio/emmet | lib/resolver/gradient/linear.js | function(colorStops) {
var from = 0;
colorStops.forEach(function(cs, i) {
// make sure that first and last positions are defined
if (!i) {
return cs.position = cs.position || 0;
}
if (i == colorStops.length - 1 && !('position' in cs)) {
cs.position = 1;
}
if ('posit... | javascript | function(colorStops) {
var from = 0;
colorStops.forEach(function(cs, i) {
// make sure that first and last positions are defined
if (!i) {
return cs.position = cs.position || 0;
}
if (i == colorStops.length - 1 && !('position' in cs)) {
cs.position = 1;
}
if ('posit... | [
"function",
"(",
"colorStops",
")",
"{",
"var",
"from",
"=",
"0",
";",
"colorStops",
".",
"forEach",
"(",
"function",
"(",
"cs",
",",
"i",
")",
"{",
"// make sure that first and last positions are defined",
"if",
"(",
"!",
"i",
")",
"{",
"return",
"cs",
".... | Fills-out implied positions in color-stops. This function is useful for
old Webkit gradient definitions | [
"Fills",
"-",
"out",
"implied",
"positions",
"in",
"color",
"-",
"stops",
".",
"This",
"function",
"is",
"useful",
"for",
"old",
"Webkit",
"gradient",
"definitions"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/resolver/gradient/linear.js#L199-L222 | train | |
emmetio/emmet | lib/resolver/gradient/linear.js | resolveDirection | function resolveDirection(dir) {
if (typeof dir == 'number') {
return dir;
}
dir = normalizeSpace(dir).toLowerCase();
if (reDeg.test(dir)) {
return +RegExp.$1;
}
var prefix = /^to\s/.test(dir) ? 'to ' : '';
var left = ~dir.indexOf('left') && 'left';
var right = ~dir.indexOf('right') && 'ri... | javascript | function resolveDirection(dir) {
if (typeof dir == 'number') {
return dir;
}
dir = normalizeSpace(dir).toLowerCase();
if (reDeg.test(dir)) {
return +RegExp.$1;
}
var prefix = /^to\s/.test(dir) ? 'to ' : '';
var left = ~dir.indexOf('left') && 'left';
var right = ~dir.indexOf('right') && 'ri... | [
"function",
"resolveDirection",
"(",
"dir",
")",
"{",
"if",
"(",
"typeof",
"dir",
"==",
"'number'",
")",
"{",
"return",
"dir",
";",
"}",
"dir",
"=",
"normalizeSpace",
"(",
"dir",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"reDeg",
".",
"test"... | Resolves textual direction to degrees
@param {String} dir Direction to resolve
@return {Number} | [
"Resolves",
"textual",
"direction",
"to",
"degrees"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/resolver/gradient/linear.js#L238-L256 | train |
emmetio/emmet | lib/resolver/gradient/linear.js | stringifyDirection | function stringifyDirection(dir, oldStyle) {
var reNewStyle = /^to\s/;
var keys = Object.keys(directions).filter(function(k) {
var hasPrefix = reNewStyle.test(k);
return oldStyle ? !hasPrefix : hasPrefix;
});
for (var i = 0; i < keys.length; i++) {
if (directions[keys[i]] == dir) {
return keys[i];... | javascript | function stringifyDirection(dir, oldStyle) {
var reNewStyle = /^to\s/;
var keys = Object.keys(directions).filter(function(k) {
var hasPrefix = reNewStyle.test(k);
return oldStyle ? !hasPrefix : hasPrefix;
});
for (var i = 0; i < keys.length; i++) {
if (directions[keys[i]] == dir) {
return keys[i];... | [
"function",
"stringifyDirection",
"(",
"dir",
",",
"oldStyle",
")",
"{",
"var",
"reNewStyle",
"=",
"/",
"^to\\s",
"/",
";",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"directions",
")",
".",
"filter",
"(",
"function",
"(",
"k",
")",
"{",
"var",
... | Tries to find keyword for given direction, expressed in degrees
@param {Number} dir Direction (degrees)
@param {Boolean} oldStyle Use old style keywords (e.g. "top" instead of "to bottom")
@return {String} Keyword or <code>Ndeg</code> expression | [
"Tries",
"to",
"find",
"keyword",
"for",
"given",
"direction",
"expressed",
"in",
"degrees"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/resolver/gradient/linear.js#L264-L282 | train |
emmetio/emmet | lib/resolver/gradient/linear.js | function(gradient) {
// cut out all redundant data
if (this.isLinearGradient(gradient)) {
gradient = gradient.replace(/^\s*[\-a-z]+\s*\(|\)\s*$/ig, '');
} else {
throw 'Invalid linear gradient definition:\n' + gradient;
}
return new LinearGradient(gradient);
} | javascript | function(gradient) {
// cut out all redundant data
if (this.isLinearGradient(gradient)) {
gradient = gradient.replace(/^\s*[\-a-z]+\s*\(|\)\s*$/ig, '');
} else {
throw 'Invalid linear gradient definition:\n' + gradient;
}
return new LinearGradient(gradient);
} | [
"function",
"(",
"gradient",
")",
"{",
"// cut out all redundant data",
"if",
"(",
"this",
".",
"isLinearGradient",
"(",
"gradient",
")",
")",
"{",
"gradient",
"=",
"gradient",
".",
"replace",
"(",
"/",
"^\\s*[\\-a-z]+\\s*\\(|\\)\\s*$",
"/",
"ig",
",",
"''",
"... | Parses gradient definition into an object.
This object can be used to transform gradient into various
forms
@param {String} gradient Gradient definition
@return {LinearGradient} | [
"Parses",
"gradient",
"definition",
"into",
"an",
"object",
".",
"This",
"object",
"can",
"be",
"used",
"to",
"transform",
"gradient",
"into",
"various",
"forms"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/resolver/gradient/linear.js#L311-L320 | train | |
emmetio/emmet | lib/assets/resources.js | parseAbbreviation | function parseAbbreviation(key, value) {
key = utils.trim(key);
var m;
if ((m = reTag.exec(value))) {
return elements.create('element', m[1], m[2], m[4] == '/');
} else {
// assume it's reference to another abbreviation
return elements.create('reference', value);
}
} | javascript | function parseAbbreviation(key, value) {
key = utils.trim(key);
var m;
if ((m = reTag.exec(value))) {
return elements.create('element', m[1], m[2], m[4] == '/');
} else {
// assume it's reference to another abbreviation
return elements.create('reference', value);
}
} | [
"function",
"parseAbbreviation",
"(",
"key",
",",
"value",
")",
"{",
"key",
"=",
"utils",
".",
"trim",
"(",
"key",
")",
";",
"var",
"m",
";",
"if",
"(",
"(",
"m",
"=",
"reTag",
".",
"exec",
"(",
"value",
")",
")",
")",
"{",
"return",
"elements",
... | Parses single abbreviation
@param {String} key Abbreviation name
@param {String} value Abbreviation value
@return {Object} | [
"Parses",
"single",
"abbreviation"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/assets/resources.js#L75-L84 | train |
emmetio/emmet | lib/assets/resources.js | function(data, type) {
cache = {};
// sections like "snippets" and "abbreviations" could have
// definitions like `"f|fs": "fieldset"` which is the same as distinct
// "f" and "fs" keys both equals to "fieldset".
// We should parse these definitions first
var voc = {};
each(data, function(section,... | javascript | function(data, type) {
cache = {};
// sections like "snippets" and "abbreviations" could have
// definitions like `"f|fs": "fieldset"` which is the same as distinct
// "f" and "fs" keys both equals to "fieldset".
// We should parse these definitions first
var voc = {};
each(data, function(section,... | [
"function",
"(",
"data",
",",
"type",
")",
"{",
"cache",
"=",
"{",
"}",
";",
"// sections like \"snippets\" and \"abbreviations\" could have",
"// definitions like `\"f|fs\": \"fieldset\"` which is the same as distinct",
"// \"f\" and \"fs\" keys both equals to \"fieldset\".",
"// We s... | Sets new unparsed data for specified settings vocabulary
@param {Object} data
@param {String} type Vocabulary type ('system' or 'user')
@memberOf resources | [
"Sets",
"new",
"unparsed",
"data",
"for",
"specified",
"settings",
"vocabulary"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/assets/resources.js#L115-L141 | train | |
emmetio/emmet | lib/assets/resources.js | function(name, value){
var voc = this.getVocabulary('user') || {};
if (!('variables' in voc))
voc.variables = {};
voc.variables[name] = value;
this.setVocabulary(voc, 'user');
} | javascript | function(name, value){
var voc = this.getVocabulary('user') || {};
if (!('variables' in voc))
voc.variables = {};
voc.variables[name] = value;
this.setVocabulary(voc, 'user');
} | [
"function",
"(",
"name",
",",
"value",
")",
"{",
"var",
"voc",
"=",
"this",
".",
"getVocabulary",
"(",
"'user'",
")",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"(",
"'variables'",
"in",
"voc",
")",
")",
"voc",
".",
"variables",
"=",
"{",
"}",
";",
"... | Store runtime variable in user storage
@param {String} name Variable name
@param {String} value Variable value | [
"Store",
"runtime",
"variable",
"in",
"user",
"storage"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/assets/resources.js#L177-L184 | train | |
emmetio/emmet | lib/assets/resources.js | function(name) {
if (!name)
return null;
if (!(name in cache)) {
cache[name] = utils.deepMerge({}, systemSettings[name], userSettings[name]);
}
var data = cache[name], subsections = utils.toArray(arguments, 1), key;
while (data && (key = subsections.shift())) {
if (key in data) {
data ... | javascript | function(name) {
if (!name)
return null;
if (!(name in cache)) {
cache[name] = utils.deepMerge({}, systemSettings[name], userSettings[name]);
}
var data = cache[name], subsections = utils.toArray(arguments, 1), key;
while (data && (key = subsections.shift())) {
if (key in data) {
data ... | [
"function",
"(",
"name",
")",
"{",
"if",
"(",
"!",
"name",
")",
"return",
"null",
";",
"if",
"(",
"!",
"(",
"name",
"in",
"cache",
")",
")",
"{",
"cache",
"[",
"name",
"]",
"=",
"utils",
".",
"deepMerge",
"(",
"{",
"}",
",",
"systemSettings",
"... | Returns actual section data, merged from both
system and user data
@param {String} name Section name (syntax)
@param {String} ...args Subsections
@returns | [
"Returns",
"actual",
"section",
"data",
"merged",
"from",
"both",
"system",
"and",
"user",
"data"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/assets/resources.js#L220-L238 | train | |
emmetio/emmet | lib/assets/resources.js | function(syntax, name, minScore) {
var result = this.fuzzyFindMatches(syntax, name, minScore)[0];
if (result) {
return result.value.parsedValue;
}
} | javascript | function(syntax, name, minScore) {
var result = this.fuzzyFindMatches(syntax, name, minScore)[0];
if (result) {
return result.value.parsedValue;
}
} | [
"function",
"(",
"syntax",
",",
"name",
",",
"minScore",
")",
"{",
"var",
"result",
"=",
"this",
".",
"fuzzyFindMatches",
"(",
"syntax",
",",
"name",
",",
"minScore",
")",
"[",
"0",
"]",
";",
"if",
"(",
"result",
")",
"{",
"return",
"result",
".",
... | Performs fuzzy search of snippet definition
@param {String} syntax Top-level section name (syntax)
@param {String} name Snippet name
@returns | [
"Performs",
"fuzzy",
"search",
"of",
"snippet",
"definition"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/assets/resources.js#L305-L310 | train | |
emmetio/emmet | lib/assets/resources.js | function(syntax) {
var cacheKey = 'all-' + syntax;
if (!cache[cacheKey]) {
var stack = [], sectionKey = syntax;
var memo = [];
do {
var section = this.getSection(sectionKey);
if (!section)
break;
['snippets', 'abbreviations'].forEach(function(sectionName) {
var stackItem =... | javascript | function(syntax) {
var cacheKey = 'all-' + syntax;
if (!cache[cacheKey]) {
var stack = [], sectionKey = syntax;
var memo = [];
do {
var section = this.getSection(sectionKey);
if (!section)
break;
['snippets', 'abbreviations'].forEach(function(sectionName) {
var stackItem =... | [
"function",
"(",
"syntax",
")",
"{",
"var",
"cacheKey",
"=",
"'all-'",
"+",
"syntax",
";",
"if",
"(",
"!",
"cache",
"[",
"cacheKey",
"]",
")",
"{",
"var",
"stack",
"=",
"[",
"]",
",",
"sectionKey",
"=",
"syntax",
";",
"var",
"memo",
"=",
"[",
"]"... | Returns plain dictionary of all available abbreviations and snippets
for specified syntax with respect of inheritance
@param {String} syntax
@returns {Object} | [
"Returns",
"plain",
"dictionary",
"of",
"all",
"available",
"abbreviations",
"and",
"snippets",
"for",
"specified",
"syntax",
"with",
"respect",
"of",
"inheritance"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/assets/resources.js#L341-L375 | train | |
emmetio/emmet | lib/action/expandAbbreviation.js | findAbbreviation | function findAbbreviation(editor) {
var r = range(editor.getSelectionRange());
var content = String(editor.getContent());
if (r.length()) {
// abbreviation is selected by user
return r.substring(content);
}
// search for new abbreviation from current caret position
var curLine = editor.getCurrentLi... | javascript | function findAbbreviation(editor) {
var r = range(editor.getSelectionRange());
var content = String(editor.getContent());
if (r.length()) {
// abbreviation is selected by user
return r.substring(content);
}
// search for new abbreviation from current caret position
var curLine = editor.getCurrentLi... | [
"function",
"findAbbreviation",
"(",
"editor",
")",
"{",
"var",
"r",
"=",
"range",
"(",
"editor",
".",
"getSelectionRange",
"(",
")",
")",
";",
"var",
"content",
"=",
"String",
"(",
"editor",
".",
"getContent",
"(",
")",
")",
";",
"if",
"(",
"r",
"."... | Search for abbreviation in editor from current caret position
@param {IEmmetEditor} editor Editor instance
@return {String} | [
"Search",
"for",
"abbreviation",
"in",
"editor",
"from",
"current",
"caret",
"position"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/expandAbbreviation.js#L31-L42 | train |
emmetio/emmet | lib/utils/editor.js | function(html, caretPos) {
var reTag = /^<\/?\w[\w\:\-]*.*?>/;
// search left to find opening brace
var pos = caretPos;
while (pos > -1) {
if (html.charAt(pos) == '<')
break;
pos--;
}
if (pos != -1) {
var m = reTag.exec(html.substring(pos));
if (m && caretPos > pos && car... | javascript | function(html, caretPos) {
var reTag = /^<\/?\w[\w\:\-]*.*?>/;
// search left to find opening brace
var pos = caretPos;
while (pos > -1) {
if (html.charAt(pos) == '<')
break;
pos--;
}
if (pos != -1) {
var m = reTag.exec(html.substring(pos));
if (m && caretPos > pos && car... | [
"function",
"(",
"html",
",",
"caretPos",
")",
"{",
"var",
"reTag",
"=",
"/",
"^<\\/?\\w[\\w\\:\\-]*.*?>",
"/",
";",
"// search left to find opening brace",
"var",
"pos",
"=",
"caretPos",
";",
"while",
"(",
"pos",
">",
"-",
"1",
")",
"{",
"if",
"(",
"html"... | Check if cursor is placed inside XHTML tag
@param {String} html Contents of the document
@param {Number} caretPos Current caret position inside tag
@return {Boolean} | [
"Check",
"if",
"cursor",
"is",
"placed",
"inside",
"XHTML",
"tag"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/utils/editor.js#L22-L40 | train | |
emmetio/emmet | lib/utils/editor.js | function(editor, syntax, profile) {
// most of this code makes sense for Java/Rhino environment
// because string that comes from Java are not actually JS string
// but Java String object so the have to be explicitly converted
// to native string
profile = profile || editor.getProfileName();
return {... | javascript | function(editor, syntax, profile) {
// most of this code makes sense for Java/Rhino environment
// because string that comes from Java are not actually JS string
// but Java String object so the have to be explicitly converted
// to native string
profile = profile || editor.getProfileName();
return {... | [
"function",
"(",
"editor",
",",
"syntax",
",",
"profile",
")",
"{",
"// most of this code makes sense for Java/Rhino environment",
"// because string that comes from Java are not actually JS string",
"// but Java String object so the have to be explicitly converted",
"// to native string",
... | Sanitizes incoming editor data and provides default values for
output-specific info
@param {IEmmetEditor} editor
@param {String} syntax
@param {String} profile | [
"Sanitizes",
"incoming",
"editor",
"data",
"and",
"provides",
"default",
"values",
"for",
"output",
"-",
"specific",
"info"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/utils/editor.js#L49-L61 | train | |
emmetio/emmet | lib/action/reflectCSSValue.js | getReflectedCSSName | function getReflectedCSSName(name) {
name = cssEditTree.baseName(name);
var vendorPrefix = '^(?:\\-\\w+\\-)?', m;
if ((name == 'opacity' || name == 'filter') && prefs.get('css.reflect.oldIEOpacity')) {
return new RegExp(vendorPrefix + '(?:opacity|filter)$');
} else if ((m = name.match(/^border-radius-(top... | javascript | function getReflectedCSSName(name) {
name = cssEditTree.baseName(name);
var vendorPrefix = '^(?:\\-\\w+\\-)?', m;
if ((name == 'opacity' || name == 'filter') && prefs.get('css.reflect.oldIEOpacity')) {
return new RegExp(vendorPrefix + '(?:opacity|filter)$');
} else if ((m = name.match(/^border-radius-(top... | [
"function",
"getReflectedCSSName",
"(",
"name",
")",
"{",
"name",
"=",
"cssEditTree",
".",
"baseName",
"(",
"name",
")",
";",
"var",
"vendorPrefix",
"=",
"'^(?:\\\\-\\\\w+\\\\-)?'",
",",
"m",
";",
"if",
"(",
"(",
"name",
"==",
"'opacity'",
"||",
"name",
"=... | Returns regexp that should match reflected CSS property names
@param {String} name Current CSS property name
@return {RegExp} | [
"Returns",
"regexp",
"that",
"should",
"match",
"reflected",
"CSS",
"property",
"names"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/reflectCSSValue.js#L61-L75 | train |
emmetio/emmet | lib/action/editPoints.js | findNewEditPoint | function findNewEditPoint(editor, inc, offset) {
inc = inc || 1;
offset = offset || 0;
var curPoint = editor.getCaretPos() + offset;
var content = String(editor.getContent());
var maxLen = content.length;
var nextPoint = -1;
var reEmptyLine = /^\s+$/;
function getLine(ix) {
var start = ix;
w... | javascript | function findNewEditPoint(editor, inc, offset) {
inc = inc || 1;
offset = offset || 0;
var curPoint = editor.getCaretPos() + offset;
var content = String(editor.getContent());
var maxLen = content.length;
var nextPoint = -1;
var reEmptyLine = /^\s+$/;
function getLine(ix) {
var start = ix;
w... | [
"function",
"findNewEditPoint",
"(",
"editor",
",",
"inc",
",",
"offset",
")",
"{",
"inc",
"=",
"inc",
"||",
"1",
";",
"offset",
"=",
"offset",
"||",
"0",
";",
"var",
"curPoint",
"=",
"editor",
".",
"getCaretPos",
"(",
")",
"+",
"offset",
";",
"var",... | Search for new caret insertion point
@param {IEmmetEditor} editor Editor instance
@param {Number} inc Search increment: -1 — search left, 1 — search right
@param {Number} offset Initial offset relative to current caret position
@return {Number} Returns -1 if insertion point wasn't found | [
"Search",
"for",
"new",
"caret",
"insertion",
"point"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/editPoints.js#L19-L75 | train |
emmetio/emmet | lib/action/editPoints.js | function(editor, syntax, profile) {
var curPos = editor.getCaretPos();
var newPoint = findNewEditPoint(editor, -1);
if (newPoint == curPos)
// we're still in the same point, try searching from the other place
newPoint = findNewEditPoint(editor, -1, -2);
if (newPoint != -1) {
editor.setC... | javascript | function(editor, syntax, profile) {
var curPos = editor.getCaretPos();
var newPoint = findNewEditPoint(editor, -1);
if (newPoint == curPos)
// we're still in the same point, try searching from the other place
newPoint = findNewEditPoint(editor, -1, -2);
if (newPoint != -1) {
editor.setC... | [
"function",
"(",
"editor",
",",
"syntax",
",",
"profile",
")",
"{",
"var",
"curPos",
"=",
"editor",
".",
"getCaretPos",
"(",
")",
";",
"var",
"newPoint",
"=",
"findNewEditPoint",
"(",
"editor",
",",
"-",
"1",
")",
";",
"if",
"(",
"newPoint",
"==",
"c... | Move to previous edit point
@param {IEmmetEditor} editor Editor instance
@param {String} syntax Current document syntax
@param {String} profile Output profile name
@return {Boolean} | [
"Move",
"to",
"previous",
"edit",
"point"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/editPoints.js#L85-L99 | train | |
emmetio/emmet | lib/action/editPoints.js | function(editor, syntax, profile) {
var newPoint = findNewEditPoint(editor, 1);
if (newPoint != -1) {
editor.setCaretPos(newPoint);
return true;
}
return false;
} | javascript | function(editor, syntax, profile) {
var newPoint = findNewEditPoint(editor, 1);
if (newPoint != -1) {
editor.setCaretPos(newPoint);
return true;
}
return false;
} | [
"function",
"(",
"editor",
",",
"syntax",
",",
"profile",
")",
"{",
"var",
"newPoint",
"=",
"findNewEditPoint",
"(",
"editor",
",",
"1",
")",
";",
"if",
"(",
"newPoint",
"!=",
"-",
"1",
")",
"{",
"editor",
".",
"setCaretPos",
"(",
"newPoint",
")",
";... | Move to next edit point
@param {IEmmetEditor} editor Editor instance
@param {String} syntax Current document syntax
@param {String} profile Output profile name
@return {Boolean} | [
"Move",
"to",
"next",
"edit",
"point"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/editPoints.js#L108-L116 | train | |
emmetio/emmet | lib/filter/haml.js | makeAttributesString | function makeAttributesString(tag, profile) {
var attrs = '';
var otherAttrs = [];
var attrQuote = profile.attributeQuote();
var cursor = profile.cursor();
tag.attributeList().forEach(function(a) {
var attrName = profile.attributeName(a.name);
switch (attrName.toLowerCase()) {
// use short notati... | javascript | function makeAttributesString(tag, profile) {
var attrs = '';
var otherAttrs = [];
var attrQuote = profile.attributeQuote();
var cursor = profile.cursor();
tag.attributeList().forEach(function(a) {
var attrName = profile.attributeName(a.name);
switch (attrName.toLowerCase()) {
// use short notati... | [
"function",
"makeAttributesString",
"(",
"tag",
",",
"profile",
")",
"{",
"var",
"attrs",
"=",
"''",
";",
"var",
"otherAttrs",
"=",
"[",
"]",
";",
"var",
"attrQuote",
"=",
"profile",
".",
"attributeQuote",
"(",
")",
";",
"var",
"cursor",
"=",
"profile",
... | Creates HAML attributes string from tag according to profile settings
@param {AbbreviationNode} tag
@param {Object} profile | [
"Creates",
"HAML",
"attributes",
"string",
"from",
"tag",
"according",
"to",
"profile",
"settings"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/filter/haml.js#L67-L98 | train |
emmetio/emmet | lib/action/updateImageSize.js | updateImageSizeHTML | function updateImageSizeHTML(editor) {
var offset = editor.getCaretPos();
// find tag from current caret position
var info = editorUtils.outputInfo(editor);
var xmlElem = xmlEditTree.parseFromPosition(info.content, offset, true);
if (xmlElem && (xmlElem.name() || '').toLowerCase() == 'img') {
getImageSize... | javascript | function updateImageSizeHTML(editor) {
var offset = editor.getCaretPos();
// find tag from current caret position
var info = editorUtils.outputInfo(editor);
var xmlElem = xmlEditTree.parseFromPosition(info.content, offset, true);
if (xmlElem && (xmlElem.name() || '').toLowerCase() == 'img') {
getImageSize... | [
"function",
"updateImageSizeHTML",
"(",
"editor",
")",
"{",
"var",
"offset",
"=",
"editor",
".",
"getCaretPos",
"(",
")",
";",
"// find tag from current caret position",
"var",
"info",
"=",
"editorUtils",
".",
"outputInfo",
"(",
"editor",
")",
";",
"var",
"xmlEl... | Updates image size of <img src=""> tag
@param {IEmmetEditor} editor | [
"Updates",
"image",
"size",
"of",
"<",
";",
"img",
"src",
"=",
">",
";",
"tag"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/updateImageSize.js#L24-L44 | train |
emmetio/emmet | lib/action/updateImageSize.js | getImageSizeForSource | function getImageSizeForSource(editor, src, callback) {
var fileContent;
if (src) {
// check if it is data:url
if (/^data:/.test(src)) {
fileContent = base64.decode( src.replace(/^data\:.+?;.+?,/, '') );
return callback(actionUtils.getImageSize(fileContent));
}
var filePath = editor.getFilePath... | javascript | function getImageSizeForSource(editor, src, callback) {
var fileContent;
if (src) {
// check if it is data:url
if (/^data:/.test(src)) {
fileContent = base64.decode( src.replace(/^data\:.+?;.+?,/, '') );
return callback(actionUtils.getImageSize(fileContent));
}
var filePath = editor.getFilePath... | [
"function",
"getImageSizeForSource",
"(",
"editor",
",",
"src",
",",
"callback",
")",
"{",
"var",
"fileContent",
";",
"if",
"(",
"src",
")",
"{",
"// check if it is data:url",
"if",
"(",
"/",
"^data:",
"/",
".",
"test",
"(",
"src",
")",
")",
"{",
"fileCo... | Returns image dimensions for source
@param {IEmmetEditor} editor
@param {String} src Image source (path or data:url) | [
"Returns",
"image",
"dimensions",
"for",
"source"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/updateImageSize.js#L81-L106 | train |
emmetio/emmet | lib/filter/main.js | function(tree, filters, profileName) {
profileName = profile.get(profileName);
list(filters).forEach(function(filter) {
var name = utils.trim(filter.toLowerCase());
if (name && name in registeredFilters) {
tree = registeredFilters[name](tree, profileName);
}
});
return tree;
} | javascript | function(tree, filters, profileName) {
profileName = profile.get(profileName);
list(filters).forEach(function(filter) {
var name = utils.trim(filter.toLowerCase());
if (name && name in registeredFilters) {
tree = registeredFilters[name](tree, profileName);
}
});
return tree;
} | [
"function",
"(",
"tree",
",",
"filters",
",",
"profileName",
")",
"{",
"profileName",
"=",
"profile",
".",
"get",
"(",
"profileName",
")",
";",
"list",
"(",
"filters",
")",
".",
"forEach",
"(",
"function",
"(",
"filter",
")",
"{",
"var",
"name",
"=",
... | Apply filters for final output tree
@param {AbbreviationNode} tree Output tree
@param {Array} filters List of filters to apply. Might be a
<code>String</code>
@param {Object} profile Output profile, defined in <i>profile</i>
module. Filters defined it profile are not used, <code>profile</code>
is passed to filter funct... | [
"Apply",
"filters",
"for",
"final",
"output",
"tree"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/filter/main.js#L66-L77 | train | |
emmetio/emmet | lib/filter/main.js | function(syntax, profileName, additionalFilters) {
profileName = profile.get(profileName);
var filters = list(profileName.filters || resources.findItem(syntax, 'filters') || basicFilters);
if (profileName.extraFilters) {
filters = filters.concat(list(profileName.extraFilters));
}
if (additio... | javascript | function(syntax, profileName, additionalFilters) {
profileName = profile.get(profileName);
var filters = list(profileName.filters || resources.findItem(syntax, 'filters') || basicFilters);
if (profileName.extraFilters) {
filters = filters.concat(list(profileName.extraFilters));
}
if (additio... | [
"function",
"(",
"syntax",
",",
"profileName",
",",
"additionalFilters",
")",
"{",
"profileName",
"=",
"profile",
".",
"get",
"(",
"profileName",
")",
";",
"var",
"filters",
"=",
"list",
"(",
"profileName",
".",
"filters",
"||",
"resources",
".",
"findItem",... | Composes list of filters that should be applied to a tree, based on
passed data
@param {String} syntax Syntax name ('html', 'css', etc.)
@param {Object} profile Output profile
@param {String} additionalFilters List or pipe-separated
string of additional filters to apply
@returns {Array} | [
"Composes",
"list",
"of",
"filters",
"that",
"should",
"be",
"applied",
"to",
"a",
"tree",
"based",
"on",
"passed",
"data"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/filter/main.js#L88-L106 | train | |
emmetio/emmet | lib/filter/main.js | function(abbr) {
var filters = '';
abbr = abbr.replace(/\|([\w\|\-]+)$/, function(str, p1){
filters = p1;
return '';
});
return [abbr, list(filters)];
} | javascript | function(abbr) {
var filters = '';
abbr = abbr.replace(/\|([\w\|\-]+)$/, function(str, p1){
filters = p1;
return '';
});
return [abbr, list(filters)];
} | [
"function",
"(",
"abbr",
")",
"{",
"var",
"filters",
"=",
"''",
";",
"abbr",
"=",
"abbr",
".",
"replace",
"(",
"/",
"\\|([\\w\\|\\-]+)$",
"/",
",",
"function",
"(",
"str",
",",
"p1",
")",
"{",
"filters",
"=",
"p1",
";",
"return",
"''",
";",
"}",
... | Extracts filter list from abbreviation
@param {String} abbr
@returns {Array} Array with cleaned abbreviation and list of
extracted filters | [
"Extracts",
"filter",
"list",
"from",
"abbreviation"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/filter/main.js#L114-L122 | train | |
emmetio/emmet | lib/assets/htmlMatcher.js | function(i) {
var key = 'p' + i;
if (!(key in memo)) {
memo[key] = false;
if (text.charAt(i) == '<') {
var substr = text.slice(i);
if ((m = substr.match(reOpenTag))) {
memo[key] = openTag(i, m);
} else if ((m = substr.match(reCloseTag))) {
memo[key] = closeTag(i, m... | javascript | function(i) {
var key = 'p' + i;
if (!(key in memo)) {
memo[key] = false;
if (text.charAt(i) == '<') {
var substr = text.slice(i);
if ((m = substr.match(reOpenTag))) {
memo[key] = openTag(i, m);
} else if ((m = substr.match(reCloseTag))) {
memo[key] = closeTag(i, m... | [
"function",
"(",
"i",
")",
"{",
"var",
"key",
"=",
"'p'",
"+",
"i",
";",
"if",
"(",
"!",
"(",
"key",
"in",
"memo",
")",
")",
"{",
"memo",
"[",
"key",
"]",
"=",
"false",
";",
"if",
"(",
"text",
".",
"charAt",
"(",
"i",
")",
"==",
"'<'",
")... | Matches either opening or closing tag for given position
@param i
@returns | [
"Matches",
"either",
"opening",
"or",
"closing",
"tag",
"for",
"given",
"position"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/assets/htmlMatcher.js#L81-L97 | train | |
emmetio/emmet | lib/assets/htmlMatcher.js | findClosingPair | function findClosingPair(open, matcher) {
var stack = [], tag = null;
var text = matcher.text();
for (var pos = open.range.end, len = text.length; pos < len; pos++) {
if (matches(text, pos, '<!--')) {
// skip to end of comment
for (var j = pos; j < len; j++) {
if (matches(text, j, '-->')) {
... | javascript | function findClosingPair(open, matcher) {
var stack = [], tag = null;
var text = matcher.text();
for (var pos = open.range.end, len = text.length; pos < len; pos++) {
if (matches(text, pos, '<!--')) {
// skip to end of comment
for (var j = pos; j < len; j++) {
if (matches(text, j, '-->')) {
... | [
"function",
"findClosingPair",
"(",
"open",
",",
"matcher",
")",
"{",
"var",
"stack",
"=",
"[",
"]",
",",
"tag",
"=",
"null",
";",
"var",
"text",
"=",
"matcher",
".",
"text",
"(",
")",
";",
"for",
"(",
"var",
"pos",
"=",
"open",
".",
"range",
"."... | Search for closing pair of opening tag
@param {Object} open Open tag instance
@param {Object} matcher Matcher instance | [
"Search",
"for",
"closing",
"pair",
"of",
"opening",
"tag"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/assets/htmlMatcher.js#L122-L166 | train |
emmetio/emmet | lib/parser/abbreviation.js | function(child, position) {
child = child || new AbbreviationNode();
child.parent = this;
if (typeof position === 'undefined') {
this.children.push(child);
} else {
this.children.splice(position, 0, child);
}
return child;
} | javascript | function(child, position) {
child = child || new AbbreviationNode();
child.parent = this;
if (typeof position === 'undefined') {
this.children.push(child);
} else {
this.children.splice(position, 0, child);
}
return child;
} | [
"function",
"(",
"child",
",",
"position",
")",
"{",
"child",
"=",
"child",
"||",
"new",
"AbbreviationNode",
"(",
")",
";",
"child",
".",
"parent",
"=",
"this",
";",
"if",
"(",
"typeof",
"position",
"===",
"'undefined'",
")",
"{",
"this",
".",
"childre... | Adds passed node as child or creates new child
@param {AbbreviationNode} child
@param {Number} position Index in children array where child should
be inserted
@return {AbbreviationNode} | [
"Adds",
"passed",
"node",
"as",
"child",
"or",
"creates",
"new",
"child"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/parser/abbreviation.js#L86-L97 | train | |
emmetio/emmet | lib/parser/abbreviation.js | function() {
var node = new AbbreviationNode();
var attrs = ['abbreviation', 'counter', '_name', '_text', 'repeatCount', 'hasImplicitRepeat', 'start', 'end', 'content', 'padding'];
attrs.forEach(function(a) {
node[a] = this[a];
}, this);
// clone attributes
node._attributes = this._attributes.... | javascript | function() {
var node = new AbbreviationNode();
var attrs = ['abbreviation', 'counter', '_name', '_text', 'repeatCount', 'hasImplicitRepeat', 'start', 'end', 'content', 'padding'];
attrs.forEach(function(a) {
node[a] = this[a];
}, this);
// clone attributes
node._attributes = this._attributes.... | [
"function",
"(",
")",
"{",
"var",
"node",
"=",
"new",
"AbbreviationNode",
"(",
")",
";",
"var",
"attrs",
"=",
"[",
"'abbreviation'",
",",
"'counter'",
",",
"'_name'",
",",
"'_text'",
",",
"'repeatCount'",
",",
"'hasImplicitRepeat'",
",",
"'start'",
",",
"'... | Creates a deep copy of current node
@returns {AbbreviationNode} | [
"Creates",
"a",
"deep",
"copy",
"of",
"current",
"node"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/parser/abbreviation.js#L103-L125 | train | |
emmetio/emmet | lib/parser/abbreviation.js | function(name, value) {
if (arguments.length == 2) {
if (value === null) {
// remove attribute
var vals = this._attributes.filter(function(attr) {
return attr.name === name;
});
var that = this;
vals.forEach(function(attr) {
var ix = that._attributes.indexOf(attr);
if ... | javascript | function(name, value) {
if (arguments.length == 2) {
if (value === null) {
// remove attribute
var vals = this._attributes.filter(function(attr) {
return attr.name === name;
});
var that = this;
vals.forEach(function(attr) {
var ix = that._attributes.indexOf(attr);
if ... | [
"function",
"(",
"name",
",",
"value",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"==",
"2",
")",
"{",
"if",
"(",
"value",
"===",
"null",
")",
"{",
"// remove attribute",
"var",
"vals",
"=",
"this",
".",
"_attributes",
".",
"filter",
"(",
"func... | Returns or sets attribute value
@param {String} name Attribute name
@param {String} value New attribute value. `Null` value
will remove attribute
@returns {String} | [
"Returns",
"or",
"sets",
"attribute",
"value"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/parser/abbreviation.js#L252-L289 | train | |
emmetio/emmet | lib/parser/abbreviation.js | function(abbr) {
abbr = abbr || '';
var that = this;
// find multiplier
abbr = abbr.replace(/\*(\d+)?$/, function(str, repeatCount) {
that._setRepeat(repeatCount);
return '';
});
this.abbreviation = abbr;
var abbrText = extractText(abbr);
if (abbrText) {
abbr = abbrTe... | javascript | function(abbr) {
abbr = abbr || '';
var that = this;
// find multiplier
abbr = abbr.replace(/\*(\d+)?$/, function(str, repeatCount) {
that._setRepeat(repeatCount);
return '';
});
this.abbreviation = abbr;
var abbrText = extractText(abbr);
if (abbrText) {
abbr = abbrTe... | [
"function",
"(",
"abbr",
")",
"{",
"abbr",
"=",
"abbr",
"||",
"''",
";",
"var",
"that",
"=",
"this",
";",
"// find multiplier",
"abbr",
"=",
"abbr",
".",
"replace",
"(",
"/",
"\\*(\\d+)?$",
"/",
",",
"function",
"(",
"str",
",",
"repeatCount",
")",
"... | Sets abbreviation that belongs to current node
@param {String} abbr | [
"Sets",
"abbreviation",
"that",
"belongs",
"to",
"current",
"node"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/parser/abbreviation.js#L315-L346 | train | |
emmetio/emmet | lib/parser/abbreviation.js | function() {
var start = this.start;
var end = this.end;
var content = this.content;
// apply output processors
var node = this;
outputProcessors.forEach(function(fn) {
start = fn(start, node, 'start');
content = fn(content, node, 'content');
end = fn(end, node, 'end');
});
... | javascript | function() {
var start = this.start;
var end = this.end;
var content = this.content;
// apply output processors
var node = this;
outputProcessors.forEach(function(fn) {
start = fn(start, node, 'start');
content = fn(content, node, 'content');
end = fn(end, node, 'end');
});
... | [
"function",
"(",
")",
"{",
"var",
"start",
"=",
"this",
".",
"start",
";",
"var",
"end",
"=",
"this",
".",
"end",
";",
"var",
"content",
"=",
"this",
".",
"content",
";",
"// apply output processors",
"var",
"node",
"=",
"this",
";",
"outputProcessors",
... | Returns string representation of current node
@return {String} | [
"Returns",
"string",
"representation",
"of",
"current",
"node"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/parser/abbreviation.js#L352-L375 | train | |
emmetio/emmet | lib/parser/abbreviation.js | function() {
if (!this.children.length)
return null;
var deepestChild = this;
while (deepestChild.children.length) {
deepestChild = deepestChild.children[deepestChild.children.length - 1];
}
return deepestChild;
} | javascript | function() {
if (!this.children.length)
return null;
var deepestChild = this;
while (deepestChild.children.length) {
deepestChild = deepestChild.children[deepestChild.children.length - 1];
}
return deepestChild;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"children",
".",
"length",
")",
"return",
"null",
";",
"var",
"deepestChild",
"=",
"this",
";",
"while",
"(",
"deepestChild",
".",
"children",
".",
"length",
")",
"{",
"deepestChild",
"=",
"deepes... | Returns latest and deepest child of current tree
@returns {AbbreviationNode} | [
"Returns",
"latest",
"and",
"deepest",
"child",
"of",
"current",
"tree"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/parser/abbreviation.js#L446-L456 | train | |
emmetio/emmet | lib/parser/abbreviation.js | splitAttributes | function splitAttributes(attrSet) {
attrSet = utils.trim(attrSet);
var parts = [];
// split attribute set by spaces
var stream = stringStream(attrSet), ch;
while ((ch = stream.next())) {
if (ch == ' ') {
parts.push(utils.trim(stream.current()));
// skip spaces
while (stream.peek() == ' ') {
... | javascript | function splitAttributes(attrSet) {
attrSet = utils.trim(attrSet);
var parts = [];
// split attribute set by spaces
var stream = stringStream(attrSet), ch;
while ((ch = stream.next())) {
if (ch == ' ') {
parts.push(utils.trim(stream.current()));
// skip spaces
while (stream.peek() == ' ') {
... | [
"function",
"splitAttributes",
"(",
"attrSet",
")",
"{",
"attrSet",
"=",
"utils",
".",
"trim",
"(",
"attrSet",
")",
";",
"var",
"parts",
"=",
"[",
"]",
";",
"// split attribute set by spaces",
"var",
"stream",
"=",
"stringStream",
"(",
"attrSet",
")",
",",
... | Splits attribute set into a list of attributes string
@param {String} attrSet
@return {Array} | [
"Splits",
"attribute",
"set",
"into",
"a",
"list",
"of",
"attributes",
"string"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/parser/abbreviation.js#L577-L602 | train |
emmetio/emmet | lib/parser/abbreviation.js | unquote | function unquote(str) {
var ch = str.charAt(0);
if (ch == '"' || ch == "'") {
str = str.substr(1);
var last = str.charAt(str.length - 1);
if (last === ch) {
str = str.substr(0, str.length - 1);
}
}
return str;
} | javascript | function unquote(str) {
var ch = str.charAt(0);
if (ch == '"' || ch == "'") {
str = str.substr(1);
var last = str.charAt(str.length - 1);
if (last === ch) {
str = str.substr(0, str.length - 1);
}
}
return str;
} | [
"function",
"unquote",
"(",
"str",
")",
"{",
"var",
"ch",
"=",
"str",
".",
"charAt",
"(",
"0",
")",
";",
"if",
"(",
"ch",
"==",
"'\"'",
"||",
"ch",
"==",
"\"'\"",
")",
"{",
"str",
"=",
"str",
".",
"substr",
"(",
"1",
")",
";",
"var",
"last",
... | Removes opening and closing quotes from given string
@param {String} str
@return {String} | [
"Removes",
"opening",
"and",
"closing",
"quotes",
"from",
"given",
"string"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/parser/abbreviation.js#L609-L620 | train |
emmetio/emmet | lib/parser/abbreviation.js | function(abbr, options) {
if (!abbr) return '';
if (typeof options == 'string') {
throw new Error('Deprecated use of `expand` method: `options` must be object');
}
options = options || {};
if (!options.syntax) {
options.syntax = utils.defaultSyntax();
}
var p = profile.get(options.profil... | javascript | function(abbr, options) {
if (!abbr) return '';
if (typeof options == 'string') {
throw new Error('Deprecated use of `expand` method: `options` must be object');
}
options = options || {};
if (!options.syntax) {
options.syntax = utils.defaultSyntax();
}
var p = profile.get(options.profil... | [
"function",
"(",
"abbr",
",",
"options",
")",
"{",
"if",
"(",
"!",
"abbr",
")",
"return",
"''",
";",
"if",
"(",
"typeof",
"options",
"==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Deprecated use of `expand` method: `options` must be object'",
")",... | Expands given abbreviation into a formatted code structure.
This is the main method that is used for expanding abbreviation
@param {String} abbr Abbreviation to expand
@param {Options} options Additional options for abbreviation
expanding and transformation: `syntax`, `profile`, `contextNode` etc.
@return {String} | [
"Expands",
"given",
"abbreviation",
"into",
"a",
"formatted",
"code",
"structure",
".",
"This",
"is",
"the",
"main",
"method",
"that",
"is",
"used",
"for",
"expanding",
"abbreviation"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/parser/abbreviation.js#L941-L963 | train | |
emmetio/emmet | lib/action/selectItem.js | findItem | function findItem(editor, isBackward, extractFn, rangeFn) {
var content = editorUtils.outputInfo(editor).content;
var contentLength = content.length;
var itemRange, rng;
/** @type Range */
var prevRange = range(-1, 0);
/** @type Range */
var sel = range(editor.getSelectionRange());
var searchPos =... | javascript | function findItem(editor, isBackward, extractFn, rangeFn) {
var content = editorUtils.outputInfo(editor).content;
var contentLength = content.length;
var itemRange, rng;
/** @type Range */
var prevRange = range(-1, 0);
/** @type Range */
var sel = range(editor.getSelectionRange());
var searchPos =... | [
"function",
"findItem",
"(",
"editor",
",",
"isBackward",
",",
"extractFn",
",",
"rangeFn",
")",
"{",
"var",
"content",
"=",
"editorUtils",
".",
"outputInfo",
"(",
"editor",
")",
".",
"content",
";",
"var",
"contentLength",
"=",
"content",
".",
"length",
"... | Generic function for searching for items to select
@param {IEmmetEditor} editor
@param {Boolean} isBackward Search backward (search forward otherwise)
@param {Function} extractFn Function that extracts item content
@param {Function} rangeFn Function that search for next token range | [
"Generic",
"function",
"for",
"searching",
"for",
"items",
"to",
"select"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/selectItem.js#L31-L63 | train |
emmetio/emmet | lib/action/selectItem.js | findNextHTMLItem | function findNextHTMLItem(editor) {
var isFirst = true;
return findItem(editor, false, function(content, searchPos){
if (isFirst) {
isFirst = false;
return findOpeningTagFromPosition(content, searchPos);
} else {
return getOpeningTagFromPosition(content, searchPos);
}
}, function(tag, offset,... | javascript | function findNextHTMLItem(editor) {
var isFirst = true;
return findItem(editor, false, function(content, searchPos){
if (isFirst) {
isFirst = false;
return findOpeningTagFromPosition(content, searchPos);
} else {
return getOpeningTagFromPosition(content, searchPos);
}
}, function(tag, offset,... | [
"function",
"findNextHTMLItem",
"(",
"editor",
")",
"{",
"var",
"isFirst",
"=",
"true",
";",
"return",
"findItem",
"(",
"editor",
",",
"false",
",",
"function",
"(",
"content",
",",
"searchPos",
")",
"{",
"if",
"(",
"isFirst",
")",
"{",
"isFirst",
"=",
... | XXX HTML section
Find next HTML item
@param {IEmmetEditor} editor | [
"XXX",
"HTML",
"section",
"Find",
"next",
"HTML",
"item"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/selectItem.js#L71-L83 | train |
emmetio/emmet | lib/action/selectItem.js | findPrevHTMLItem | function findPrevHTMLItem(editor) {
return findItem(editor, true, getOpeningTagFromPosition, function (tag, offset, selRange) {
return getRangeForHTMLItem(tag, offset, selRange, true);
});
} | javascript | function findPrevHTMLItem(editor) {
return findItem(editor, true, getOpeningTagFromPosition, function (tag, offset, selRange) {
return getRangeForHTMLItem(tag, offset, selRange, true);
});
} | [
"function",
"findPrevHTMLItem",
"(",
"editor",
")",
"{",
"return",
"findItem",
"(",
"editor",
",",
"true",
",",
"getOpeningTagFromPosition",
",",
"function",
"(",
"tag",
",",
"offset",
",",
"selRange",
")",
"{",
"return",
"getRangeForHTMLItem",
"(",
"tag",
","... | Find previous HTML item
@param {IEmmetEditor} editor | [
"Find",
"previous",
"HTML",
"item"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/selectItem.js#L89-L93 | train |
emmetio/emmet | lib/action/selectItem.js | makePossibleRangesHTML | function makePossibleRangesHTML(source, tokens, offset) {
offset = offset || 0;
var result = [];
var attrStart = -1, attrName = '', attrValue = '', attrValueRange, tagName;
tokens.forEach(function(tok) {
switch (tok.type) {
case 'tag':
tagName = source.substring(tok.start, tok.end);
if (/^<[\w\... | javascript | function makePossibleRangesHTML(source, tokens, offset) {
offset = offset || 0;
var result = [];
var attrStart = -1, attrName = '', attrValue = '', attrValueRange, tagName;
tokens.forEach(function(tok) {
switch (tok.type) {
case 'tag':
tagName = source.substring(tok.start, tok.end);
if (/^<[\w\... | [
"function",
"makePossibleRangesHTML",
"(",
"source",
",",
"tokens",
",",
"offset",
")",
"{",
"offset",
"=",
"offset",
"||",
"0",
";",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"attrStart",
"=",
"-",
"1",
",",
"attrName",
"=",
"''",
",",
"attrValue",
... | Creates possible selection ranges for HTML tag
@param {String} source Original HTML source for tokens
@param {Array} tokens List of HTML tokens
@returns {Array} | [
"Creates",
"possible",
"selection",
"ranges",
"for",
"HTML",
"tag"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/selectItem.js#L101-L159 | train |
emmetio/emmet | lib/action/selectItem.js | getRangeForHTMLItem | function getRangeForHTMLItem(tag, offset, selRange, isBackward) {
var ranges = makePossibleRangesHTML(tag, xmlParser.parse(tag), offset);
if (isBackward)
ranges.reverse();
// try to find selected range
var curRange = utils.find(ranges, function(r) {
return r.equal(selRange);
});
if (curRange)... | javascript | function getRangeForHTMLItem(tag, offset, selRange, isBackward) {
var ranges = makePossibleRangesHTML(tag, xmlParser.parse(tag), offset);
if (isBackward)
ranges.reverse();
// try to find selected range
var curRange = utils.find(ranges, function(r) {
return r.equal(selRange);
});
if (curRange)... | [
"function",
"getRangeForHTMLItem",
"(",
"tag",
",",
"offset",
",",
"selRange",
",",
"isBackward",
")",
"{",
"var",
"ranges",
"=",
"makePossibleRangesHTML",
"(",
"tag",
",",
"xmlParser",
".",
"parse",
"(",
"tag",
")",
",",
"offset",
")",
";",
"if",
"(",
"... | Returns best HTML tag range match for current selection
@param {String} tag Tag declaration
@param {Number} offset Tag's position index inside content
@param {Range} selRange Selection range
@return {Range} Returns range if next item was found, <code>null</code> otherwise | [
"Returns",
"best",
"HTML",
"tag",
"range",
"match",
"for",
"current",
"selection"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/selectItem.js#L196-L238 | train |
emmetio/emmet | lib/action/selectItem.js | findOpeningTagFromPosition | function findOpeningTagFromPosition(html, pos) {
var tag;
while (pos >= 0) {
if ((tag = getOpeningTagFromPosition(html, pos)))
return tag;
pos--;
}
return null;
} | javascript | function findOpeningTagFromPosition(html, pos) {
var tag;
while (pos >= 0) {
if ((tag = getOpeningTagFromPosition(html, pos)))
return tag;
pos--;
}
return null;
} | [
"function",
"findOpeningTagFromPosition",
"(",
"html",
",",
"pos",
")",
"{",
"var",
"tag",
";",
"while",
"(",
"pos",
">=",
"0",
")",
"{",
"if",
"(",
"(",
"tag",
"=",
"getOpeningTagFromPosition",
"(",
"html",
",",
"pos",
")",
")",
")",
"return",
"tag",
... | Search for opening tag in content, starting at specified position
@param {String} html Where to search tag
@param {Number} pos Character index where to start searching
@return {Range} Returns range if valid opening tag was found,
<code>null</code> otherwise | [
"Search",
"for",
"opening",
"tag",
"in",
"content",
"starting",
"at",
"specified",
"position"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/selectItem.js#L247-L256 | train |
emmetio/emmet | lib/action/selectItem.js | findInnerRanges | function findInnerRanges(rule) {
// rule selector
var ranges = [rule.nameRange(true)];
// find nested sections, keep selectors only
var nestedSections = cssSections.nestedSectionsInRule(rule);
nestedSections.forEach(function(section) {
ranges.push(range.create2(section.start, section._selectorEnd));
});... | javascript | function findInnerRanges(rule) {
// rule selector
var ranges = [rule.nameRange(true)];
// find nested sections, keep selectors only
var nestedSections = cssSections.nestedSectionsInRule(rule);
nestedSections.forEach(function(section) {
ranges.push(range.create2(section.start, section._selectorEnd));
});... | [
"function",
"findInnerRanges",
"(",
"rule",
")",
"{",
"// rule selector",
"var",
"ranges",
"=",
"[",
"rule",
".",
"nameRange",
"(",
"true",
")",
"]",
";",
"// find nested sections, keep selectors only",
"var",
"nestedSections",
"=",
"cssSections",
".",
"nestedSectio... | Returns all ranges inside given rule, available for selection
@param {CSSEditContainer} rule
@return {Array} | [
"Returns",
"all",
"ranges",
"inside",
"given",
"rule",
"available",
"for",
"selection"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/selectItem.js#L280-L304 | train |
emmetio/emmet | lib/action/selectItem.js | matchedRangeForCSSProperty | function matchedRangeForCSSProperty(rule, selRange, isBackward) {
var ranges = findInnerRanges(rule);
if (isBackward) {
ranges.reverse();
}
// return next to selected range, if possible
var r = utils.find(ranges, function(item) {
return item.equal(selRange);
});
if (r) {
return ranges[ranges.... | javascript | function matchedRangeForCSSProperty(rule, selRange, isBackward) {
var ranges = findInnerRanges(rule);
if (isBackward) {
ranges.reverse();
}
// return next to selected range, if possible
var r = utils.find(ranges, function(item) {
return item.equal(selRange);
});
if (r) {
return ranges[ranges.... | [
"function",
"matchedRangeForCSSProperty",
"(",
"rule",
",",
"selRange",
",",
"isBackward",
")",
"{",
"var",
"ranges",
"=",
"findInnerRanges",
"(",
"rule",
")",
";",
"if",
"(",
"isBackward",
")",
"{",
"ranges",
".",
"reverse",
"(",
")",
";",
"}",
"// return... | Tries to find matched CSS property and nearest range for selection
@param {CSSRule} rule
@param {Range} selRange
@param {Boolean} isBackward
@returns {Range} | [
"Tries",
"to",
"find",
"matched",
"CSS",
"property",
"and",
"nearest",
"range",
"for",
"selection"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/selectItem.js#L356-L395 | train |
emmetio/emmet | lib/action/updateTag.js | function(editor, abbr) {
abbr = abbr || editor.prompt("Enter abbreviation");
if (!abbr) {
return false;
}
var content = editor.getContent();
var ctx = actionUtils.captureContext(editor);
var tag = this.getUpdatedTag(abbr, ctx, content);
if (!tag) {
// nothing to update
return false;
... | javascript | function(editor, abbr) {
abbr = abbr || editor.prompt("Enter abbreviation");
if (!abbr) {
return false;
}
var content = editor.getContent();
var ctx = actionUtils.captureContext(editor);
var tag = this.getUpdatedTag(abbr, ctx, content);
if (!tag) {
// nothing to update
return false;
... | [
"function",
"(",
"editor",
",",
"abbr",
")",
"{",
"abbr",
"=",
"abbr",
"||",
"editor",
".",
"prompt",
"(",
"\"Enter abbreviation\"",
")",
";",
"if",
"(",
"!",
"abbr",
")",
"{",
"return",
"false",
";",
"}",
"var",
"content",
"=",
"editor",
".",
"getCo... | Matches HTML tag under caret and updates its definition
according to given abbreviation
@param {IEmmetEditor} Editor instance
@param {String} abbr Abbreviation to update with | [
"Matches",
"HTML",
"tag",
"under",
"caret",
"and",
"updates",
"its",
"definition",
"according",
"to",
"given",
"abbreviation"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/updateTag.js#L75-L98 | train | |
emmetio/emmet | lib/action/updateTag.js | function(abbr, ctx, content, options) {
if (!ctx) {
// nothing to update
return null;
}
var tree = parser.parse(abbr, options || {});
// for this action some characters in abbreviation has special
// meaning. For example, `.-c2` means “remove `c2` class from
// element” and `.+c3` means “app... | javascript | function(abbr, ctx, content, options) {
if (!ctx) {
// nothing to update
return null;
}
var tree = parser.parse(abbr, options || {});
// for this action some characters in abbreviation has special
// meaning. For example, `.-c2` means “remove `c2` class from
// element” and `.+c3` means “app... | [
"function",
"(",
"abbr",
",",
"ctx",
",",
"content",
",",
"options",
")",
"{",
"if",
"(",
"!",
"ctx",
")",
"{",
"// nothing to update",
"return",
"null",
";",
"}",
"var",
"tree",
"=",
"parser",
".",
"parse",
"(",
"abbr",
",",
"options",
"||",
"{",
... | Returns XMLEditContainer node with updated tag structure
of existing tag context.
This data can be used to modify existing tag
@param {String} abbr Abbreviation
@param {Object} ctx Tag to be updated (captured with `htmlMatcher`)
@param {String} content Original editor content
@return {XMLEditContainer} | [
"Returns",
"XMLEditContainer",
"node",
"with",
"updated",
"tag",
"structure",
"of",
"existing",
"tag",
"context",
".",
"This",
"data",
"can",
"be",
"used",
"to",
"modify",
"existing",
"tag"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/updateTag.js#L109-L141 | train | |
emmetio/emmet | lib/action/base64.js | encodeToBase64 | function encodeToBase64(editor, imgPath, pos) {
var editorFile = editor.getFilePath();
var defaultMimeType = 'application/octet-stream';
if (editorFile === null) {
throw "You should save your file before using this action";
}
// locate real image path
file.locateFile(editorFile, imgPath, function(realI... | javascript | function encodeToBase64(editor, imgPath, pos) {
var editorFile = editor.getFilePath();
var defaultMimeType = 'application/octet-stream';
if (editorFile === null) {
throw "You should save your file before using this action";
}
// locate real image path
file.locateFile(editorFile, imgPath, function(realI... | [
"function",
"encodeToBase64",
"(",
"editor",
",",
"imgPath",
",",
"pos",
")",
"{",
"var",
"editorFile",
"=",
"editor",
".",
"getFilePath",
"(",
")",
";",
"var",
"defaultMimeType",
"=",
"'application/octet-stream'",
";",
"if",
"(",
"editorFile",
"===",
"null",
... | Encodes image to base64
@param {IEmmetEditor} editor
@param {String} imgPath Path to image
@param {Number} pos Caret position where image is located in the editor
@return {Boolean} | [
"Encodes",
"image",
"to",
"base64"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/base64.js#L39-L71 | train |
emmetio/emmet | lib/action/base64.js | decodeFromBase64 | function decodeFromBase64(editor, filePath, data, pos) {
// ask user to enter path to file
filePath = filePath || String(editor.prompt('Enter path to file (absolute or relative)'));
if (!filePath) {
return false;
}
var editorFile = editor.getFilePath();
file.createPath(editorFile, filePath, function(err... | javascript | function decodeFromBase64(editor, filePath, data, pos) {
// ask user to enter path to file
filePath = filePath || String(editor.prompt('Enter path to file (absolute or relative)'));
if (!filePath) {
return false;
}
var editorFile = editor.getFilePath();
file.createPath(editorFile, filePath, function(err... | [
"function",
"decodeFromBase64",
"(",
"editor",
",",
"filePath",
",",
"data",
",",
"pos",
")",
"{",
"// ask user to enter path to file",
"filePath",
"=",
"filePath",
"||",
"String",
"(",
"editor",
".",
"prompt",
"(",
"'Enter path to file (absolute or relative)'",
")",
... | Decodes base64 string back to file.
@param {IEmmetEditor} editor
@param {String} filePath to new image
@param {String} data Base64-encoded file content
@param {Number} pos Caret position where image is located in the editor | [
"Decodes",
"base64",
"string",
"back",
"to",
"file",
"."
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/base64.js#L80-L104 | train |
emmetio/emmet | lib/action/balance.js | getCSSRanges | function getCSSRanges(content, pos) {
var rule;
if (typeof content === 'string') {
var ruleRange = cssSections.matchEnclosingRule(content, pos);
if (ruleRange) {
rule = cssEditTree.parse(ruleRange.substring(content), {
offset: ruleRange.start
});
}
} else {
// passed parsed CSS rule
ru... | javascript | function getCSSRanges(content, pos) {
var rule;
if (typeof content === 'string') {
var ruleRange = cssSections.matchEnclosingRule(content, pos);
if (ruleRange) {
rule = cssEditTree.parse(ruleRange.substring(content), {
offset: ruleRange.start
});
}
} else {
// passed parsed CSS rule
ru... | [
"function",
"getCSSRanges",
"(",
"content",
",",
"pos",
")",
"{",
"var",
"rule",
";",
"if",
"(",
"typeof",
"content",
"===",
"'string'",
")",
"{",
"var",
"ruleRange",
"=",
"cssSections",
".",
"matchEnclosingRule",
"(",
"content",
",",
"pos",
")",
";",
"i... | Returns all possible selection ranges for given caret position
@param {String} content CSS content
@param {Number} pos Caret position(where to start searching)
@return {Array} | [
"Returns",
"all",
"possible",
"selection",
"ranges",
"for",
"given",
"caret",
"position"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/balance.js#L138-L167 | train |
emmetio/emmet | lib/action/balance.js | function(editor, direction) {
direction = String((direction || 'out').toLowerCase());
var info = editorUtils.outputInfo(editor);
if (actionUtils.isSupportedCSS(info.syntax)) {
return balanceCSS(editor, direction);
}
return balanceHTML(editor, direction);
} | javascript | function(editor, direction) {
direction = String((direction || 'out').toLowerCase());
var info = editorUtils.outputInfo(editor);
if (actionUtils.isSupportedCSS(info.syntax)) {
return balanceCSS(editor, direction);
}
return balanceHTML(editor, direction);
} | [
"function",
"(",
"editor",
",",
"direction",
")",
"{",
"direction",
"=",
"String",
"(",
"(",
"direction",
"||",
"'out'",
")",
".",
"toLowerCase",
"(",
")",
")",
";",
"var",
"info",
"=",
"editorUtils",
".",
"outputInfo",
"(",
"editor",
")",
";",
"if",
... | Find and select HTML tag pair
@param {IEmmetEditor} editor Editor instance
@param {String} direction Direction of pair matching: 'in' or 'out'.
Default is 'out' | [
"Find",
"and",
"select",
"HTML",
"tag",
"pair"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/action/balance.js#L252-L260 | train | |
emmetio/emmet | lib/resolver/cssGradient.js | getGradientPrefixes | function getGradientPrefixes(type) {
var prefixes = cssResolver.vendorPrefixes(type);
if (!prefixes) {
// disabled Can I Use, fallback to property list
prefixes = prefs.getArray('css.gradient.prefixes');
}
return prefixes || [];
} | javascript | function getGradientPrefixes(type) {
var prefixes = cssResolver.vendorPrefixes(type);
if (!prefixes) {
// disabled Can I Use, fallback to property list
prefixes = prefs.getArray('css.gradient.prefixes');
}
return prefixes || [];
} | [
"function",
"getGradientPrefixes",
"(",
"type",
")",
"{",
"var",
"prefixes",
"=",
"cssResolver",
".",
"vendorPrefixes",
"(",
"type",
")",
";",
"if",
"(",
"!",
"prefixes",
")",
"{",
"// disabled Can I Use, fallback to property list",
"prefixes",
"=",
"prefs",
".",
... | Returns vendor prefixes for given gradient type
@param {String} type Gradient type (currently, 'linear-gradient'
is the only supported value)
@return {Array} | [
"Returns",
"vendor",
"prefixes",
"for",
"given",
"gradient",
"type"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/resolver/cssGradient.js#L71-L79 | train |
emmetio/emmet | lib/resolver/cssGradient.js | getPropertiesForGradient | function getPropertiesForGradient(gradients, property) {
var props = [];
var propertyName = property.name();
var omitDir = prefs.get('css.gradient.omitDefaultDirection');
if (prefs.get('css.gradient.fallback') && ~propertyName.toLowerCase().indexOf('background')) {
props.push({
name: 'background-color... | javascript | function getPropertiesForGradient(gradients, property) {
var props = [];
var propertyName = property.name();
var omitDir = prefs.get('css.gradient.omitDefaultDirection');
if (prefs.get('css.gradient.fallback') && ~propertyName.toLowerCase().indexOf('background')) {
props.push({
name: 'background-color... | [
"function",
"getPropertiesForGradient",
"(",
"gradients",
",",
"property",
")",
"{",
"var",
"props",
"=",
"[",
"]",
";",
"var",
"propertyName",
"=",
"property",
".",
"name",
"(",
")",
";",
"var",
"omitDir",
"=",
"prefs",
".",
"get",
"(",
"'css.gradient.omi... | Returns list of CSS properties with gradient
@param {Array} gradient List of gradient objects
@param {CSSEditElement} property Original CSS property
@returns {Array} | [
"Returns",
"list",
"of",
"CSS",
"properties",
"with",
"gradient"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/resolver/cssGradient.js#L100-L140 | train |
emmetio/emmet | lib/resolver/cssGradient.js | insertGradientsIntoCSSValue | function insertGradientsIntoCSSValue(gradients, value, options) {
// gradients *should* passed in order they actually appear in CSS property
// iterate over it in backward direction to preserve gradient locations
options = options || {};
gradients = utils.clone(gradients);
gradients.reverse().forEach(function... | javascript | function insertGradientsIntoCSSValue(gradients, value, options) {
// gradients *should* passed in order they actually appear in CSS property
// iterate over it in backward direction to preserve gradient locations
options = options || {};
gradients = utils.clone(gradients);
gradients.reverse().forEach(function... | [
"function",
"insertGradientsIntoCSSValue",
"(",
"gradients",
",",
"value",
",",
"options",
")",
"{",
"// gradients *should* passed in order they actually appear in CSS property",
"// iterate over it in backward direction to preserve gradient locations",
"options",
"=",
"options",
"||",... | Replaces old gradient definitions in given CSS property value
with new ones, preserving original formatting
@param {Array} gradients List of CSS gradients
@param {String} value Original CSS value
@param {Object} options Options for gradient’s stringify() method
@return {String} | [
"Replaces",
"old",
"gradient",
"definitions",
"in",
"given",
"CSS",
"property",
"value",
"with",
"new",
"ones",
"preserving",
"original",
"formatting"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/resolver/cssGradient.js#L150-L162 | train |
emmetio/emmet | lib/resolver/cssGradient.js | pasteGradient | function pasteGradient(property, gradients) {
var rule = property.parent;
var alignVendor = prefs.get('css.alignVendor');
var omitDir = prefs.get('css.gradient.omitDefaultDirection');
// we may have aligned gradient definitions: find the smallest value
// separator
var sep = property.styleSeparator;
va... | javascript | function pasteGradient(property, gradients) {
var rule = property.parent;
var alignVendor = prefs.get('css.alignVendor');
var omitDir = prefs.get('css.gradient.omitDefaultDirection');
// we may have aligned gradient definitions: find the smallest value
// separator
var sep = property.styleSeparator;
va... | [
"function",
"pasteGradient",
"(",
"property",
",",
"gradients",
")",
"{",
"var",
"rule",
"=",
"property",
".",
"parent",
";",
"var",
"alignVendor",
"=",
"prefs",
".",
"get",
"(",
"'css.alignVendor'",
")",
";",
"var",
"omitDir",
"=",
"prefs",
".",
"get",
... | Pastes gradient definition into CSS rule with correct vendor-prefixes
@param {EditElement} property Matched CSS property
@param {Array} gradients List of gradients to insert | [
"Pastes",
"gradient",
"definition",
"into",
"CSS",
"rule",
"with",
"correct",
"vendor",
"-",
"prefixes"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/resolver/cssGradient.js#L187-L266 | train |
emmetio/emmet | lib/resolver/cssGradient.js | function(cssProp) {
var value = cssProp.value();
var gradients = [];
var that = this;
cssProp.valueParts().forEach(function(part) {
var partValue = part.substring(value);
if (linearGradient.isLinearGradient(partValue)) {
var gradient = linearGradient.parse(partValue);
if (gradient) {
... | javascript | function(cssProp) {
var value = cssProp.value();
var gradients = [];
var that = this;
cssProp.valueParts().forEach(function(part) {
var partValue = part.substring(value);
if (linearGradient.isLinearGradient(partValue)) {
var gradient = linearGradient.parse(partValue);
if (gradient) {
... | [
"function",
"(",
"cssProp",
")",
"{",
"var",
"value",
"=",
"cssProp",
".",
"value",
"(",
")",
";",
"var",
"gradients",
"=",
"[",
"]",
";",
"var",
"that",
"=",
"this",
";",
"cssProp",
".",
"valueParts",
"(",
")",
".",
"forEach",
"(",
"function",
"("... | Search for gradient definitions inside CSS property value
@returns {Array} Array of matched gradients | [
"Search",
"for",
"gradient",
"definitions",
"inside",
"CSS",
"property",
"value"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/resolver/cssGradient.js#L307-L325 | train | |
emmetio/emmet | lib/resolver/cssGradient.js | function(editor, syntax) {
var propertyName = prefs.get('css.gradient.defaultProperty');
var omitDir = prefs.get('css.gradient.omitDefaultDirection');
if (!propertyName) {
return false;
}
// assuming that gradient definition is written on new line,
// do a simplified parsing
var content... | javascript | function(editor, syntax) {
var propertyName = prefs.get('css.gradient.defaultProperty');
var omitDir = prefs.get('css.gradient.omitDefaultDirection');
if (!propertyName) {
return false;
}
// assuming that gradient definition is written on new line,
// do a simplified parsing
var content... | [
"function",
"(",
"editor",
",",
"syntax",
")",
"{",
"var",
"propertyName",
"=",
"prefs",
".",
"get",
"(",
"'css.gradient.defaultProperty'",
")",
";",
"var",
"omitDir",
"=",
"prefs",
".",
"get",
"(",
"'css.gradient.omitDefaultDirection'",
")",
";",
"if",
"(",
... | Tries to expand gradient outside CSS value
@param {IEmmetEditor} editor
@param {String} syntax | [
"Tries",
"to",
"expand",
"gradient",
"outside",
"CSS",
"value"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/resolver/cssGradient.js#L416-L475 | train | |
emmetio/emmet | lib/assets/handlerList.js | function(fn, options) {
// TODO hack for stable sort, remove after fixing `list()`
var order = this._list.length;
if (options && 'order' in options) {
order = options.order * 10000;
}
this._list.push(utils.extend({}, options, {order: order, fn: fn}));
} | javascript | function(fn, options) {
// TODO hack for stable sort, remove after fixing `list()`
var order = this._list.length;
if (options && 'order' in options) {
order = options.order * 10000;
}
this._list.push(utils.extend({}, options, {order: order, fn: fn}));
} | [
"function",
"(",
"fn",
",",
"options",
")",
"{",
"// TODO hack for stable sort, remove after fixing `list()`",
"var",
"order",
"=",
"this",
".",
"_list",
".",
"length",
";",
"if",
"(",
"options",
"&&",
"'order'",
"in",
"options",
")",
"{",
"order",
"=",
"optio... | Adds function handler
@param {Function} fn Handler
@param {Object} options Handler options. Possible values are:<br><br>
<b>order</b> : (<code>Number</code>) – order in handler list. Handlers
with higher order value will be executed earlier. | [
"Adds",
"function",
"handler"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/assets/handlerList.js#L32-L39 | train | |
emmetio/emmet | lib/assets/handlerList.js | function(fn) {
var item = utils.find(this._list, function(item) {
return item.fn === fn;
});
if (item) {
this._list.splice(this._list.indexOf(item), 1);
}
} | javascript | function(fn) {
var item = utils.find(this._list, function(item) {
return item.fn === fn;
});
if (item) {
this._list.splice(this._list.indexOf(item), 1);
}
} | [
"function",
"(",
"fn",
")",
"{",
"var",
"item",
"=",
"utils",
".",
"find",
"(",
"this",
".",
"_list",
",",
"function",
"(",
"item",
")",
"{",
"return",
"item",
".",
"fn",
"===",
"fn",
";",
"}",
")",
";",
"if",
"(",
"item",
")",
"{",
"this",
"... | Removes handler from list
@param {Function} fn | [
"Removes",
"handler",
"from",
"list"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/assets/handlerList.js#L45-L52 | train | |
emmetio/emmet | lib/emmet.js | getFileName | function getFileName(path) {
var re = /([\w\.\-]+)$/i;
var m = re.exec(path);
return m ? m[1] : '';
} | javascript | function getFileName(path) {
var re = /([\w\.\-]+)$/i;
var m = re.exec(path);
return m ? m[1] : '';
} | [
"function",
"getFileName",
"(",
"path",
")",
"{",
"var",
"re",
"=",
"/",
"([\\w\\.\\-]+)$",
"/",
"i",
";",
"var",
"m",
"=",
"re",
".",
"exec",
"(",
"path",
")",
";",
"return",
"m",
"?",
"m",
"[",
"1",
"]",
":",
"''",
";",
"}"
] | Returns file name part from path
@param {String} path Path to file
@return {String} | [
"Returns",
"file",
"name",
"part",
"from",
"path"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/emmet.js#L28-L32 | train |
emmetio/emmet | lib/emmet.js | function(abbr, syntax, profile, contextNode) {
return parser.expand(abbr, {
syntax: syntax,
profile: profile,
contextNode: contextNode
});
} | javascript | function(abbr, syntax, profile, contextNode) {
return parser.expand(abbr, {
syntax: syntax,
profile: profile,
contextNode: contextNode
});
} | [
"function",
"(",
"abbr",
",",
"syntax",
",",
"profile",
",",
"contextNode",
")",
"{",
"return",
"parser",
".",
"expand",
"(",
"abbr",
",",
"{",
"syntax",
":",
"syntax",
",",
"profile",
":",
"profile",
",",
"contextNode",
":",
"contextNode",
"}",
")",
"... | The essential function that expands Emmet abbreviation
@param {String} abbr Abbreviation to parse
@param {String} syntax Abbreviation's context syntax
@param {String} profile Output profile (or its name)
@param {Object} contextNode Contextual node where abbreviation is
written
@return {String} | [
"The",
"essential",
"function",
"that",
"expands",
"Emmet",
"abbreviation"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/emmet.js#L66-L72 | train | |
emmetio/emmet | lib/emmet.js | function(profiles) {
profiles = utils.parseJSON(profiles);
var snippets = {};
Object.keys(profiles).forEach(function(syntax) {
var options = profiles[syntax];
if (!(syntax in snippets)) {
snippets[syntax] = {};
}
snippets[syntax].profile = normalizeProfile(options);
});
this.loadSni... | javascript | function(profiles) {
profiles = utils.parseJSON(profiles);
var snippets = {};
Object.keys(profiles).forEach(function(syntax) {
var options = profiles[syntax];
if (!(syntax in snippets)) {
snippets[syntax] = {};
}
snippets[syntax].profile = normalizeProfile(options);
});
this.loadSni... | [
"function",
"(",
"profiles",
")",
"{",
"profiles",
"=",
"utils",
".",
"parseJSON",
"(",
"profiles",
")",
";",
"var",
"snippets",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"profiles",
")",
".",
"forEach",
"(",
"function",
"(",
"syntax",
")",
"{"... | Load syntax-specific output profiles. These are essentially
an extension to syntax snippets
@param {Object} profiles Dictionary of profiles | [
"Load",
"syntax",
"-",
"specific",
"output",
"profiles",
".",
"These",
"are",
"essentially",
"an",
"extension",
"to",
"syntax",
"snippets"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/emmet.js#L248-L260 | train | |
emmetio/emmet | lib/emmet.js | function(profiles) {
profiles = utils.parseJSON(profiles);
Object.keys(profiles).forEach(function(name) {
profile.create(name, normalizeProfile(profiles[name]));
});
} | javascript | function(profiles) {
profiles = utils.parseJSON(profiles);
Object.keys(profiles).forEach(function(name) {
profile.create(name, normalizeProfile(profiles[name]));
});
} | [
"function",
"(",
"profiles",
")",
"{",
"profiles",
"=",
"utils",
".",
"parseJSON",
"(",
"profiles",
")",
";",
"Object",
".",
"keys",
"(",
"profiles",
")",
".",
"forEach",
"(",
"function",
"(",
"name",
")",
"{",
"profile",
".",
"create",
"(",
"name",
... | Load named profiles
@param {Object} profiles | [
"Load",
"named",
"profiles"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/emmet.js#L266-L271 | train | |
emmetio/emmet | lib/utils/abbreviation.js | function(node) {
return (this.hasTagsInContent(node) && this.isBlock(node))
|| node.children.some(function(child) {
return this.isBlock(child);
}, this);
} | javascript | function(node) {
return (this.hasTagsInContent(node) && this.isBlock(node))
|| node.children.some(function(child) {
return this.isBlock(child);
}, this);
} | [
"function",
"(",
"node",
")",
"{",
"return",
"(",
"this",
".",
"hasTagsInContent",
"(",
"node",
")",
"&&",
"this",
".",
"isBlock",
"(",
"node",
")",
")",
"||",
"node",
".",
"children",
".",
"some",
"(",
"function",
"(",
"child",
")",
"{",
"return",
... | Test if current element contains block-level children
@param {AbbreviationNode} node
@return {Boolean} | [
"Test",
"if",
"current",
"element",
"contains",
"block",
"-",
"level",
"children"
] | 7c9a4623cea414c2f2cc9caebc13355d2bbd898d | https://github.com/emmetio/emmet/blob/7c9a4623cea414c2f2cc9caebc13355d2bbd898d/lib/utils/abbreviation.js#L77-L82 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.