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.

link.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. module.exports = link
  2. link.peek = linkPeek
  3. var checkQuote = require('../util/check-quote')
  4. var formatLinkAsAutolink = require('../util/format-link-as-autolink')
  5. var phrasing = require('../util/container-phrasing')
  6. var safe = require('../util/safe')
  7. function link(node, _, context) {
  8. var quote = checkQuote(context)
  9. var suffix = quote === '"' ? 'Quote' : 'Apostrophe'
  10. var exit
  11. var subexit
  12. var value
  13. var stack
  14. if (formatLinkAsAutolink(node, context)) {
  15. // Hide the fact that we’re in phrasing, because escapes don’t work.
  16. stack = context.stack
  17. context.stack = []
  18. exit = context.enter('autolink')
  19. value = '<' + phrasing(node, context, {before: '<', after: '>'}) + '>'
  20. exit()
  21. context.stack = stack
  22. return value
  23. }
  24. exit = context.enter('link')
  25. subexit = context.enter('label')
  26. value = '[' + phrasing(node, context, {before: '[', after: ']'}) + ']('
  27. subexit()
  28. if (
  29. // If there’s no url but there is a title…
  30. (!node.url && node.title) ||
  31. // Or if there’s markdown whitespace or an eol, enclose.
  32. /[ \t\r\n]/.test(node.url)
  33. ) {
  34. subexit = context.enter('destinationLiteral')
  35. value += '<' + safe(context, node.url, {before: '<', after: '>'}) + '>'
  36. } else {
  37. // No whitespace, raw is prettier.
  38. subexit = context.enter('destinationRaw')
  39. value += safe(context, node.url, {
  40. before: '(',
  41. after: node.title ? ' ' : ')'
  42. })
  43. }
  44. subexit()
  45. if (node.title) {
  46. subexit = context.enter('title' + suffix)
  47. value +=
  48. ' ' +
  49. quote +
  50. safe(context, node.title, {before: quote, after: quote}) +
  51. quote
  52. subexit()
  53. }
  54. value += ')'
  55. exit()
  56. return value
  57. }
  58. function linkPeek(node, _, context) {
  59. return formatLinkAsAutolink(node, context) ? '<' : '['
  60. }