single and double emphasis parsing
(p *Markdown, data []byte, offset int)
| 84 | |
| 85 | // single and double emphasis parsing |
| 86 | func emphasis(p *Markdown, data []byte, offset int) (int, *Node) { |
| 87 | data = data[offset:] |
| 88 | c := data[0] |
| 89 | |
| 90 | if len(data) > 2 && data[1] != c { |
| 91 | // whitespace cannot follow an opening emphasis; |
| 92 | // strikethrough only takes two characters '~~' |
| 93 | if c == '~' || isspace(data[1]) { |
| 94 | return 0, nil |
| 95 | } |
| 96 | ret, node := helperEmphasis(p, data[1:], c) |
| 97 | if ret == 0 { |
| 98 | return 0, nil |
| 99 | } |
| 100 | |
| 101 | return ret + 1, node |
| 102 | } |
| 103 | |
| 104 | if len(data) > 3 && data[1] == c && data[2] != c { |
| 105 | if isspace(data[2]) { |
| 106 | return 0, nil |
| 107 | } |
| 108 | ret, node := helperDoubleEmphasis(p, data[2:], c) |
| 109 | if ret == 0 { |
| 110 | return 0, nil |
| 111 | } |
| 112 | |
| 113 | return ret + 2, node |
| 114 | } |
| 115 | |
| 116 | if len(data) > 4 && data[1] == c && data[2] == c && data[3] != c { |
| 117 | if c == '~' || isspace(data[3]) { |
| 118 | return 0, nil |
| 119 | } |
| 120 | ret, node := helperTripleEmphasis(p, data, 3, c) |
| 121 | if ret == 0 { |
| 122 | return 0, nil |
| 123 | } |
| 124 | |
| 125 | return ret + 3, node |
| 126 | } |
| 127 | |
| 128 | return 0, nil |
| 129 | } |
| 130 | |
| 131 | func codeSpan(p *Markdown, data []byte, offset int) (int, *Node) { |
| 132 | data = data[offset:] |
nothing calls this directly
no test coverage detected
searching dependent graphs…