Skip to main content

latest

A simple utility for wrapping text in various formats, including XML, Markdown, HTML, JSON, YAML, CSV, Plain Text, LaTeX, and Shell.

This package works with DenoIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
94%
Published
a week ago (0.1.0)
function wrapText
wrapText(
text: string,
tag: string,
type?:
"xml"
| "markdown"
| "html"
| "json"
| "yaml"
| "csv"
| "plain"
| "latex"
| "shell"
,
): string

Wraps the given text in the specified tag based on the provided type.

Examples

Example 1

wrapText("Hello, World!", "greeting", "xml"); // Returns: Hello, World!

wrapText("Hello, World!", "greeting", "markdown"); // Returns:

greeting\nHello, World!\n

Parameters

text: string
  • The text to be wrapped.
  • The tag to wrap the text with.
optional
type:
"xml"
| "markdown"
| "html"
| "json"
| "yaml"
| "csv"
| "plain"
| "latex"
| "shell"
= "xml"
  • The type of wrapping to apply.

Return Type

The wrapped text in the specified format.

Add Package

deno add @yawnxyz/fence

Import symbol

import { wrapText } from "@yawnxyz/fence";

---- OR ----

Import directly with a jsr specifier

import { wrapText } from "jsr:@yawnxyz/fence";

Add Package

npx jsr add @yawnxyz/fence

Import symbol

import { wrapText } from "@yawnxyz/fence";

Add Package

yarn dlx jsr add @yawnxyz/fence

Import symbol

import { wrapText } from "@yawnxyz/fence";

Add Package

pnpm dlx jsr add @yawnxyz/fence

Import symbol

import { wrapText } from "@yawnxyz/fence";

Add Package

bunx jsr add @yawnxyz/fence

Import symbol

import { wrapText } from "@yawnxyz/fence";