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.

parse.js 940B

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. const parser = require("./parser");
  3. const processor = require("./processor");
  4. const getLang = require("./get-lang");
  5. const normalOpts = require("./normal-opts");
  6. function getSyntax (opts, source) {
  7. const rules = opts.syntax && opts.syntax.config && opts.syntax.config.rules;
  8. const file = opts.from || "";
  9. return (rules && rules.find(
  10. rule => rule.test.test ? rule.test.test(file) : rule.test(file, source)
  11. )) || getLang(file, source) || {
  12. lang: "css",
  13. };
  14. }
  15. function parse (source, opts) {
  16. source = source.toString();
  17. opts = normalOpts(opts, this);
  18. const syntax = getSyntax(opts, source);
  19. const syntaxOpts = Object.assign({}, opts, syntax.opts);
  20. let root;
  21. if (syntax.extract) {
  22. root = processor(source, syntax.extract, syntaxOpts);
  23. root.source.lang = syntax.extract;
  24. } else {
  25. root = parser(source, syntax.lang, syntaxOpts);
  26. root.source.lang = syntax.lang;
  27. }
  28. return root;
  29. }
  30. module.exports = parse;