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.

block-parser.js 938B

1234567891011121314151617181920212223242526272829
  1. const reTag = /^@\S+/;
  2. /**
  3. * Creates configured `Parser`
  4. * @param {Partial<Options>} options
  5. */
  6. export default function getParser({ fence = '```', } = {}) {
  7. const fencer = getFencer(fence);
  8. const toggleFence = (source, isFenced) => fencer(source) ? !isFenced : isFenced;
  9. return function parseBlock(source) {
  10. // start with description section
  11. const sections = [[]];
  12. let isFenced = false;
  13. for (const line of source) {
  14. if (reTag.test(line.tokens.description) && !isFenced) {
  15. sections.push([line]);
  16. }
  17. else {
  18. sections[sections.length - 1].push(line);
  19. }
  20. isFenced = toggleFence(line.tokens.description, isFenced);
  21. }
  22. return sections;
  23. };
  24. }
  25. function getFencer(fence) {
  26. if (typeof fence === 'string')
  27. return (source) => source.split(fence).length % 2 === 0;
  28. return fence;
  29. }