* Helper used to automatically link items to global JS documentation or to internal * documentation. * * @param {string} text - text to potentially link * @param {function} [getHref] - a function that tries * to find a URL to point a named link to * @param {string} description text that will b
(text, getHref, description)
| 26 | * link('string').url // => 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String' |
| 27 | */ |
| 28 | function link(text, getHref, description) { |
| 29 | const href = getHref(text); |
| 30 | if (href) { |
| 31 | // TODO: this is a temporary fix until we drop remark 3.x support, |
| 32 | // and then we should remove the 'href' property and only |
| 33 | // have the url property of links |
| 34 | return u( |
| 35 | 'link', |
| 36 | { |
| 37 | href, |
| 38 | url: href |
| 39 | }, |
| 40 | [t(description || text)] |
| 41 | ); |
| 42 | } |
| 43 | return t(text); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Given a list of types, a method to get a link location, and start, |
no test coverage detected