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.

index.cjs 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. const util_1 = require("../util.cjs");
  6. const block_parser_1 = require("./block-parser.cjs");
  7. const source_parser_1 = require("./source-parser.cjs");
  8. const spec_parser_1 = require("./spec-parser.cjs");
  9. const tag_1 = require("./tokenizers/tag.cjs");
  10. const type_1 = require("./tokenizers/type.cjs");
  11. const name_1 = require("./tokenizers/name.cjs");
  12. const description_1 = require("./tokenizers/description.cjs");
  13. function getParser({
  14. startLine = 0,
  15. fence = '```',
  16. spacing = 'compact',
  17. tokenizers = [tag_1.default(), type_1.default(spacing), name_1.default(), description_1.default(spacing)]
  18. } = {}) {
  19. if (startLine < 0 || startLine % 1 > 0) throw new Error('Invalid startLine');
  20. const parseSource = source_parser_1.default({
  21. startLine
  22. });
  23. const parseBlock = block_parser_1.default({
  24. fence
  25. });
  26. const parseSpec = spec_parser_1.default({
  27. tokenizers
  28. });
  29. const joinDescription = description_1.getJoiner(spacing);
  30. const notEmpty = line => line.tokens.description.trim() != '';
  31. return function (source) {
  32. const blocks = [];
  33. for (const line of util_1.splitLines(source)) {
  34. const lines = parseSource(line);
  35. if (lines === null) continue;
  36. if (lines.find(notEmpty) === undefined) continue;
  37. const sections = parseBlock(lines);
  38. const specs = sections.slice(1).map(parseSpec);
  39. blocks.push({
  40. description: joinDescription(sections[0]),
  41. tags: specs,
  42. source: lines,
  43. problems: specs.reduce((acc, spec) => acc.concat(spec.problems), [])
  44. });
  45. }
  46. return blocks;
  47. };
  48. }
  49. exports.default = getParser;
  50. //# sourceMappingURL=index.cjs.map