(token: Token, type: string)
| 34 | } |
| 35 | |
| 36 | function handleAttrs(token: Token, type: string) { |
| 37 | switch (type) { |
| 38 | case 'heading': |
| 39 | return { level: Number(token.tag.replace('h', '')) }; |
| 40 | case 'list': { |
| 41 | const attrs = token.attrs ? Object.fromEntries(token.attrs) : undefined; |
| 42 | const ordered = token.type.startsWith('ordered'); |
| 43 | return ordered && attrs?.start |
| 44 | ? { ordered: true, start: attrs.start, marker: token.markup } |
| 45 | : { ordered, marker: token.markup }; |
| 46 | } |
| 47 | case 'link': { |
| 48 | const attrs = Object.fromEntries(token.attrs); |
| 49 | return attrs.title |
| 50 | ? { href: attrs.href, title: attrs.title } |
| 51 | : { href: attrs.href }; |
| 52 | } |
| 53 | case 'image': { |
| 54 | const attrs = Object.fromEntries(token.attrs); |
| 55 | return attrs.title |
| 56 | ? { alt: token.content, src: attrs.src, title: attrs.title } |
| 57 | : { alt: token.content, src: attrs.src }; |
| 58 | } |
| 59 | case 'em': |
| 60 | case 'strong': |
| 61 | return { marker: token.markup }; |
| 62 | case 'text': |
| 63 | case 'code': |
| 64 | case 'comment': |
| 65 | return { content: (token.meta || {}).variable || token.content }; |
| 66 | case 'fence': { |
| 67 | const [language] = token.info.split(' ', 1); |
| 68 | return language === '' || language === OPEN |
| 69 | ? { content: token.content } |
| 70 | : { content: token.content, language }; |
| 71 | } |
| 72 | case 'td': |
| 73 | case 'th': { |
| 74 | if (token.attrs) { |
| 75 | const attrs = Object.fromEntries(token.attrs); |
| 76 | |
| 77 | let align; |
| 78 | if (attrs.style) { |
| 79 | if (attrs.style.includes('left')) { |
| 80 | align = 'left'; |
| 81 | } else if (attrs.style.includes('center')) { |
| 82 | align = 'center'; |
| 83 | } else if (attrs.style.includes('right')) { |
| 84 | align = 'right'; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | if (align) { |
| 89 | return { align }; |
| 90 | } |
| 91 | } |
| 92 | return {}; |
| 93 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…