Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

inline-comment.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* eslint-disable no-param-reassign */
  2. const tokenizer = require('postcss/lib/tokenize');
  3. const Input = require('postcss/lib/input');
  4. module.exports = {
  5. isInlineComment(token) {
  6. if (token[0] === 'word' && token[1].slice(0, 2) === '//') {
  7. const first = token;
  8. const bits = [];
  9. let last;
  10. while (token) {
  11. if (/\r?\n/.test(token[1])) {
  12. // If there are quotes, fix tokenizer creating one token from start quote to end quote
  13. if (/['"].*\r?\n/.test(token[1])) {
  14. // Add string before newline to inline comment token
  15. bits.push(token[1].substring(0, token[1].indexOf('\n')));
  16. // Get remaining input and retokenize
  17. let remainingInput = token[1].substring(token[1].indexOf('\n'));
  18. remainingInput += this.input.css.valueOf().substring(this.tokenizer.position());
  19. // Replace tokenizer to retokenize the rest of the string
  20. this.input = new Input(remainingInput);
  21. this.tokenizer = tokenizer(this.input);
  22. } else {
  23. // If the tokenizer went to the next line go back
  24. this.tokenizer.back(token);
  25. }
  26. break;
  27. }
  28. bits.push(token[1]);
  29. last = token;
  30. token = this.tokenizer.nextToken({ ignoreUnclosed: true });
  31. }
  32. const newToken = ['comment', bits.join(''), first[2], first[3], last[2], last[3]];
  33. this.inlineComment(newToken);
  34. return true;
  35. } else if (token[1] === '/') {
  36. // issue #135
  37. const next = this.tokenizer.nextToken({ ignoreUnclosed: true });
  38. if (next[0] === 'comment' && /^\/\*/.test(next[1])) {
  39. next[0] = 'word';
  40. next[1] = next[1].slice(1);
  41. token[1] = '//';
  42. this.tokenizer.back(next);
  43. return module.exports.isInlineComment.bind(this)(token);
  44. }
  45. }
  46. return false;
  47. }
  48. };