@diplodoc/quote-link-extension
v0.1.6
Published
Quote link extension for Diplodoc platform
Maintainers
Keywords
Readme
Diplodoc quote link extension
Extension for the Diplodoc platform that adds quote link blocks (Markdown blockquotes with data-quotelink).
Installation
npm install @diplodoc/quote-link-extensionContents
- Prepared runtime — scripts and styles for the browser
- MarkdownIt transform plugin — integration with @diplodoc/transform
Quickstart
Attach the plugin to the transformer:
import quoteLinkExtension from '@diplodoc/quote-link-extension';
import transform from '@diplodoc/transform';
const {result} = await transform(
`
> [link title](http://example.ru){data-quotelink="true"}
>
> link content
`,
{
plugins: [quoteLinkExtension.transform({bundle: false})],
},
);Prepared runtime
It is necessary to add runtime scripts to make quote links interactive on your page.
You can add assets files which were generated by the MarkdownIt transform plugin.
<html>
<head>
<!-- Read more about '_assets/quote-link-extension.js' and '_assets/quote-link-extension.css' in 'Transform plugin' section -->
<script src="_assets/quote-link-extension.js" async></script>
<link rel="stylesheet" href="_assets/quote-link-extension.css" />
</head>
<body>
${result.html}
</body>
</html>Or you can just include runtime's source code in your bundle.
import '@diplodoc/quote-link-extension/runtime';
import '@diplodoc/quote-link-extension/runtime/styles.css';Public CSS variables
--yfm-quote-link-background— background color of the quote link. Default:rgb(242, 242, 242). For dark theme:rgb(56, 52, 56).--yfm-quote-link-background-hover— background on hover. Default:rgba(0, 0, 0, 0.05). For dark theme:rgba(255, 255, 255, 0.1).
MarkdownIt transform plugin
Plugin for @diplodoc/transform package.
A blockquote is treated as a quote link when its first paragraph starts with a link that has the data-quotelink attribute (in HTML) or {data-quotelink} / {data-quotelink="true"} in YFM markup. The plugin then sets the block’s token type and CSS class (yfm-quote-link), and adds script/style paths to the transform result so the runtime can be loaded.
Options:
runtime— string or{ script, style }. Paths for script and CSS in the transform result. Default:_assets/quote-link-extension.js/_assets/quote-link-extension.css.bundle— copy bundled runtime to output. Target directory:<transformer output>/<plugin runtime option>. Default:true.
Documentation
- For AI agents and developers — see AGENTS.md for setup, scripts, and contribution notes.
