
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
noop functions to help formatters and syntax highlighters recognize embedded code
noop functions to help formatters and syntax highlighters recognize embedded code
When embedding other languages in JavaScript, you can mark those strings with a tag function to help JavaScript tools recognize the string as code:
document.body.innerHTML = html`
<p>This is inline HTML</p>
<!-- Including comments -->
<style>.and {css: 'too'}</style>
`;
You can find such tag functions in:
Here are some tools that support them natively:
npm install code-tag
import {html, css, gql, md, sql} from 'code-tag';
// Or:
// const {html, css, gql, md, sql} = require('code-tag');
document.body.innerHTML = html`
<p>This is HTML in JS</p>
`;
document.querySelector('style').textContent = css`
.this.is {
css: 'in JS';
}
`;
await githubQuery(gql`
query {
repository(owner: "fregante", name: "template-tags") {
nameWithOwner
}
}
`);
yourMarkdownConverter(md`
# Markdown
Is _highlighted_ [as well](https://www.youtube.com/watch?v=dQw4w9WgXcQ)
`);
await sqlQuery(sql`select * from users`);
There's also an any
export that you can rename as you please:
import {any as mdx} from 'code-tag';
mdx`
Some other <New>Language</New>
`;
MIT © Federico Brigante
FAQs
noop functions to help formatters and syntax highlighters recognize embedded code
The npm package code-tag receives a total of 13,894 weekly downloads. As such, code-tag popularity was classified as popular.
We found that code-tag 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.