Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
remark-usage
Advanced tools
Add a usage example to a README with remark.
npm:
npm install remark-usage
This section is rendered by this module from example.js.
Dependencies:
var fs = require('fs');
var remark = require('remark');
var usage = require('remark-usage'); // This is changed from `./index.js` to `remark-usage`
Read and parse readme.md
:
var readme = fs.readFileSync('readme.md', 'utf-8');
var ast = remark().use(usage).parse(readme);
Log something with a language flag:
## Installation
Or without language:
[npm][]:
Log something which is never captured:
function neverCalled() {
console.log('javascript', 'alert("test")');
}
Log something which isn’t captured because it’s not a string.
console.log(this);
remark.use(usage[, options])
Adds example.js
to the Usage
section in a readme.md
.
Removes the current content between the heading containing the text “usage”, and the next heading of the same (or higher) depth, and replaces it with the example.
The example is run as JavaScript. Line comments are parsed as Markdown.
Calls to console.log()
are exposed as code blocks, containing the logged
values (optionally with a language flag).
It’s easiest to check out and compare example.js
with the
above Usage section.
cwd
example.js
options
options.cwd
string?
— Path to a directory containing a node module. Used to infer name
,
main
, and example
.
options.name
string?
— Name of the module, inferred from package.json
s name
property.
Used to rewrite require('./index.js')
to require('some-name')
.
options.main
string?
— Path to the main script. Resolved from package.json
s main
property (or index.js
). Used to rewrite require('./index.js')
to
require('some-name')
.
options.example
string?
— Path to the example script. remark-usage
checks for
docs/example.js
, doc/example.js
, examples/index.js
, example/index.js
,
and example.js
.
options.heading
string?
, default: 'usage'
— Heading to look for, wrapped in
new RegExp('^(' + value + ')$', 'i');
.
FAQs
remark plugin to add a usage example to your readme
The npm package remark-usage receives a total of 5,407 weekly downloads. As such, remark-usage popularity was classified as popular.
We found that remark-usage demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.