DEV Community

Valeria
Valeria

Posted on

1

Day 20: Not a Dedent! 🚧

I tried to write a really funny joke about a dedent, but it just didn’t indent well πŸ₯ While my sense of humour is beyond fixing, extra identation can easily be stripped with dedent.

Let's install it e.g. with deno add npm:dedent, create a file, e.g. main.ts and try out:

import d from 'dedent'

console.log(d`
    What do you call a Christmas tree that’s lost its way?
        ...A mistletoe!
    `)
Enter fullscreen mode Exit fullscreen mode

Run with e.g. deno run -A ./main.ts and enjoy perfectly aligned lines:

deno run -A ./main.ts
#What do you call a Christmas tree that’s lost its way?
#    ...A mistletoe!
Enter fullscreen mode Exit fullscreen mode

Extra padding? Gone.
Bad taste and formatting: preservedπŸ‘Œ

Any ideas what dedent could help you with? Share in the comments!

Liked the content and would love to have more of it all year long?

Buy Me A Coffee

Do your career a favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay