Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
md-utils-ts
Advanced tools
Tiny markdown utility functions for Typescript.
Install with npm:
$ npm install --save md-utils-ts
See Implementation for details.
import md, { bold } from "md-utils-ts";
const boldText = bold("some text");
console.log(boldText); // "**some text**"
// Use function from the imported 'md'
const italicText = md.italic("Hello, world!");
console.log(italicText); // "_Hello, world!_"
Note: Table is not supported. You can use markdown-table as well.
Make the text bold.
text
(string): The input text.const result = bold("Hello, world!");
// Output: "**Hello, world!**"
Make the text italic.
text
(string): The input text.const result = italic("Hello, world!");
// Output: "_Hello, world!_"
Add strike-through to the text.
text
(string): The input text.const result = del("Hello, world!");
// Output: "~~Hello, world!~~"
Add underline to the text.
text
(string): The input text.const result = underline("Hello, world!");
// Output: "<u>Hello, world!</u>"
Create an anchor link.
text
(string): The anchor text.href
(string): The URL to link to.const result = anchor("OpenAI", "https://www.openai.com");
// Output: "[OpenAI](https://www.openai.com)"
Create a code block or inline code.
inline
(boolean): Whether the code should be inline or in a block.language
(string): The code language for syntax highlighting.text
(string): The code content.const tsCodeBlock = code(false)("ts");
const result = tsCodeBlock("console.log('Hello, world!');");
// Output:
// "```ts
// console.log('Hello, world!');
// ```"
Create inline code with optional syntax highlighting.
text
(string): The code content.const code = inlineCode("console.log('Hello, world!');");
// Output:
// "`console.log('Hello, world!');`"
Create a code block with optional syntax highlighting.
language
(string, optional): The code language for syntax highlighting.text
(string): The code content.const code = codeBlock("ts")("console.log('Hello, world!');");
// Output:
// "```ts
// console.log('Hello, world!');
// ```"
Create an equation block or inline equation.
inline
(boolean): Whether the equation should be inline or in a block.text
(string): The equation content.const equationBlock = equation(false)("x^2 + y^2 = z^2");
// Output:
// "$$
// x^2 + y^2 = z^2
// $$"
const inlineEquation = equation(true)("E = mc^2");
// Output: "$E = mc^2$"
Create inline code with optional syntax highlighting.
text
(string): The equation content.const result = inlineEquation("E = mc^2");
// Output: "$E = mc^2$"
Create an equation block or inline equation.
text
(string): The equation content.const result = equationBlock("x^2 + y^2 = z^2");
// Output:
// "$$
// x^2 + y^2 = z^2
// $$"
Create a heading with the specified level.
level
(number): The level of the heading (1 to 6).text
(string): The heading text.const heading = h(2)("Hello, world!");
// Output: "## Hello, world!"
Create a level 1 heading.
text
(string): The heading text.const heading = h1("Title");
// Output:
// # Title
Create a level 2 heading.
text
(string): The heading text.const heading = h2("Subtitle");
// Output:
// ## Subtitle
Create a level 3 heading.
text
(string): The heading text.const heading = h3("Subsection");
// Output:
// ### Subsection
Create a level 4 heading.
text
(string): The heading text.const heading = h4("Subsubsection");
// Output:
// #### Subsubsection
Create a level 5 heading.
text
(string): The heading text.const heading = h5("Subsubsubsection");
// Output:
// ##### Subsubsubsection
Create a level 6 heading.
text
(string): The heading text.const heading = h6("Subsubsubsubsection");
// Output:
// ###### Subsubsubsubsection
Convert text to a blockquote.
text
(string): The input text.const quotedText = quote("This is a quoted text.");
// Output:
// > This is a quoted text.
Create a bullet point list item.
text
(string): The content of the bullet point.count
(number, optional): The optional index/count of the bullet point.const bulletPoint = bullet("List item");
// Output:
// - List item
const numberedBulletPoint = bullet("List item", 1);
// Output:
// 1. List item
Create a todo list item.
text
(string): The content of the todo item.checked
(boolean): Whether the todo item is checked or not.const uncheckedTodo = todo("Task to be done", false);
// Output:
// - [ ] Task to be done
const checkedTodo = todo("Completed task", true);
// Output:
// - [x] Completed task
Create an image element.
alt
(string): The alt text for the image.href
(string): The URL of the image.const imageElement = image("Description", "https://example.com/image.jpg");
// Output:
// ![Description](https://example.com/image.jpg)
Create a horizontal divider.
const dividerElement = divider();
// Output:
// ---
Create a collapsible details element.
summary
(string): The summary text for the details element.details
(string): The details/content of the details element.const detailsElement = details("Click to expand", "Hidden content");
// Output:
// <details>
// <summary>Click to expand</summary>
//
// Hidden content
// </details>
Create a superscript text.
text
(string): The input text.const superscriptText = sup("2");
// Output:
// <sup>2</sup>
Create a subscript text.
text
(string): The input text.const subscriptText = sub("2");
// Output:
// <sub>2</sub>
Indent the text with a specified number of spaces.
space
(number, default: 2): The number of spaces to indent with.text
(string): The input text.level
(number, default: 1): The level of indentation.const indentedText = indent(4)("Indented text", 2);
// Output:
// " Indented text"
FAQs
Tiny markdown utility functions for Typescript.
The npm package md-utils-ts receives a total of 17,236 weekly downloads. As such, md-utils-ts popularity was classified as popular.
We found that md-utils-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.