зеркало из https://github.com/telerik/dss.git
fix(parsing): allow usage of '@' in blocks
This commit is contained in:
Родитель
40faa1753b
Коммит
827ca613f2
4
dss.js
4
dss.js
|
@ -215,7 +215,7 @@ let dss = ( function() {
|
|||
let indexer = function( str, find ) {
|
||||
return ( str.indexOf( find ) > 0 ) ? str.indexOf( find ) : false;
|
||||
};
|
||||
let parts = line.replace( /.*@/, '' );
|
||||
let parts = line.replace( /[^@]*@/, '' );
|
||||
let i = indexer( parts, ' ' ) || indexer( parts, '\n' ) || indexer( parts, '\r' ) || parts.length;
|
||||
let name = _dss.trim( parts.substr( 0, i ) );
|
||||
let description = _dss.trim( parts.substr( i ) );
|
||||
|
@ -385,7 +385,7 @@ let dss = ( function() {
|
|||
/* eslint-disable no-param-reassign */
|
||||
// find the next instance of a parser (if there is one based on the @ symbol)
|
||||
// in order to isolate the current multi-line parser
|
||||
let nextParserIndex = block.indexOf('@', i + 1);
|
||||
let nextParserIndex = block.indexOf('\n @', i + 1);
|
||||
let markupLength = (nextParserIndex > -1) ? nextParserIndex - i : block.length;
|
||||
let markup = _dss.trim(block.split('').splice(i, markupLength).join(''));
|
||||
let parserMarker = '@' + parserName;
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
/// @description Your standard description with an @ in it
|
||||
/// second row test
|
||||
/// @name Special character "@" description test.
|
11
test/test.js
11
test/test.js
|
@ -65,6 +65,17 @@ describe('Core tests', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('description with the @ symbol is correctly parsed', function() {
|
||||
const file = fs.readFileSync(path.join(__dirname, 'data/description-with-special-symbol.scss'), 'utf8');
|
||||
|
||||
dss.parse(file, {}, function(parsed) {
|
||||
const data = parsed.blocks[0];
|
||||
|
||||
assert.strictEqual(data.name, 'Special character "@" description test.');
|
||||
assert.strictEqual(data.description, 'Your standard description with an @ in it\nsecond row test');
|
||||
});
|
||||
});
|
||||
|
||||
it('should should parse all annotations', function() {
|
||||
const file = fs.readFileSync(path.join(__dirname, 'data/all-annotations.scss'), 'utf8');
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче