| 2 | // https://github.com/iodide-project/iodide/blob/master/src/editor/iomd-tools/iomd-parser.js |
| 3 | |
| 4 | function hashCode(str) { |
| 5 | // this is an implementation of java's hashcode method |
| 6 | // https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript |
| 7 | let hash = 0; |
| 8 | let chr; |
| 9 | if (str.length !== 0) { |
| 10 | for (let i = 0; i < str.length; i++) { |
| 11 | chr = str.charCodeAt(i); |
| 12 | hash = (hash << 5) - hash + chr; // eslint-disable-line |
| 13 | hash |= 0; // eslint-disable-line |
| 14 | } |
| 15 | } |
| 16 | return hash.toString(); |
| 17 | } |
| 18 | |
| 19 | export function iomdParser(fullIomd) { |
| 20 | const iomdLines = fullIomd.split('\n'); |