本文整理匯總了TypeScript中json2md.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript json2md.default方法的具體用法?TypeScript json2md.default怎麽用?TypeScript json2md.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類json2md
的用法示例。
在下文中一共展示了json2md.default方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it("Table", () => {
json2md([
{
table: {
headers: EXAMPLE_STRING_ARRAY,
rows: [
{
A: EXAMPLE_STRING,
B: EXAMPLE_STRING
}
]
}
}
]);
json2md([
{
table: {
headers: EXAMPLE_STRING_ARRAY,
rows: [
EXAMPLE_STRING_ARRAY
]
}
}
]);
});
示例2:
it("Custom types", () => {
const customConverter: json2md.ConverterCallback<string> = (input, json2md) => {
return `Hello ${input} world!`;
};
json2md.converters.customConverter = customConverter;
json2md([
{
customConverter: EXAMPLE_STRING
}
]);
});
示例3: sum
it("Big example", () => {
const md: string = json2md([
{
h1: "JSON To Markdown"
},
{
blockquote: "A JSON to Markdown converter."
},
{
img: [
{
title: "Some image",
source: "https://example.com/some-image.png"
},
{
title: "Another image",
source: "https://example.com/some-image1.png"
},
{
title: "Yet another image",
source: "https://example.com/some-image2.png"
}
]
},
{
h2: "Features"
},
{
ul: [
"Easy to use",
"You can programatically generate Markdown content",
"..."
]
},
{
h2: "How to contribute"
},
{
ol: [
"Fork the project",
"Create your branch",
"Raise a pull request"
]
},
{
h2: "Code blocks"
},
{
p: "Below you can see a code block example."
},
{
code: {
language: "js",
content: [
"function sum (a, b) {",
" return a + b;",
"}",
"sum(1, 2);"
]
}
}
]);
});