Support for helper functions

This commit is contained in:
Ariel Saldana
2018-02-23 10:00:58 -05:00
parent e4803bb977
commit 0da14f6a5b
3 changed files with 16 additions and 3 deletions

2
.github/CODEOWNERS vendored
View File

@@ -3379,7 +3379,7 @@
/types/shopify-buy/ @openminder
/types/shortid/ @stpettersens @despairblue
/types/shot/ @AJamesPhillips
/types/showdown/ @cbowdon @tan9
/types/showdown/ @cbowdon @tan9 @arielsaldana
/types/shrink-ray/ @forabi
/types/siema/ @Irmiz @0x6368656174 @samnau
/types/siesta/ @bquarmby

View File

@@ -1,6 +1,6 @@
// Type definitions for Showdown 1.7.2
// Type definitions for Showdown 1.7.3
// Project: https://github.com/coreyti/showdown
// Definitions by: cbowdon <https://github.com/cbowdon>, Pei-Tang Huang <https://github.com/tan9>
// Definitions by: cbowdon <https://github.com/cbowdon>, Pei-Tang Huang <https://github.com/tan9>, Ariel-Saldana <https://github.com/arielsaldana>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = Showdown;
@@ -362,10 +362,21 @@ declare namespace Showdown {
*/
new (converterOptions?: ConverterOptions): Converter;
}
/**
* Helper Interface
*/
interface Helper {
replaceRecursiveRegExp(...args: any[]): string;
}
/** Constructor function for a Converter */
var Converter: ConverterStatic;
/**
* Showdown helper
*/
var helper: Helper;
/**
* Setting a "global" option affects all instances of showdown
*/

View File

@@ -17,6 +17,8 @@ var preloadedExtensions = [ 'my-ext' ],
var configuredConverter = new showdown.Converter();
configuredConverter.addExtension({type: 'output', filter: (text, converter)=>{return text.replace('#', '*')}}, 'myext');
console.log(showdown.helper);
console.log(converter.makeHtml(exampleMarkdown));
// should log '<h1 id="hellomarkdown">hello, markdown</h1>'