@cobapen/markdown 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,4 +14,4 @@ https://cobapen.github.io/markdown
14
14
  - fenced code block with filename, line-number support
15
15
  - server side syntax highlighting
16
16
  - server side math rendering
17
-
17
+ - complex table rendering
@@ -4,10 +4,5 @@ import Token from "markdown-it/lib/token.mjs";
4
4
  interface Env {
5
5
  showCodeTitleByDefault?: boolean;
6
6
  }
7
- /**
8
- * Custom fence renderer for markdown-it.
9
- *
10
- * see: markdown-it/lib/renderer.mjs
11
- */
12
7
  export declare function fence_custom(tokens: Token[], idx: number, options: Options, env: Env, slf: Renderer): string;
13
8
  export {};
@@ -1,10 +1,5 @@
1
1
  import { escapeHtml, unescapeAll } from "markdown-it/lib/common/utils.mjs";
2
2
  import { InfoString } from "./info-string.js";
3
- /**
4
- * Custom fence renderer for markdown-it.
5
- *
6
- * see: markdown-it/lib/renderer.mjs
7
- */
8
3
  export function fence_custom(tokens, idx, options, env, slf) {
9
4
  const token = tokens[idx];
10
5
  const info_str = token.info ? unescapeAll(token.info).trim() : "";
@@ -21,9 +16,6 @@ export function fence_custom(tokens, idx, options, env, slf) {
21
16
  if (highlighted.indexOf("<pre") === 0) {
22
17
  return highlighted + "\n";
23
18
  }
24
- // If language exists, inject class gently, without modifying original token.
25
- // May be, one day we will add .deepClone() for token and simplify this part, but
26
- // now we prefer to keep things local.
27
19
  if (info.hasLang) {
28
20
  const i = token.attrIndex("class");
29
21
  const tmpAttrs = token.attrs ? token.attrs.slice() : [];
@@ -34,7 +26,6 @@ export function fence_custom(tokens, idx, options, env, slf) {
34
26
  tmpAttrs[i] = tmpAttrs[i].slice();
35
27
  tmpAttrs[i][1] += " " + options.langPrefix + langName;
36
28
  }
37
- // Fake token just to render attributes
38
29
  const tmpToken = {
39
30
  attrs: tmpAttrs
40
31
  };
@@ -0,0 +1,2 @@
1
+ export declare function highlightWithLineNumber(code: string, lang: string, linestart?: number): string;
2
+ export declare function highlighterForMarkdownIt(str: string, lang: string, attrs: string): string;
@@ -1,51 +1,17 @@
1
- /**
2
- * highlight.ts
3
- * 2023-11-20
4
- * provides a custom highlighter for MarkdownIt
5
- */
6
1
  import hljs from "highlight.js";
7
2
  import { InfoString } from "./info-string.js";
8
3
  function _debuglog(..._args) {
9
- // if (_debuglog.caller.name !== "") return;
10
- // console.log(...args);
11
4
  }
12
- /** Get digits of the number. e.g. 1000 => 4 */
13
5
  function numDigits(n) {
14
6
  return Math.floor(n).toString().length;
15
7
  }
16
- /** Print a decimal nicely */
17
8
  function niceDec(n) {
18
9
  return n.toFixed(3);
19
10
  }
20
- /**
21
- * Highlight function with line number support
22
- *
23
- * @param code
24
- * @param lang
25
- * @param linestart
26
- * @returns
27
- */
28
11
  export function highlightWithLineNumber(code, lang, linestart) {
29
12
  try {
30
- /** convert if lang is specified + supported by highlight.js */
31
13
  if (lang && hljs.getLanguage(lang)) {
32
- /** do conversion */
33
14
  let htmlLines = hljs.highlight(code, { language: lang }).value;
34
- /**
35
- * Attach the line number if specified.
36
- *
37
- * The given code is rendered in <pre><code>, so each line is terminated by '\n'.
38
- * Split the input, wrap them by <div class="line">.
39
- * At the beginning of each line, <span class="line-no"> is added.
40
- *
41
- * default styles are embedded so that the text is readable
42
- * even if css was not applied.
43
- *
44
- * default-styles:
45
- * - display: inline-block
46
- * - user-select: none
47
- * - width: ${numDigits}em
48
- */
49
15
  if (linestart !== undefined) {
50
16
  const lines = htmlLines.split("\n");
51
17
  const elWidth = numDigits(linestart + lines.length) * 0.8;
@@ -64,9 +30,6 @@ export function highlightWithLineNumber(code, lang, linestart) {
64
30
  return htmlLines;
65
31
  }
66
32
  else {
67
- // no language , no highlighting.
68
- // If you want line numbers without highlighting, set language to
69
- // "nohighlight" or "text"
70
33
  return "";
71
34
  }
72
35
  }
@@ -74,14 +37,6 @@ export function highlightWithLineNumber(code, lang, linestart) {
74
37
  return "";
75
38
  }
76
39
  }
77
- /**
78
- * Exported function for markdown-it
79
- *
80
- * @param str
81
- * @param lang
82
- * @param attrs
83
- * @returns
84
- */
85
40
  export function highlighterForMarkdownIt(str, lang, attrs) {
86
41
  _debuglog(lang ? lang : "(lang is empty or undefined)");
87
42
  const info = new InfoString(lang + " " + attrs);
@@ -1,6 +1,3 @@
1
- /**
2
- * InfoString parses info_string from fenced code block.
3
- */
4
1
  export declare class InfoString {
5
2
  private readonly _lang;
6
3
  private readonly _attrs;
@@ -12,15 +9,11 @@ export declare class InfoString {
12
9
  get title(): string;
13
10
  get linestart(): number | undefined;
14
11
  get hasLang(): boolean;
15
- /** Parse info_string into an array of strings. All quotes are removed*/
16
12
  static parseInfoString(info: string): string[];
17
- /** Parse metadata notation "{filename:line, ...}"" */
18
13
  static parseMetaNotation(text: string): {
19
14
  filename: string;
20
15
  line: number;
21
16
  } | undefined;
22
- /** From attributes list, return title metadata */
23
17
  static getTitle(attr: string[]): string;
24
- /** From attributes list, return line number if defined */
25
18
  static getLineStart(attr: string[]): number | undefined;
26
19
  }
@@ -1,6 +1,3 @@
1
- /**
2
- * InfoString parses info_string from fenced code block.
3
- */
4
1
  export class InfoString {
5
2
  _lang;
6
3
  _attrs;
@@ -36,32 +33,10 @@ export class InfoString {
36
33
  get hasLang() {
37
34
  return this._lang.length > 0;
38
35
  }
39
- /** Parse info_string into an array of strings. All quotes are removed*/
40
36
  static parseInfoString(info) {
41
- // There are 4 possible tokens, but it can be reduced to 2 patterns.
42
- // arg, "arg quoted", key=value, key="value quoted"
43
- //
44
- // This function returns a quote-removed string.
45
- //
46
- // const regex = /([^\s]+=)?(?:"([^"]*)"|'([^']*)'|([^\s]+))/g;
47
- // ~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48
- // key= "value" 'value' value
49
- //
50
- // The regex above does not support escape letters. The next regex
51
- // is escape char aware.
52
- //
53
- // NOTE: This class is designed to handle escape letters. However, tools
54
- // might decide to unescape info_string before used (e.g. markdown-it).
55
- // In such case, you might need to use double-escaped quotes.
56
- //
57
- const dq = "[^\"\\\\]*(?:\\\\.|[^\"\\\\]*)*"; // [^"]*
58
- const sq = "[^\'\\\\]*(?:\\\\.|[^\'\\\\]*)*"; // [^']*
59
- // ~~~~~~~~~~ ~~~~~ ~~~~~~~~~~
60
- // char seq ( escape char seq )*
61
- //
37
+ const dq = "[^\"\\\\]*(?:\\\\.|[^\"\\\\]*)*";
38
+ const sq = "[^\'\\\\]*(?:\\\\.|[^\'\\\\]*)*";
62
39
  const ptn = `([^\\s]+=)?(?:"(${dq})"|'(${sq})'|([^\\s]+))`;
63
- // ~~~~~~~~~~ ~~~~~~~~~ ~~~~~~~~~ ~~~~~~~~~
64
- // key= "value" 'value' value
65
40
  const regex = new RegExp(ptn, "g");
66
41
  const result = [];
67
42
  let match;
@@ -72,7 +47,6 @@ export class InfoString {
72
47
  }
73
48
  return result;
74
49
  }
75
- /** Parse metadata notation "{filename:line, ...}"" */
76
50
  static parseMetaNotation(text) {
77
51
  const match = text.match(/^\{\s*([^:]+):(\d+)\s*\}$/);
78
52
  if (match) {
@@ -83,7 +57,6 @@ export class InfoString {
83
57
  }
84
58
  return undefined;
85
59
  }
86
- /** From attributes list, return title metadata */
87
60
  static getTitle(attr) {
88
61
  const titleAttr = attr.find(x => x.startsWith("title=")) ?? "";
89
62
  if (titleAttr.length > 0) {
@@ -108,7 +81,6 @@ export class InfoString {
108
81
  }
109
82
  return "";
110
83
  }
111
- /** From attributes list, return line number if defined */
112
84
  static getLineStart(attr) {
113
85
  const lineAttr = attr.find(x => x.startsWith("linestart=")) ?? "";
114
86
  if (lineAttr.length > 0) {
package/lib/index.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import markdownIt, { Options as MarkdownOptions } from "markdown-it";
2
+ import { Options as MathOptions } from "./math/mathjax.js";
3
+ export interface Config {
4
+ showCodeTitleByDefault: boolean;
5
+ markdown: Partial<MarkdownOptions>;
6
+ math: Partial<MathOptions>;
7
+ }
8
+ export type Options = Partial<Config>;
9
+ export declare class CMarkdown {
10
+ private readonly _config;
11
+ private readonly _mj;
12
+ private readonly _md;
13
+ constructor(option?: Options);
14
+ setup(md: markdownIt): void;
15
+ render(text: string): string;
16
+ mathcss(): string;
17
+ }
@@ -1,13 +1,9 @@
1
1
  import markdownIt from "markdown-it";
2
2
  import advTable from "markdown-it-adv-table";
3
3
  import anchor from "markdown-it-anchor";
4
- // @ts-ignore
5
4
  import cjkbreaks from "markdown-it-cjk-breaks";
6
- // @ts-ignore
7
5
  import deflist from "markdown-it-deflist";
8
- // @ts-ignore
9
6
  import footnote from "markdown-it-footnote";
10
- // @ts-ignore
11
7
  import toc from "markdown-it-table-of-contents";
12
8
  import { fence_custom } from "./code/fence-custom.js";
13
9
  import { highlighterForMarkdownIt } from "./code/highlight.js";
@@ -42,11 +38,6 @@ export class CMarkdown {
42
38
  this._md = md;
43
39
  this.setup(md);
44
40
  }
45
- /**
46
- * Install plugins and renderers to the markdown-it instance.
47
- *
48
- * @param md The instance
49
- */
50
41
  setup(md) {
51
42
  md.renderer.rules.fence = fence_custom;
52
43
  md.use(anchor)
@@ -60,20 +51,10 @@ export class CMarkdown {
60
51
  includeLevel: [2, 3],
61
52
  });
62
53
  }
63
- /**
64
- * Render html from markdown.
65
- *
66
- * @param text markdown text
67
- * @returns html text
68
- */
69
54
  render(text) {
70
- const env = { ...this._config }; // env object must s
55
+ const env = { ...this._config };
71
56
  return this._md.render(text, env);
72
57
  }
73
- /**
74
- * Returns the MathJax CSS.
75
- * @returns
76
- */
77
58
  mathcss() {
78
59
  return this._mj.stylesheet();
79
60
  }
@@ -1,5 +1,5 @@
1
- import { PluginWithOptions } from "markdown-it";
2
- import Token from "markdown-it/lib/token.mjs";
1
+ import type { PluginWithOptions } from "markdown-it";
2
+ import type Token from "markdown-it/lib/token.mjs";
3
3
  type ReplaceHandler = (link: string, env: any, token: Token) => string;
4
4
  interface Options {
5
5
  replace: ReplaceHandler;
@@ -54,14 +54,6 @@ export interface Options {
54
54
  tex?: Partial<TexConfig>;
55
55
  chtml?: Partial<CHTMLConfig>;
56
56
  }
57
- /**
58
- * Initialize and encapsulates mathjax instances to generate
59
- * CommonHTML from TeX input.
60
- *
61
- * There are 2 important methods. One converts the input.
62
- * The other returns a stylesheet document. The stylesheet must be included
63
- * in your HTML document to render the equation properly.
64
- */
65
57
  export declare class MathjaxEngine {
66
58
  option: Options;
67
59
  adaptor: LiteAdaptor;
@@ -69,20 +61,7 @@ export declare class MathjaxEngine {
69
61
  chtml: CHTML<N, T, D>;
70
62
  html: MathDocument<N, T, D>;
71
63
  constructor(option?: Partial<Options>);
72
- /**
73
- * convert TeX input to CHTML.
74
- *
75
- * @param tex input string
76
- * @param override parameter to override the defaults, if you wish to
77
- * @returns
78
- */
79
64
  convert(tex: string, override?: Partial<Options>): string;
80
- /**
81
- * returns adaptive css (stylesheet for the processed equations only),
82
- * or the full mathjax css (if configured)
83
- *
84
- * @returns css content
85
- */
86
65
  stylesheet(): string;
87
66
  }
88
67
  export {};
@@ -1,14 +1,5 @@
1
- /**
2
- * mathjax.ts
3
- *
4
- * Server-Side Mathjax converter from TeX input to CommonHTML.
5
- *
6
- * see official examples for more information
7
- * https://github.com/mathjax/mathjax-v3
8
- * https://github.com/mathjax/MathJax-demos-node/blob/master/direct/tex2chtml
9
- */
10
1
  import { merge } from "lodash-es";
11
- import { LiteElement } from "mathjax-full/js/adaptors/lite/Element.js"; /* N */
2
+ import { LiteElement } from "mathjax-full/js/adaptors/lite/Element.js";
12
3
  import { liteAdaptor } from "mathjax-full/js/adaptors/liteAdaptor.js";
13
4
  import { RegisterHTMLHandler } from "mathjax-full/js/handlers/html.js";
14
5
  import { AllPackages } from "mathjax-full/js/input/tex/AllPackages.js";
@@ -25,20 +16,12 @@ const defaultOption = {
25
16
  packages: AllPackages,
26
17
  },
27
18
  chtml: {
28
- scale: 1.21, // magic # chosen which look nice for me
19
+ scale: 1.21,
29
20
  fontURL: MATHJAX_DEFAULT_FONT_URL,
30
21
  adaptiveCSS: true,
31
22
  exFactor: 5,
32
23
  },
33
24
  };
34
- /**
35
- * Initialize and encapsulates mathjax instances to generate
36
- * CommonHTML from TeX input.
37
- *
38
- * There are 2 important methods. One converts the input.
39
- * The other returns a stylesheet document. The stylesheet must be included
40
- * in your HTML document to render the equation properly.
41
- */
42
25
  export class MathjaxEngine {
43
26
  option;
44
27
  adaptor;
@@ -75,13 +58,6 @@ export class MathjaxEngine {
75
58
  adaptor.append(math.typesetRoot, text);
76
59
  }
77
60
  }
78
- /**
79
- * convert TeX input to CHTML.
80
- *
81
- * @param tex input string
82
- * @param override parameter to override the defaults, if you wish to
83
- * @returns
84
- */
85
61
  convert(tex, override) {
86
62
  const node = this.html.convert(tex, {
87
63
  display: !(override?.inline ?? this.option.inline),
@@ -97,12 +73,6 @@ export class MathjaxEngine {
97
73
  return "ERROR";
98
74
  }
99
75
  }
100
- /**
101
- * returns adaptive css (stylesheet for the processed equations only),
102
- * or the full mathjax css (if configured)
103
- *
104
- * @returns css content
105
- */
106
76
  stylesheet() {
107
77
  return this.adaptor.textContent(this.chtml.styleSheet(this.html));
108
78
  }
@@ -0,0 +1,3 @@
1
+ import type { PluginSimple } from "markdown-it";
2
+ import { MathjaxEngine } from "./mathjax.js";
3
+ export declare function mdmath(math: MathjaxEngine): PluginSimple;
@@ -1,17 +1,5 @@
1
- /**
2
- * mdmath.ts
3
- *
4
- * MarkdownIt extension for math equation processing
5
- */
6
1
  import katex from "katex";
7
2
  import { math_block, math_inline } from "./mdparser.js";
8
- /**
9
- * Returns a MarkdownIt renderer to render inline/block TeX into HTML.
10
- * `KaTeX` is used for inline math, `MathJax` is used for block math.
11
- *
12
- * @param mathjax mathjax engine (used for block math processing)
13
- * @returns
14
- */
15
3
  function getRenderers(mathjax) {
16
4
  function renderInlineMath(tex) {
17
5
  return katex.renderToString(tex, {
@@ -47,12 +35,6 @@ function getRenderers(mathjax) {
47
35
  blockRenderer,
48
36
  };
49
37
  }
50
- /**
51
- * returns a Markdown-It plugin
52
- *
53
- * @param math mathjax Engine to use
54
- * @returns
55
- */
56
38
  export function mdmath(math) {
57
39
  const renderer = getRenderers(math);
58
40
  return (md) => {
@@ -1,8 +1,3 @@
1
- /**
2
- * mdparser.ts
3
- *
4
- * provides methods to parse MarkdownIt token stream and extract math equations.
5
- */
6
1
  import StateBlock from "markdown-it/lib/rules_block/state_block.mjs";
7
2
  import StateInline from "markdown-it/lib/rules_inline/state_inline.mjs";
8
3
  export declare function math_inline(state: StateInline, silent: boolean): boolean;
@@ -1,26 +1,15 @@
1
- /**
2
- * mdparser.ts
3
- *
4
- * provides methods to parse MarkdownIt token stream and extract math equations.
5
- */
6
- /**
7
- * Tests if potential opening or closing delimieter
8
- * Assumes that there is a "$" at state.src[pos]
9
- */
10
1
  function isValidDelim(state, pos) {
11
2
  const max = state.posMax;
12
3
  let can_open = true;
13
4
  let can_close = true;
14
5
  const prevChar = pos > 0 ? state.src.charCodeAt(pos - 1) : -1;
15
6
  const nextChar = pos + 1 <= max ? state.src.charCodeAt(pos + 1) : -1;
16
- // Check non-whitespace conditions for opening and closing, and
17
- // check that closing delimeter isn't followed by a number
18
- if (prevChar === 0x20 /* " " */ ||
19
- prevChar === 0x09 /* \t */ ||
20
- (nextChar >= 0x30 /* "0" */ && nextChar <= 0x39) /* "9" */) {
7
+ if (prevChar === 0x20 ||
8
+ prevChar === 0x09 ||
9
+ (nextChar >= 0x30 && nextChar <= 0x39)) {
21
10
  can_close = false;
22
11
  }
23
- if (nextChar === 0x20 /* " " */ || nextChar === 0x09 /* \t */) {
12
+ if (nextChar === 0x20 || nextChar === 0x09) {
24
13
  can_open = false;
25
14
  }
26
15
  return {
@@ -41,26 +30,18 @@ export function math_inline(state, silent) {
41
30
  state.pos += 1;
42
31
  return true;
43
32
  }
44
- // First check for and bypass all properly escaped delimieters
45
- // This loop will assume that the first leading backtick can not
46
- // be the first character in state.src, which is known since
47
- // we have found an opening delimieter already.
48
33
  const start = state.pos + 1;
49
34
  match = start;
50
35
  while ((match = state.src.indexOf("$", match)) !== -1) {
51
- // Found potential $, look for escapes, pos will point to
52
- // first non escape when complete
53
36
  pos = match - 1;
54
37
  while (state.src[pos] === "\\") {
55
38
  pos -= 1;
56
39
  }
57
- // Even number of escapes, potential closing delimiter found
58
40
  if ((match - pos) % 2 == 1) {
59
41
  break;
60
42
  }
61
43
  match += 1;
62
44
  }
63
- // No closing delimter found. Consume $ and continue.
64
45
  if (match === -1) {
65
46
  if (!silent) {
66
47
  state.pending += "$";
@@ -68,7 +49,6 @@ export function math_inline(state, silent) {
68
49
  state.pos = start;
69
50
  return true;
70
51
  }
71
- // Check if we have empty content, ie: $$. Do not parse.
72
52
  if (match - start === 0) {
73
53
  if (!silent) {
74
54
  state.pending += "$$";
@@ -76,7 +56,6 @@ export function math_inline(state, silent) {
76
56
  state.pos = start + 1;
77
57
  return true;
78
58
  }
79
- // Check for valid closing delimiter
80
59
  res = isValidDelim(state, match);
81
60
  if (!res.can_close) {
82
61
  if (!silent) {
@@ -113,7 +92,6 @@ export function math_block(state, start, end, silent) {
113
92
  return true;
114
93
  }
115
94
  if (firstLine.trim().slice(-2) === "$$") {
116
- // Single line expression
117
95
  firstLine = firstLine.trim().slice(0, -2);
118
96
  found = true;
119
97
  }
@@ -125,7 +103,6 @@ export function math_block(state, start, end, silent) {
125
103
  pos = state.bMarks[next] + state.tShift[next];
126
104
  max = state.eMarks[next];
127
105
  if (pos < max && state.tShift[next] < state.blkIndent) {
128
- // non-empty line with negative indent should stop the list:
129
106
  break;
130
107
  }
131
108
  if (state.src.slice(pos, max).trim().slice(-2) === "$$") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cobapen/markdown",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "A markdown converter for cobapen website",
5
5
  "keywords": [
6
6
  "markdown"
@@ -8,8 +8,8 @@
8
8
  "license": "MIT",
9
9
  "author": "yamavol",
10
10
  "type": "module",
11
- "main": "dist/index.js",
12
- "types": "dist/index.d.ts",
11
+ "main": "lib/index.js",
12
+ "types": "lib/index.d.ts",
13
13
  "homepage": "https://github.com/cobapen/markdown#readme",
14
14
  "bugs": {
15
15
  "url": "https://github.com/cobapen/markdown/issues"
@@ -19,21 +19,20 @@
19
19
  "url": "git+https://github.com/cobapen/markdown.git"
20
20
  },
21
21
  "files": [
22
- "dist/**/*.js",
23
- "dist/**/*.d.ts"
22
+ "lib/**/*.js",
23
+ "lib/**/*.d.ts"
24
24
  ],
25
25
  "engines": {
26
26
  "node": ">=20.11.0 <21 || >=21.2.0"
27
27
  },
28
28
  "scripts": {
29
29
  "build": "tsc",
30
- "build:dist": "tsc --build tsconfig.dist.json",
31
- "build:doc": "tsc && node docs/build.js",
30
+ "build:dev": "tsc --build tsconfig.dev.json",
31
+ "build:doc": "npm run build && node docs/build.js",
32
32
  "test": "vitest",
33
33
  "coverage": "vitest run --coverage",
34
34
  "lint": "eslint src",
35
- "lint:fix": "eslint src --fix",
36
- "lint:dist": "eslint dist --fix"
35
+ "lint:fix": "eslint src --fix"
37
36
  },
38
37
  "dependencies": {
39
38
  "highlight.js": "^11.11.1",
@@ -49,7 +48,7 @@
49
48
  "mathjax-full": "^3.2.2"
50
49
  },
51
50
  "devDependencies": {
52
- "@stylistic/eslint-plugin": "^4.2.0",
51
+ "@cobapen/eslint-config": "^0.4.0",
53
52
  "@types/katex": "^0.16.7",
54
53
  "@types/lodash-es": "^4.17.12",
55
54
  "@types/markdown-it": "^14.1.2",
@@ -57,10 +56,8 @@
57
56
  "@types/node": "^22.14.1",
58
57
  "@vitest/coverage-v8": "^3.1.1",
59
58
  "eslint": "^9.24.0",
60
- "eslint-plugin-import": "^2.31.0",
61
59
  "mustache": "^4.2.0",
62
60
  "typescript": "^5.8.3",
63
- "typescript-eslint": "^8.29.1",
64
61
  "vitest": "^3.1.1"
65
62
  }
66
63
  }
@@ -1,18 +0,0 @@
1
- /**
2
- * Highlight function with line number support
3
- *
4
- * @param code
5
- * @param lang
6
- * @param linestart
7
- * @returns
8
- */
9
- export declare function highlightWithLineNumber(code: string, lang: string, linestart?: number): string;
10
- /**
11
- * Exported function for markdown-it
12
- *
13
- * @param str
14
- * @param lang
15
- * @param attrs
16
- * @returns
17
- */
18
- export declare function highlighterForMarkdownIt(str: string, lang: string, attrs: string): string;
package/dist/index.d.ts DELETED
@@ -1,42 +0,0 @@
1
- import markdownIt, { Options as MarkdownOptions } from "markdown-it";
2
- import { Options as MathOptions } from "./math/mathjax.js";
3
- export interface Config {
4
- /**
5
- * Set "true" to display the title (if specified) of the fenced code block.
6
- * The title is hidden by default, and user must explicitly override the style.
7
- */
8
- showCodeTitleByDefault: boolean;
9
- /**
10
- * MarkdownIt options
11
- */
12
- markdown: Partial<MarkdownOptions>;
13
- /**
14
- * MathJax options
15
- */
16
- math: Partial<MathOptions>;
17
- }
18
- export type Options = Partial<Config>;
19
- export declare class CMarkdown {
20
- private readonly _config;
21
- private readonly _mj;
22
- private readonly _md;
23
- constructor(option?: Options);
24
- /**
25
- * Install plugins and renderers to the markdown-it instance.
26
- *
27
- * @param md The instance
28
- */
29
- setup(md: markdownIt): void;
30
- /**
31
- * Render html from markdown.
32
- *
33
- * @param text markdown text
34
- * @returns html text
35
- */
36
- render(text: string): string;
37
- /**
38
- * Returns the MathJax CSS.
39
- * @returns
40
- */
41
- mathcss(): string;
42
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * mdmath.ts
3
- *
4
- * MarkdownIt extension for math equation processing
5
- */
6
- import { PluginSimple } from "markdown-it";
7
- import { MathjaxEngine } from "./mathjax.js";
8
- /**
9
- * returns a Markdown-It plugin
10
- *
11
- * @param math mathjax Engine to use
12
- * @returns
13
- */
14
- export declare function mdmath(math: MathjaxEngine): PluginSimple;
File without changes