
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@f-fjs/tidy-markdown
Advanced tools
Beautify Markdown, fixing formatting mistakes and converting basic HTML & Unicode into their Markdown equivalents. Based on the conventions in Carrot Creative's Markdown Styleguide and built on Marked.
There is also an Atom Plugin to run this entirely within your editor.
Tidy Markdown is an npm package, so it can be installed like this:
npm install tidy-markdown -g
Tidy Markdown includes a simple CLI. It operates entirely over STDIN/STDOUT. For example:
$ echo "# a header #" | tidy-markdown
# a header
Or using a file:
$ tidy-markdown < ./ugly-markdown
# Some markdown
Lorem ipsum dolor adipiscing
- one
- two
- three
And, of course, we can output to a file too:
$ tidy-markdown < ./ugly-markdown > ./clean-markdown
If you want to rewrite a file in-place, you can use sponge
from moreutils. If you did tidy-markdown < ./README.md > ./README.md
you'd end up with an empty file.
$ tidy-markdown < ./README.md | sponge ./README.md
The --help
arg will make it show a usage page:
$ tidy-markdown --help
usage: tidy-markdown [-h] [-v] [--no-ensure-first-header-is-h1]
Fix ugly markdown. Unformatted Markdown is read from STDIN, formatted, and
written to STDOUT.
Optional arguments:
-h, --help Show this help message and exit.
-v, --version Show program's version number and exit.
--no-ensure-first-header-is-h1
Disable fixing the first header when it isn't an H1.
This is useful if the markdown you're processing
isn't a full document, but rather a piece of a larger
document.
Tidy Markdown only exports one function. Here's an example of how it can be used:
tidyMarkdown = require 'tidy-markdown'
uglyMarkdown = '''
# Some markdown #
Lorem ipsum dolor adipiscing
- one
* two
+ three
'''
cleanMarkdown = tidyMarkdown(uglyMarkdown)
console.log cleanMarkdown
which outputs:
# Some markdown
Lorem ipsum dolor adipiscing
- one
- two
- three
You can also pass options through a 2nd arg, like tidyMarkdown(uglyMarkdown, {ensureFirstHeaderIsH1: false})
. The option ensureFirstHeaderIsH1
is the only one right now.
h1
to smaller without gaps (like an h1
followed by an h4
would be corrected to an h1
followed by an h2
).<em>text</em>
becomes _text_
.Tidy Markdown works hard to keep configuration to a minimum. The goal is to create a highly readable, canonical representation of Markdown, much like gofmt has done for Go. Having extra configuration would defeat that purpose and add extra maintenance work.
That's not to say you shouldn't open issues if you find the output ugly, that's encouraged, especially in the styleguide repo because without criticism it won't get better. However, you should provide examples and a good argument to support the change.
FAQs
Fix ugly markdown.
The npm package @f-fjs/tidy-markdown receives a total of 96 weekly downloads. As such, @f-fjs/tidy-markdown popularity was classified as not popular.
We found that @f-fjs/tidy-markdown 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.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.