Markdown Content
blog.ts
import const MarkdownIt: MarkdownItConstructor
Main parser/renderer class.
Usage
// node.js, "classic" way:
var MarkdownIt = require('markdown-it'),
md = new MarkdownIt();
var result = md.render('# markdown-it rulezz!');
// node.js, the same, but with sugar:
var md = require('markdown-it')();
var result = md.render('# markdown-it rulezz!');
// browser without AMD, added to "window" on script load
// Note, there are no dash.
var md = window.markdownit();
var result = md.render('# markdown-it rulezz!');
Single line rendering, without paragraph wrap:
var md = require('markdown-it')();
var result = md.renderInline('__markdown-it__ rulezz!');
Example
// commonmark mode
var md = require('markdown-it')('commonmark');
// default mode
var md = require('markdown-it')();
// enable everything
var md = require('markdown-it')({
html: true,
linkify: true,
typographer: true
});
Syntax highlighting
var hljs = require('highlight.js') // https://highlightjs.org/
var md = require('markdown-it')({
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str, true).value;
} catch (__) {}
}
return ''; // use external default escaping
}
});
Or with full wrapper override (if you need assign class to <pre>
):
var hljs = require('highlight.js') // https://highlightjs.org/
// Actual default values
var md = require('markdown-it')({
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return '<pre class="hljs"><code>' +
hljs.highlight(lang, str, true).value +
'</code></pre>';
} catch (__) {}
}
return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
}
});
MarkdownIt from 'markdown-it';
var console: Console
console.Console.log(...data: any[]): void
log(1);
var console: Console
console.Console.log(...data: any[]): void
log(2);
ts
blog.ts
import { function rendererRich(options?: RendererRichOptions): TwoslashRenderer
An alternative renderer that providers better prefixed class names,
with syntax highlight for the info text.
rendererRich, function transformerTwoslash(options?: TransformerTwoslashIndexOptions): _shikijs_core_dist_chunk_tokens_mjs.A
Factory function to create a Shiki transformer for twoslash integrations.
transformerTwoslash } from '@shikijs/twoslash';
function transformerTwoslash(options?: TransformerTwoslashIndexOptions | undefined): ShikiTransformer
Factory function to create a Shiki transformer for twoslash integrations.
transformerTwoslash({
TransformerTwoslashOptions.renderer?: TwoslashRenderer | undefined
Custom renderers to decide how each info should be rendered
renderer: function rendererRich(options?: RendererRichOptions | undefined): TwoslashRenderer
An alternative renderer that providers better prefixed class names,
with syntax highlight for the info text.
rendererRich(), // <--
});
import {
function transformerNotationDiff(options?: TransformerNotationDiffOptions): ShikiTransformer
Use [!code ++]
and [!code --]
to mark added and removed lines.
transformerNotationDiff,
// ...
} from '@shikijs/transformers';
const const code: "console.log('hello')"
code = `console.log('hello')`;
ts
console.log(1);
console.log(1);
console.log(1);
console.log(1);
console.log(1);
js
console.log(1);
console.log(1);
console.log(1);
js
#Heading 2
#Heading 3
#Heading 4
#Heading 5
#Heading 6
npm install @nuxtjs/html-validator --save-dev
bash
yarn add @nuxtjs/html-validator --dev
bash
pnpm i -D @nuxtjs/html-validator
bash
bun install @nuxtjs/html-validator --save-dev
bash
const a = 2;
js
const a: number = 2;
ts
- Block space
function block() {
space();
if (true) {
table();
}
}
ts
- Word highlight
const const obj: {
boo: number;
bar: () => number;
baz: string;
}
obj = {
boo: number
boo: 1,
bar: () => number
bar: () => 2,
baz: string
baz: 'string',
};
const obj: {
boo: number;
bar: () => number;
baz: string;
}
obj.b- bar
- baz
- boo
boo: number
oo;
ts
import { function getHighlighterCore(options?: HighlighterCoreOptions): Promise<HighlighterCore>
Create a Shiki core highlighter instance, with no languages or themes bundled.
Wasm and each language and theme must be loaded manually.
getHighlighterCore } from '@shikijs/core';
const const highlighter: HighlighterCore
highlighter = await function getHighlighterCore(options?: HighlighterCoreOptions | undefined): Promise<HighlighterCore>
Create a Shiki core highlighter instance, with no languages or themes bundled.
Wasm and each language and theme must be loaded manually.
getHighlighterCore({});
const str: string = 1;str = 'Hello';
ts
const const a: 1
a = 1;Custom log messageconst const b: 1
b = 1;Custom error messageconst const c: 1
c = 1;Custom warning messageconst const d: 1
d = 1;Custom annotation message
ts
var Number: NumberConstructor
An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers.
Number.p- parseFloat
- parseInt
- prototype
NumberConstructor.parseInt(string: string, radix?: number | undefined): number
Converts A string to an integer.
arseInt('123', 10);
ts
- Block space
function block() {
space();
if (true) {
table();
}
}
ts
- Word highlight
export function foo() {
const msg = 'Hello World';
console.log(msg); // prints Hello World
}
ts
const options = { foo: 'bar' };
options.foo = 'baz';
console.log(options.foo); // this one will not be highlighted
ts