Skip to content

Commit

Permalink
move html out of index, add class Raw and document
Browse files Browse the repository at this point in the history
  • Loading branch information
cAttte committed Mar 4, 2021
1 parent c05bccf commit 8e0e817
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
36 changes: 36 additions & 0 deletions mw/html.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
declare global {
namespace mw {
namespace html {
/**
* Escape a string for HTML.
* Converts special characters to HTML entities.
* @param {string} s The string to escape
* @returns {string} HTML
*/
function escape(s: string): string;

/**
* Create an HTML element string, with safe escaping.
* @param {string} name The tag name
* @param {{ [key: string]: string }} attrs An object with members mapping element names to values
* @param {string | html.Raw} contents The contents of the element
* @returns {string} HTML
*/
function element(
name: string,
attrs?: Record<string, string>,
contents?: string | mw.html.Raw
): string;

/**
* Wrapper object for raw HTML passed to mw.html.element().
*/
class Raw<V extends string = string> {
constructor(value: V);
private value: V;
}
}
}
}

export {};
6 changes: 0 additions & 6 deletions mw/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ declare global {
wgWikibaseItemId: string;
}>;

namespace html {
function escape(s: string): string;

function element(name: string, attrs?: any, contents?: string): string;
}

namespace log {
function deprecate(
obj: any,
Expand Down

0 comments on commit 8e0e817

Please sign in to comment.