42 lines
No EOL
1.2 KiB
JavaScript
42 lines
No EOL
1.2 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.getQuote = exports.quotes = void 0;
|
|
var parser_1 = require("../syntax/parser");
|
|
exports.quotes = {
|
|
name: 'quotes',
|
|
initialValue: 'none',
|
|
prefix: true,
|
|
type: 1 /* LIST */,
|
|
parse: function (_context, tokens) {
|
|
if (tokens.length === 0) {
|
|
return null;
|
|
}
|
|
var first = tokens[0];
|
|
if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
|
|
return null;
|
|
}
|
|
var quotes = [];
|
|
var filtered = tokens.filter(parser_1.isStringToken);
|
|
if (filtered.length % 2 !== 0) {
|
|
return null;
|
|
}
|
|
for (var i = 0; i < filtered.length; i += 2) {
|
|
var open_1 = filtered[i].value;
|
|
var close_1 = filtered[i + 1].value;
|
|
quotes.push({ open: open_1, close: close_1 });
|
|
}
|
|
return quotes;
|
|
}
|
|
};
|
|
var getQuote = function (quotes, depth, open) {
|
|
if (!quotes) {
|
|
return '';
|
|
}
|
|
var quote = quotes[Math.min(depth, quotes.length - 1)];
|
|
if (!quote) {
|
|
return '';
|
|
}
|
|
return open ? quote.open : quote.close;
|
|
};
|
|
exports.getQuote = getQuote;
|
|
//# sourceMappingURL=quotes.js.map
|