(str, pos, max)
| 18 | } |
| 19 | |
| 20 | function parseImageSize(str, pos, max) { |
| 21 | const result = { |
| 22 | ok: false, |
| 23 | pos: 0, |
| 24 | width: '', |
| 25 | height: '', |
| 26 | }; |
| 27 | if (pos >= max) return result; |
| 28 | let code = str.charCodeAt(pos); |
| 29 | if (code !== 0x3D /* = */) return result; |
| 30 | pos++; |
| 31 | code = str.charCodeAt(pos); |
| 32 | if (code !== 0x78 /* x */ && (code < 0x30 || code > 0x39) /* [0-9] */) { |
| 33 | return result; |
| 34 | } |
| 35 | // parse width |
| 36 | const resultW = parseNextNumber(str, pos, max); |
| 37 | pos = resultW.pos; |
| 38 | // next charactor must be 'x' |
| 39 | code = str.charCodeAt(pos); |
| 40 | if (code !== 0x78 /* x */) { return result; } |
| 41 | pos++; |
| 42 | // parse height |
| 43 | const resultH = parseNextNumber(str, pos, max); |
| 44 | pos = resultH.pos; |
| 45 | result.width = resultW.value; |
| 46 | result.height = resultH.value; |
| 47 | result.pos = pos; |
| 48 | result.ok = true; |
| 49 | return result; |
| 50 | } |
| 51 | |
| 52 | export default function plugin(md) { |
| 53 | md.inline.ruler.before('emphasis', 'image', (state, silent) => { |
no test coverage detected