mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* Fixes for early June TS3.6 DOM update 1. Apollo-link used GlobalFetch, which has been removed. Until my PR goes in (apollographql/apollo-link#1095), I added a shim in apollo-upload-client, which uses apollo-link-http-common. 2. dom-inputevent is updated to match the spec-standard InputEvent types that will ship with Typescript 3.6. 3. Same for webappsec-credential-management 4. Fixed to-markdown's tests to work with the new, non-nullable definition of node.style.fontStyle. * Fix redundant `undefined` lint * Make fetch shim work on more versions of Typescript * Require TS 3.1 for apollo-upload-client fix
65 lines
1.3 KiB
TypeScript
65 lines
1.3 KiB
TypeScript
import toMarkdown = require('to-markdown');
|
|
|
|
// toMarkdown()
|
|
toMarkdown(`
|
|
<h1>Hello</h1>
|
|
`);
|
|
|
|
toMarkdown(`
|
|
<h1>Hello</h1>
|
|
`, { });
|
|
|
|
toMarkdown(`
|
|
<h1>Hello</h1>
|
|
`, {
|
|
gfm: true
|
|
});
|
|
|
|
toMarkdown(`
|
|
<h1>Hello</h1>
|
|
`, {
|
|
converters: [
|
|
{
|
|
filter: 'code',
|
|
replacement(innerHTML) {
|
|
return `\`${innerHTML}\``;
|
|
}
|
|
},
|
|
{
|
|
filter: ['em', 'i'],
|
|
replacement(innerHTML) {
|
|
return `*${innerHTML}*`;
|
|
}
|
|
},
|
|
{
|
|
filter(node) {
|
|
return node.nodeName === 'SPAN'
|
|
&& /italic/i.test(node.style.fontStyle || "");
|
|
},
|
|
replacement(innerHTML) {
|
|
return `*${innerHTML}*`;
|
|
}
|
|
},
|
|
{
|
|
filter(node) {
|
|
return node.nodeName === 'SPAN'
|
|
&& /italic/i.test(node.style.fontStyle || "");
|
|
},
|
|
replacement(innerHTML, node) {
|
|
return `${innerHTML}(node: \`${node.nodeName}\`)`;
|
|
}
|
|
}
|
|
]
|
|
});
|
|
|
|
// toMarkdown.isBlock()
|
|
toMarkdown.isBlock(document.querySelector('h1')!); // true
|
|
toMarkdown.isBlock(document.querySelector('img')!); // false
|
|
|
|
// toMarkdown.isVoid()
|
|
toMarkdown.isVoid(document.querySelector('br')!); // true
|
|
toMarkdown.isVoid(document.querySelector('body')!); // false
|
|
|
|
// toMarkdown.outer()
|
|
toMarkdown.outer(document.querySelector('a')!, '|');
|