diff --git a/src/converter/index.ts b/src/converter/index.ts index 4019eb7..ce5469d 100644 --- a/src/converter/index.ts +++ b/src/converter/index.ts @@ -1,16 +1,16 @@ import Showdown, { type Converter } from "showdown"; import { - type MmmarkConverterOptions, - type MmmarkUserSelectOptions, - getAllOptions, + type MmmarkConverterOptions, + type MmmarkUserSelectOptions, + getAllOptions, } from "../helper/getalloptions.js"; type MmConverter = Converter; function mdConverter(options?: MmmarkUserSelectOptions) { - const opts: MmmarkConverterOptions = getAllOptions(options); - return new Showdown.Converter(opts); + const opts: MmmarkConverterOptions = getAllOptions(options); + return new Showdown.Converter(opts); } export { mdConverter, type MmConverter }; diff --git a/src/extensions/copy_code.ts b/src/extensions/copy_code.ts index 1f31a7a..2265cd6 100644 --- a/src/extensions/copy_code.ts +++ b/src/extensions/copy_code.ts @@ -1,15 +1,15 @@ import { - registerExtension, - type MmExtension, + type MmExtension, + registerExtension, } from "../manage-extensions/index.js"; /** * */ declare global { - interface Window { - copyCodeListener?: boolean; - } + interface Window { + copyCodeListener?: boolean; + } } /** @@ -17,20 +17,20 @@ declare global { * @param {String} className The class name of the button. */ function addListener(className: string) { - if (typeof window !== "undefined" && window.copyCodeListener !== true) { - window.addEventListener("click", (e) => { - const target = e.target as HTMLElement; - if ( - target?.classList?.contains(className) && - target.nextElementSibling?.tagName === "PRE" - ) { - navigator.clipboard.writeText( - (target.nextElementSibling as HTMLPreElement).innerText - ); - } - }); - window.copyCodeListener = true; - } + if (typeof window !== "undefined" && window.copyCodeListener !== true) { + window.addEventListener("click", (e) => { + const target = e.target as HTMLElement; + if ( + target?.classList?.contains(className) && + target.nextElementSibling?.tagName === "PRE" + ) { + navigator.clipboard.writeText( + (target.nextElementSibling as HTMLPreElement).innerText, + ); + } + }); + window.copyCodeListener = true; + } } /** * showdownCopyCode @@ -40,19 +40,19 @@ function addListener(className: string) { * @function */ function copyCode({ className = "copy-code" } = {}): MmExtension[] { - return [ - { - type: "output", - filter: function (text: string) { - addListener(className); + return [ + { + type: "output", + filter: (text: string) => { + addListener(className); - return text.replace( - /
Copy$&`
- );
- },
- },
- ];
+ return text.replace(
+ /Copy$&`,
+ );
+ },
+ },
+ ];
}
registerExtension("copyCode", copyCode());
diff --git a/src/extensions/custom_class.ts b/src/extensions/custom_class.ts
index 31cea3b..33ec544 100644
--- a/src/extensions/custom_class.ts
+++ b/src/extensions/custom_class.ts
@@ -1,6 +1,6 @@
import {
- registerExtension,
- type MmExtension,
+ type MmExtension,
+ registerExtension,
} from "../manage-extensions/index.js";
/**
@@ -43,32 +43,32 @@ import {
* @returns {MmExtension[]}
*/
function customClass(): MmExtension[] {
- return [
- {
- type: "output",
- filter: (text) => {
- return (
- text
- // Add class for list (ol, ul)
- .replace(
- /\[\.([a-z0-9A-Z\s]+)\]<\/p>[\n]?<(.+)>/g,
- `<$2 class="$1">`
- )
+ return [
+ {
+ type: "output",
+ filter: (text) => {
+ return (
+ text
+ // Add class for list (ol, ul)
+ .replace(
+ /
\[\.([a-z0-9A-Z\s]+)\]<\/p>[\n]?<(.+)>/g,
+ `<$2 class="$1">`,
+ )
- // Add class for other blocks
- .replace(/<(.+)>\[\.([a-z0-9A-Z\s]+)\]/g, `<$1 class="$2">`)
+ // Add class for other blocks
+ .replace(/<(.+)>\[\.([a-z0-9A-Z\s]+)\]/g, `<$1 class="$2">`)
- // Prevent class name with 2 dashs being replace by `` tag
- .replace(/class="(.+)"/g, function (str) {
- if (str.indexOf("") !== -1) {
- return str.replace(/<[/]?em>/g, "_");
- }
- return str;
- })
- );
- },
- },
- ];
+ // Prevent class name with 2 dashs being replace by `` tag
+ .replace(/class="(.+)"/g, (str) => {
+ if (str.indexOf("") !== -1) {
+ return str.replace(/<[/]?em>/g, "_");
+ }
+ return str;
+ })
+ );
+ },
+ },
+ ];
}
registerExtension("customClass", customClass());
diff --git a/src/extensions/icons.ts b/src/extensions/icons.ts
index 6578e05..0181110 100644
--- a/src/extensions/icons.ts
+++ b/src/extensions/icons.ts
@@ -1,6 +1,6 @@
import {
- registerExtension,
- type MmExtension,
+ type MmExtension,
+ registerExtension,
} from "../manage-extensions/index.js";
/**
@@ -17,28 +17,27 @@ import {
* ```
*/
function icons(): MmExtension[] {
- return [
- {
- type: "lang",
- regex: "\\B(\\\\)?@fa-([\\S]+)\\b",
- replace: function (a: any, b: string, c: string) {
- return b === "\\" ? a : '' + "";
- },
- },
- {
- type: "output",
- filter: (text: string) => {
- const scriptTag = `
+ return [
+ {
+ type: "lang",
+ regex: "\\B(\\\\)?@fa-([\\S]+)\\b",
+ replace: (a: any, b: string, c: string) =>
+ b === "\\" ? a : ``,
+ },
+ {
+ type: "output",
+ filter: (text: string) => {
+ const scriptTag = `
`;
- return scriptTag + text;
- },
- },
- ];
+ return scriptTag + text;
+ },
+ },
+ ];
}
registerExtension("icons", icons());
diff --git a/src/extensions/index.ts b/src/extensions/index.ts
index e659b06..fd17c6d 100644
--- a/src/extensions/index.ts
+++ b/src/extensions/index.ts
@@ -7,11 +7,11 @@ import twitter from "./twitter.js";
import youtube from "./youtube.js";
export {
- showdownMathjax,
- showdownprism,
- copyCode,
- customClass,
- icons,
- twitter,
- youtube,
+ showdownMathjax,
+ showdownprism,
+ copyCode,
+ customClass,
+ icons,
+ twitter,
+ youtube,
};
diff --git a/src/extensions/twitter.ts b/src/extensions/twitter.ts
index 817f53a..6f233b9 100644
--- a/src/extensions/twitter.ts
+++ b/src/extensions/twitter.ts
@@ -1,6 +1,6 @@
import {
- registerExtension,
- type MmExtension,
+ type MmExtension,
+ registerExtension,
} from "../manage-extensions/index.js";
/**
* Twitter Extension
@@ -10,52 +10,38 @@ import {
* #hashtag -> #hashtag
*/
function twitter(): MmExtension[] {
- return [
- // @username syntax
- {
- type: "lang",
- regex: "\\B(\\\\)?@([\\S]+)\\b",
- replace: function (match: any, leadingSlash: string, username: string) {
- // Check if we matched the leading \ and return nothing changed if so
- if (leadingSlash === "\\") {
- return match;
- } else {
- return (
- '@' +
- username +
- ""
- );
- }
- },
- },
- // #hashtag syntax
- {
- type: "lang",
- regex: "\\B(\\\\)?#([\\S]+)\\b",
- replace: function (match: any, leadingSlash: string, tag: string) {
- // Check if we matched the leading \ and return nothing changed if so
- if (leadingSlash === "\\") {
- return match;
- } else {
- return (
- '#' +
- tag +
- ""
- );
- }
- },
- },
- // Escaped @'s
- {
- type: "lang",
- regex: "\\\\@",
- replace: "@",
- },
- ];
+ return [
+ // @username syntax
+ {
+ type: "lang",
+ regex: "\\B(\\\\)?@([\\S]+)\\b",
+ replace: (match: any, leadingSlash: string, username: string) => {
+ // Check if we matched the leading \ and return nothing changed if so
+ if (leadingSlash === "\\") {
+ return match;
+ }
+ return `@${username}`;
+ },
+ },
+ // #hashtag syntax
+ {
+ type: "lang",
+ regex: "\\B(\\\\)?#([\\S]+)\\b",
+ replace: (match: any, leadingSlash: string, tag: string) => {
+ // Check if we matched the leading \ and return nothing changed if so
+ if (leadingSlash === "\\") {
+ return match;
+ }
+ return `#${tag}`;
+ },
+ },
+ // Escaped @'s
+ {
+ type: "lang",
+ regex: "\\\\@",
+ replace: "@",
+ },
+ ];
}
registerExtension("twitter", twitter());
diff --git a/src/extensions/youtube.ts b/src/extensions/youtube.ts
index 11764f9..2602771 100644
--- a/src/extensions/youtube.ts
+++ b/src/extensions/youtube.ts
@@ -1,6 +1,6 @@
import {
- registerExtension,
- type MmExtension,
+ type MmExtension,
+ registerExtension,
} from "../manage-extensions/index.js";
/**
@@ -20,16 +20,16 @@ import {
*
*/
function youtube(): MmExtension[] {
- return [
- {
- type: "lang",
- regex: /{% youtube (.+?) %}/g,
- replace: (_match: any, url: string) => {
- const videoId = url.split("v=")[1] || url.split("/").pop();
- return ``;
- },
- },
- ];
+ return [
+ {
+ type: "lang",
+ regex: /{% youtube (.+?) %}/g,
+ replace: (_match: any, url: string) => {
+ const videoId = url.split("v=")[1] || url.split("/").pop();
+ return ``;
+ },
+ },
+ ];
}
registerExtension("youtube", youtube());
diff --git a/src/frontmatter/index.ts b/src/frontmatter/index.ts
index 2ac5fc9..3f8a2b1 100644
--- a/src/frontmatter/index.ts
+++ b/src/frontmatter/index.ts
@@ -1,18 +1,18 @@
import { load } from "js-yaml";
type DataProps = {
- lines: string[];
- metaIndices: number[];
+ lines: string[];
+ metaIndices: number[];
};
type FrontMatterResult = {
- /**
- * Yaml data form a markdown files
- */
- data: T;
- /**
- * Body content of markdown file
- */
- content: string;
+ /**
+ * Yaml data form a markdown files
+ */
+ data: T;
+ /**
+ * Body content of markdown file
+ */
+ content: string;
};
/**
@@ -20,42 +20,42 @@ type FrontMatterResult = {
* Parses metadata and content from markdown content based on metadata delimiters.
*/
class FrontMatter {
- private mdcontent: string;
- constructor(mdcontent: string) {
- this.mdcontent = mdcontent;
- }
- private findMetaIndices(mem: number[], item: string, i: number): number[] {
- // If the line starts with ---, it's a metadata delimiter
- if (/^---/.test(item)) {
- // Add the index of the line to the array of indices
- mem.push(i);
- }
+ private mdcontent: string;
+ constructor(mdcontent: string) {
+ this.mdcontent = mdcontent;
+ }
+ private findMetaIndices(mem: number[], item: string, i: number): number[] {
+ // If the line starts with ---, it's a metadata delimiter
+ if (/^---/.test(item)) {
+ // Add the index of the line to the array of indices
+ mem.push(i);
+ }
- return mem;
- }
- private getData(linesPros: DataProps): FrontMatterResult["data"] {
- const { lines, metaIndices } = linesPros;
- if (metaIndices.length > 0) {
- const data = lines.slice(metaIndices[0] + 1, metaIndices[1]);
+ return mem;
+ }
+ private getData(linesPros: DataProps): FrontMatterResult["data"] {
+ const { lines, metaIndices } = linesPros;
+ if (metaIndices.length > 0) {
+ const data = lines.slice(metaIndices[0] + 1, metaIndices[1]);
- return load(data.join("\n")) as T;
- }
- return {} as T;
- }
- private getContent(linesPros: DataProps): string {
- const { lines, metaIndices } = linesPros;
- return metaIndices.length > 0
- ? lines.slice(metaIndices[1] + 1).join("\n")
- : lines.join("\n");
- }
- frontmatter(): FrontMatterResult {
- const lines = this.mdcontent.split("\n");
- const metaIndices = lines.reduce(this.findMetaIndices, [] as number[]);
- const data: T = this.getData({ lines, metaIndices });
- const content: string = this.getContent({ lines, metaIndices });
+ return load(data.join("\n")) as T;
+ }
+ return {} as T;
+ }
+ private getContent(linesPros: DataProps): string {
+ const { lines, metaIndices } = linesPros;
+ return metaIndices.length > 0
+ ? lines.slice(metaIndices[1] + 1).join("\n")
+ : lines.join("\n");
+ }
+ frontmatter(): FrontMatterResult {
+ const lines = this.mdcontent.split("\n");
+ const metaIndices = lines.reduce(this.findMetaIndices, [] as number[]);
+ const data: T = this.getData({ lines, metaIndices });
+ const content: string = this.getContent({ lines, metaIndices });
- return { data, content };
- }
+ return { data, content };
+ }
}
/**
* **Retrieves the frontmatter data and content from markdown contents.**
@@ -101,7 +101,7 @@ class FrontMatter {
*
*/
function frontmatter(content: string): FrontMatterResult {
- return new FrontMatter(content).frontmatter();
+ return new FrontMatter(content).frontmatter();
}
export { frontmatter, type FrontMatterResult };
diff --git a/src/helper/getalloptions.ts b/src/helper/getalloptions.ts
index d8d23bb..00af9ec 100644
--- a/src/helper/getalloptions.ts
+++ b/src/helper/getalloptions.ts
@@ -8,380 +8,380 @@ type MmmarkConverterOptions = ConverterOptions;
* Options for user choice
*/
type MmmarkUserSelectOptions = {
- /**
- * Support for HTML Tag escaping.
- *
- * @example
- * **input**:
- *
- * ```md
- * \foo\.
- * ```
- *
- * **backslashEscapesHTMLTags** = false
- * ```html
- * \
foo\
- * ```
- *
- * **backslashEscapesHTMLTags** = true
- * ```html
- * <div>foo</div>
- * ```
- * @default false
- */
- backslashEscapesHTMLTags?: MmmarkConverterOptions["backslashEscapesHTMLTags"];
- /**
- * Use text in curly braces as header id.
- *
- * @example
- * ```md
- * ## Sample header {real-id} will use real-id as id
- * ```
- * @default false
- */
- customizedHeaderId?: MmmarkConverterOptions["customizedHeaderId"];
- /**
- * Disables the requirement of indenting sublists by 4 spaces for them to be nested,
- * effectively reverting to the old behavior where 2 or 3 spaces were enough.
- *
- * @example
- * **input**:
- *
- * ```md
- * - one
- * - two
- *
- * ...
- *
- * - one
- * - two
- * ```
- *
- * **disableForced4SpacesIndentedSublists** = false
- *
- * ```html
- *
- * - one
- * - two
- *
- * ...
- *
- * - one
- *
- * - two
- *
- *
- *
- * ```
- *
- * **disableForced4SpacesIndentedSublists** = true
- *
- * ```html
- *
- * - one
- *
- * - two
- *
- *
- *
- * ...
- *
- * - one
- *
- * - two
- *
- *
- *
- * ```
- * @default false
- */
- disableForced4SpacesIndentedSublists?: MmmarkConverterOptions["disableForced4SpacesIndentedSublists"];
- /**
- * Add showdown extensions to the new converter can be showdown extensions or "global" extensions name.
- *
- * @default
- * []
- *
- * Add extensions to the new converter can be showdown extensions or "global" extensions name.
- */
- extensions?: MmmarkConverterOptions["extensions"];
- /**
- * Generate header ids compatible with github style (spaces are replaced
- * with dashes and a bunch of non alphanumeric chars are removed).
- *
- * @example
- * **input**:
- *
- * ```md
- * # This is a header with @#$%
- * ```
- *
- * **ghCompatibleHeaderId** = false
- *
- * ```html
- * This is a header
- * ```
- *
- * **ghCompatibleHeaderId** = true
- *
- * ```html
- * This is a header with @#$%
- * ```
- * @default false
- */
- ghCompatibleHeaderId?: MmmarkConverterOptions["ghCompatibleHeaderId"];
- /**
- * Enables support for github @mentions, which links to the github profile page of the username mentioned.
- *
- * @example
- * **input**:
- *
- * ```md
- * hello there @tivie
- * ```
- *
- * **ghMentions** = false
- *
- * ```html
- * hello there @tivie
- * ```
- *
- * **ghMentions** = true
- *
- * ```html
- * hello there hello there @tivie
- * ```
- * @default https://github.com/{u}
- */
- ghMentionsLink?: MmmarkConverterOptions["ghMentionsLink"];
- /**
- * Turning this on will stop showdown from interpreting underscores in the middle of
- * words as and and instead treat them as literal underscores.
- *
- * @example
- * **input**:
- *
- * ```md
- * some text with__underscores__in middle
- * ```
- *
- * **literalMidWordUnderscores** = false
- *
- * ```html
- * some text withunderscoresin middle
- * ```
- *
- * **literalMidWordUnderscores** = true
- *
- * ```html
- * some text with__underscores__in middle
- * ```
- * @default false
- */
- literalMidWordUnderscores?: MmmarkConverterOptions["literalMidWordUnderscores"];
- /**
- * Disable the automatic generation of header ids.
- * Showdown generates an id for headings automatically. This is useful for linking to a specific header.
- * This behavior, however, can be disabled with this option.
- *
- * @example
- * **input**:
- *
- * ```md
- * # This is a header
- * ```
- *
- * **noHeaderId** = false
- *
- * ```html
- * This is a header
- * ```
- *
- * **noHeaderId** = true
- *
- * ```html
- * This is a header
- * ```
- * @default false
- */
- noHeaderId?: MmmarkConverterOptions["noHeaderId"];
- /**
- * Omit the trailing newline in a code block.
- * By default, showdown adds a newline before the closing tags in code blocks. By enabling this option, that newline is removed.
- * This option affects both indented and fenced (gfm style) code blocks.
- *
- * @example
- *
- * **input**:
- *
- * ```md
- * var foo = 'bar';
- * ```
- *
- * **omitExtraWLInCodeBlocks** = false:
- *
- * ```html
- * var foo = 'bar';
- *
- * ```
- * **omitExtraWLInCodeBlocks** = true:
- *
- * ```html
- * var foo = 'bar';
- * ```
- * @default false
- */
- omitExtraWLInCodeBlocks?: MmmarkConverterOptions["omitExtraWLInCodeBlocks"];
- /**
- * Add a prefix to the generated header ids.
- * Passing a string will prefix that string to the header id.
- * Setting to true will add a generic 'section' prefix.
- *
- * @default false
- */
- prefixHeaderId?: MmmarkConverterOptions["prefixHeaderId"];
- /**
- * Remove only spaces, ' and " from generated header ids (including prefixes),
- * replacing them with dashes (-).
- * WARNING: This might result in malformed ids.
- *
- * @default false
- */
- rawHeaderId?: MmmarkConverterOptions["rawHeaderId"];
- /**
- * Setting this option to true will prevent showdown from modifying the prefix.
- * This might result in malformed IDs (if, for instance, the " char is used in the prefix).
- * Has no effect if prefixHeaderId is set to false.
- *
- * @default false
- */
- rawPrefixHeaderId?: MmmarkConverterOptions["rawPrefixHeaderId"];
- /**
- * Makes adding a space between # and the header text mandatory.
- *
- * @example
- * **input**:
- *
- * ```md
- * #header
- * ```
- *
- * **requireSpaceBeforeHeadingText** = false
- *
- * ```html
- * header
- * ```
- *
- * **simpleLineBreaks** = true
- *
- * ```html
- * #header
- * ```
- *
- * @default false
- */
- requireSpaceBeforeHeadingText?: MmmarkConverterOptions["requireSpaceBeforeHeadingText"];
- /**
- * Parses line breaks as like GitHub does, without needing 2 spaces at the end of the line.
- *
- * @example
- * **input**:
- *
- * ```md
- * a line
- * wrapped in two
- * ```
- *
- * **simpleLineBreaks** = false
- *
- * ```html
- * a line
- * wrapped in two
- * ```
- *
- * **simpleLineBreaks** = true
- *
- * ```html
- * a line
- * wrapped in two
- * ```
- * @default false
- */
- simpleLineBreaks?: MmmarkConverterOptions["simpleLineBreaks"];
- /**
- * Split adjacent blockquote blocks.
- */
- splitAdjacentBlockquotes?: MmmarkConverterOptions["splitAdjacentBlockquotes"];
- /**
- * Tries to smartly fix indentation problems related to es6 template
- * strings in the midst of indented code.
- *
- * @default false
- */
- smartIndentationFix?: MmmarkConverterOptions["smartIndentationFix"];
- /**
- * Prevents weird effects in live previews due to incomplete input.
- *
- * @example
- * ![awkward effect](http://i.imgur.com/YQ9iHTL.gif)
- * You can prevent this by enabling this option.
- * @default false
- */
- smoothLivePreview?: MmmarkConverterOptions["smoothLivePreview"];
- /**
- * If enabled adds an id property to table headers tags.
- *
- * @remarks This options only applies if **[tables][]** is enabled.
- * @default false
- */
- tablesHeaderId?: MmmarkConverterOptions["tablesHeaderId"];
- /**
- * Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled,
- * underscores no longer parses into `` and ``
- *
- * @example
- * **input**:
- *
- * ```md
- * __underline word__
- * ```
- *
- * **underline** = false
- * ```html
- * underlined word
- * ```
- *
- * **underline** = true
- * ```html
- * underlined word
- * ```
- * @default false
- */
- underline?: MmmarkConverterOptions["underline"];
+ /**
+ * Support for HTML Tag escaping.
+ *
+ * @example
+ * **input**:
+ *
+ * ```md
+ * \foo\.
+ * ```
+ *
+ * **backslashEscapesHTMLTags** = false
+ * ```html
+ * \
foo\
+ * ```
+ *
+ * **backslashEscapesHTMLTags** = true
+ * ```html
+ * <div>foo</div>
+ * ```
+ * @default false
+ */
+ backslashEscapesHTMLTags?: MmmarkConverterOptions["backslashEscapesHTMLTags"];
+ /**
+ * Use text in curly braces as header id.
+ *
+ * @example
+ * ```md
+ * ## Sample header {real-id} will use real-id as id
+ * ```
+ * @default false
+ */
+ customizedHeaderId?: MmmarkConverterOptions["customizedHeaderId"];
+ /**
+ * Disables the requirement of indenting sublists by 4 spaces for them to be nested,
+ * effectively reverting to the old behavior where 2 or 3 spaces were enough.
+ *
+ * @example
+ * **input**:
+ *
+ * ```md
+ * - one
+ * - two
+ *
+ * ...
+ *
+ * - one
+ * - two
+ * ```
+ *
+ * **disableForced4SpacesIndentedSublists** = false
+ *
+ * ```html
+ *
+ * - one
+ * - two
+ *
+ * ...
+ *
+ * - one
+ *
+ * - two
+ *
+ *
+ *
+ * ```
+ *
+ * **disableForced4SpacesIndentedSublists** = true
+ *
+ * ```html
+ *
+ * - one
+ *
+ * - two
+ *
+ *
+ *
+ * ...
+ *
+ * - one
+ *
+ * - two
+ *
+ *
+ *
+ * ```
+ * @default false
+ */
+ disableForced4SpacesIndentedSublists?: MmmarkConverterOptions["disableForced4SpacesIndentedSublists"];
+ /**
+ * Add showdown extensions to the new converter can be showdown extensions or "global" extensions name.
+ *
+ * @default
+ * []
+ *
+ * Add extensions to the new converter can be showdown extensions or "global" extensions name.
+ */
+ extensions?: MmmarkConverterOptions["extensions"];
+ /**
+ * Generate header ids compatible with github style (spaces are replaced
+ * with dashes and a bunch of non alphanumeric chars are removed).
+ *
+ * @example
+ * **input**:
+ *
+ * ```md
+ * # This is a header with @#$%
+ * ```
+ *
+ * **ghCompatibleHeaderId** = false
+ *
+ * ```html
+ * This is a header
+ * ```
+ *
+ * **ghCompatibleHeaderId** = true
+ *
+ * ```html
+ * This is a header with @#$%
+ * ```
+ * @default false
+ */
+ ghCompatibleHeaderId?: MmmarkConverterOptions["ghCompatibleHeaderId"];
+ /**
+ * Enables support for github @mentions, which links to the github profile page of the username mentioned.
+ *
+ * @example
+ * **input**:
+ *
+ * ```md
+ * hello there @tivie
+ * ```
+ *
+ * **ghMentions** = false
+ *
+ * ```html
+ * hello there @tivie
+ * ```
+ *
+ * **ghMentions** = true
+ *
+ * ```html
+ * hello there hello there @tivie
+ * ```
+ * @default https://github.com/{u}
+ */
+ ghMentionsLink?: MmmarkConverterOptions["ghMentionsLink"];
+ /**
+ * Turning this on will stop showdown from interpreting underscores in the middle of
+ * words as and and instead treat them as literal underscores.
+ *
+ * @example
+ * **input**:
+ *
+ * ```md
+ * some text with__underscores__in middle
+ * ```
+ *
+ * **literalMidWordUnderscores** = false
+ *
+ * ```html
+ * some text withunderscoresin middle
+ * ```
+ *
+ * **literalMidWordUnderscores** = true
+ *
+ * ```html
+ * some text with__underscores__in middle
+ * ```
+ * @default false
+ */
+ literalMidWordUnderscores?: MmmarkConverterOptions["literalMidWordUnderscores"];
+ /**
+ * Disable the automatic generation of header ids.
+ * Showdown generates an id for headings automatically. This is useful for linking to a specific header.
+ * This behavior, however, can be disabled with this option.
+ *
+ * @example
+ * **input**:
+ *
+ * ```md
+ * # This is a header
+ * ```
+ *
+ * **noHeaderId** = false
+ *
+ * ```html
+ * This is a header
+ * ```
+ *
+ * **noHeaderId** = true
+ *
+ * ```html
+ * This is a header
+ * ```
+ * @default false
+ */
+ noHeaderId?: MmmarkConverterOptions["noHeaderId"];
+ /**
+ * Omit the trailing newline in a code block.
+ * By default, showdown adds a newline before the closing tags in code blocks. By enabling this option, that newline is removed.
+ * This option affects both indented and fenced (gfm style) code blocks.
+ *
+ * @example
+ *
+ * **input**:
+ *
+ * ```md
+ * var foo = 'bar';
+ * ```
+ *
+ * **omitExtraWLInCodeBlocks** = false:
+ *
+ * ```html
+ * var foo = 'bar';
+ *
+ * ```
+ * **omitExtraWLInCodeBlocks** = true:
+ *
+ * ```html
+ * var foo = 'bar';
+ * ```
+ * @default false
+ */
+ omitExtraWLInCodeBlocks?: MmmarkConverterOptions["omitExtraWLInCodeBlocks"];
+ /**
+ * Add a prefix to the generated header ids.
+ * Passing a string will prefix that string to the header id.
+ * Setting to true will add a generic 'section' prefix.
+ *
+ * @default false
+ */
+ prefixHeaderId?: MmmarkConverterOptions["prefixHeaderId"];
+ /**
+ * Remove only spaces, ' and " from generated header ids (including prefixes),
+ * replacing them with dashes (-).
+ * WARNING: This might result in malformed ids.
+ *
+ * @default false
+ */
+ rawHeaderId?: MmmarkConverterOptions["rawHeaderId"];
+ /**
+ * Setting this option to true will prevent showdown from modifying the prefix.
+ * This might result in malformed IDs (if, for instance, the " char is used in the prefix).
+ * Has no effect if prefixHeaderId is set to false.
+ *
+ * @default false
+ */
+ rawPrefixHeaderId?: MmmarkConverterOptions["rawPrefixHeaderId"];
+ /**
+ * Makes adding a space between # and the header text mandatory.
+ *
+ * @example
+ * **input**:
+ *
+ * ```md
+ * #header
+ * ```
+ *
+ * **requireSpaceBeforeHeadingText** = false
+ *
+ * ```html
+ * header
+ * ```
+ *
+ * **simpleLineBreaks** = true
+ *
+ * ```html
+ * #header
+ * ```
+ *
+ * @default false
+ */
+ requireSpaceBeforeHeadingText?: MmmarkConverterOptions["requireSpaceBeforeHeadingText"];
+ /**
+ * Parses line breaks as like GitHub does, without needing 2 spaces at the end of the line.
+ *
+ * @example
+ * **input**:
+ *
+ * ```md
+ * a line
+ * wrapped in two
+ * ```
+ *
+ * **simpleLineBreaks** = false
+ *
+ * ```html
+ * a line
+ * wrapped in two
+ * ```
+ *
+ * **simpleLineBreaks** = true
+ *
+ * ```html
+ * a line
+ * wrapped in two
+ * ```
+ * @default false
+ */
+ simpleLineBreaks?: MmmarkConverterOptions["simpleLineBreaks"];
+ /**
+ * Split adjacent blockquote blocks.
+ */
+ splitAdjacentBlockquotes?: MmmarkConverterOptions["splitAdjacentBlockquotes"];
+ /**
+ * Tries to smartly fix indentation problems related to es6 template
+ * strings in the midst of indented code.
+ *
+ * @default false
+ */
+ smartIndentationFix?: MmmarkConverterOptions["smartIndentationFix"];
+ /**
+ * Prevents weird effects in live previews due to incomplete input.
+ *
+ * @example
+ * ![awkward effect](http://i.imgur.com/YQ9iHTL.gif)
+ * You can prevent this by enabling this option.
+ * @default false
+ */
+ smoothLivePreview?: MmmarkConverterOptions["smoothLivePreview"];
+ /**
+ * If enabled adds an id property to table headers tags.
+ *
+ * @remarks This options only applies if **[tables][]** is enabled.
+ * @default false
+ */
+ tablesHeaderId?: MmmarkConverterOptions["tablesHeaderId"];
+ /**
+ * Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled,
+ * underscores no longer parses into `` and ``
+ *
+ * @example
+ * **input**:
+ *
+ * ```md
+ * __underline word__
+ * ```
+ *
+ * **underline** = false
+ * ```html
+ * underlined word
+ * ```
+ *
+ * **underline** = true
+ * ```html
+ * underlined word
+ * ```
+ * @default false
+ */
+ underline?: MmmarkConverterOptions["underline"];
};
/**
@@ -391,51 +391,51 @@ type MmmarkUserSelectOptions = {
* @returns The options object for the Markdown converter.
*/
const getAllOptions = (
- options?: MmmarkUserSelectOptions
+ options?: MmmarkUserSelectOptions,
): MmmarkConverterOptions => {
- const dfoptions: MmmarkConverterOptions = {
- emoji: true,
- ghCodeBlocks: true,
- parseImgDimensions: true,
- simplifiedAutoLink: true,
- tables: true,
- tasklists: true,
- completeHTMLDocument: false,
- headerLevelStart: 1,
- ellipsis: true,
- encodeEmails: true,
- metadata: false,
- openLinksInNewWindow: true,
- strikethrough: true,
- // ---------------------------------------------------------------------------------
- backslashEscapesHTMLTags: options?.backslashEscapesHTMLTags ?? false,
- customizedHeaderId: options?.customizedHeaderId ?? false,
- disableForced4SpacesIndentedSublists:
- options?.disableForced4SpacesIndentedSublists ?? false,
- extensions: options?.extensions ?? [],
- ghCompatibleHeaderId: options?.ghCompatibleHeaderId ?? false,
- ghMentions: options?.ghMentions ?? false,
- ghMentionsLink: options?.ghMentionsLink ?? "https://github.com/{u}",
- literalMidWordUnderscores: options?.literalMidWordUnderscores ?? false,
- noHeaderId: options?.noHeaderId ?? false,
- omitExtraWLInCodeBlocks: options?.omitExtraWLInCodeBlocks ?? false,
- prefixHeaderId: options?.prefixHeaderId ?? false,
- rawHeaderId: options?.rawHeaderId ?? false,
- rawPrefixHeaderId: options?.rawPrefixHeaderId ?? false,
- requireSpaceBeforeHeadingText:
- options?.requireSpaceBeforeHeadingText ?? false,
- simpleLineBreaks: options?.simpleLineBreaks ?? false,
- splitAdjacentBlockquotes: options?.splitAdjacentBlockquotes ?? false,
- smartIndentationFix: options?.smartIndentationFix ?? false,
- smoothLivePreview: options?.smoothLivePreview ?? false,
- tablesHeaderId: options?.tablesHeaderId ?? false,
- underline: options?.underline ?? false,
- };
- return dfoptions;
+ const dfoptions: MmmarkConverterOptions = {
+ emoji: true,
+ ghCodeBlocks: true,
+ parseImgDimensions: true,
+ simplifiedAutoLink: true,
+ tables: true,
+ tasklists: true,
+ completeHTMLDocument: false,
+ headerLevelStart: 1,
+ ellipsis: true,
+ encodeEmails: true,
+ metadata: false,
+ openLinksInNewWindow: true,
+ strikethrough: true,
+ // ---------------------------------------------------------------------------------
+ backslashEscapesHTMLTags: options?.backslashEscapesHTMLTags ?? false,
+ customizedHeaderId: options?.customizedHeaderId ?? false,
+ disableForced4SpacesIndentedSublists:
+ options?.disableForced4SpacesIndentedSublists ?? false,
+ extensions: options?.extensions ?? [],
+ ghCompatibleHeaderId: options?.ghCompatibleHeaderId ?? false,
+ ghMentions: options?.ghMentions ?? false,
+ ghMentionsLink: options?.ghMentionsLink ?? "https://github.com/{u}",
+ literalMidWordUnderscores: options?.literalMidWordUnderscores ?? false,
+ noHeaderId: options?.noHeaderId ?? false,
+ omitExtraWLInCodeBlocks: options?.omitExtraWLInCodeBlocks ?? false,
+ prefixHeaderId: options?.prefixHeaderId ?? false,
+ rawHeaderId: options?.rawHeaderId ?? false,
+ rawPrefixHeaderId: options?.rawPrefixHeaderId ?? false,
+ requireSpaceBeforeHeadingText:
+ options?.requireSpaceBeforeHeadingText ?? false,
+ simpleLineBreaks: options?.simpleLineBreaks ?? false,
+ splitAdjacentBlockquotes: options?.splitAdjacentBlockquotes ?? false,
+ smartIndentationFix: options?.smartIndentationFix ?? false,
+ smoothLivePreview: options?.smoothLivePreview ?? false,
+ tablesHeaderId: options?.tablesHeaderId ?? false,
+ underline: options?.underline ?? false,
+ };
+ return dfoptions;
};
export {
- getAllOptions,
- type MmmarkConverterOptions,
- type MmmarkUserSelectOptions,
+ getAllOptions,
+ type MmmarkConverterOptions,
+ type MmmarkUserSelectOptions,
};
diff --git a/src/manage-extensions/index.ts b/src/manage-extensions/index.ts
index aa4a1b6..4a63ae8 100644
--- a/src/manage-extensions/index.ts
+++ b/src/manage-extensions/index.ts
@@ -10,10 +10,10 @@ type MmExtension = ShowdownExtension;
* @throws Throws if `name` is not of type string.
*/
function registerExtension(
- name: string,
- ext: MmExtension | MmExtension[] | (() => MmExtension[] | MmExtension)
+ name: string,
+ ext: MmExtension | MmExtension[] | (() => MmExtension[] | MmExtension),
): void {
- Showdown.extension(name, ext);
+ Showdown.extension(name, ext);
}
/**
@@ -23,7 +23,7 @@ function registerExtension(
* @returns Returns `true` if the extension is valid showdown extension, otherwise `false`.
*/
function validateExtension(ext: MmExtension[] | MmExtension): boolean {
- return Showdown.validateExtension(ext);
+ return Showdown.validateExtension(ext);
}
/**
@@ -32,12 +32,12 @@ function validateExtension(ext: MmExtension[] | MmExtension): boolean {
* @returns {void}
*/
function removeExtensions(): void {
- Showdown.resetExtensions();
+ Showdown.resetExtensions();
}
export {
- registerExtension,
- validateExtension,
- removeExtensions,
- type MmExtension,
+ registerExtension,
+ validateExtension,
+ removeExtensions,
+ type MmExtension,
};
diff --git a/src/subparser/index.ts b/src/subparser/index.ts
index 43e95d2..07a5d7e 100644
--- a/src/subparser/index.ts
+++ b/src/subparser/index.ts
@@ -10,7 +10,7 @@ type MmSubParser = SubParser;
* @throws Throws if `name` is not of type string.
*/
function registerSubParser(name: string, func: SubParser): void {
- return Showdown.subParser(name, func);
+ return Showdown.subParser(name, func);
}
export { registerSubParser, type MmSubParser };