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.

heading.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. module.exports = heading
  2. var repeat = require('repeat-string')
  3. var formatHeadingAsSetext = require('../util/format-heading-as-setext')
  4. var phrasing = require('../util/container-phrasing')
  5. function heading(node, _, context) {
  6. var rank = Math.max(Math.min(6, node.depth || 1), 1)
  7. var exit
  8. var subexit
  9. var value
  10. var sequence
  11. if (formatHeadingAsSetext(node, context)) {
  12. exit = context.enter('headingSetext')
  13. subexit = context.enter('phrasing')
  14. value = phrasing(node, context, {before: '\n', after: '\n'})
  15. subexit()
  16. exit()
  17. return (
  18. value +
  19. '\n' +
  20. repeat(
  21. rank === 1 ? '=' : '-',
  22. // The whole size…
  23. value.length -
  24. // Minus the position of the character after the last EOL (or
  25. // 0 if there is none)…
  26. (Math.max(value.lastIndexOf('\r'), value.lastIndexOf('\n')) + 1)
  27. )
  28. )
  29. }
  30. sequence = repeat('#', rank)
  31. exit = context.enter('headingAtx')
  32. subexit = context.enter('phrasing')
  33. value = phrasing(node, context, {before: '# ', after: '\n'})
  34. value = value ? sequence + ' ' + value : sequence
  35. if (context.options.closeAtx) {
  36. value += ' ' + sequence
  37. }
  38. subexit()
  39. exit()
  40. return value
  41. }