Skip to content

Commit

Permalink
feat: enable inline directives by default (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
d3m1d0v authored Nov 27, 2024
1 parent 5a825d9 commit a5ec3d9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ All of parameters groups – `[]`, `()`, `{}` – are optional, but their order
- `()` – used for something like required identifier (id, url, etc.);
- `{}` – used to pass optional named arguments / attributes / `key=value` pairs.

> Note: inline directives disabled by default. You can enable them using `enableInlineDirectives()` helper.
## Helpers

### Enable or disable some of directive types
Expand Down
12 changes: 0 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import type MarkdownIt from 'markdown-it';

import directivePlugin from 'markdown-it-directive';

import {disableInlineDirectives} from './helpers';

export {
enableBlockDirectives,
enableInlineDirectives,
Expand Down Expand Up @@ -33,18 +31,8 @@ export type {
InlineDirectiveHandler,
} from './types';

// eslint-disable-next-line valid-jsdoc
/**
* Inline directives are disabled by default.
*
* They will be enabled after this error is fixed: https://github.com/hilookas/markdown-it-directive/issues/5
*
* To enable inline directives use `enableInlineDirectives()` helper.
*/
export const directiveParser = (): MarkdownIt.PluginSimple => {
return (md) => {
directivePlugin(md);

disableInlineDirectives(md);
};
};
7 changes: 3 additions & 4 deletions tests/src/directive.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
directiveParser,
disableBlockDirectives,
disableInlineDirectives,
enableInlineDirectives,
registerContainerDirective,
registerInlineDirective,
registerLeafBlockDirective,
Expand All @@ -20,14 +19,14 @@ import {

const html = (text: string, {plugins}: {plugins?: MarkdownIt.PluginSimple[]} = {}) => {
const {result} = transform(text, {
plugins: [directiveParser(), enableInlineDirectives, ...(plugins || [])],
plugins: [directiveParser(), ...(plugins || [])],
});

return result.html;
};

describe('Directive', () => {
it('should not parse inline directive by default', () => {
it.skip('should not parse inline directive by default', () => {
const md = new MarkdownIt().use(directiveParser());
const inlineHandler = jest.fn(() => false);
const leafHandler = jest.fn(() => false);
Expand Down Expand Up @@ -518,7 +517,7 @@ describe('Directive', () => {

describe('tokenizeInlineContent', () => {
it('should parse content in inline directive', () => {
const md = new MarkdownIt().use(directiveParser()).use(enableInlineDirectives);
const md = new MarkdownIt().use(directiveParser());
registerInlineDirective(md, 'inl', (state, params) => {
if (!params.content) {
return false;
Expand Down

0 comments on commit a5ec3d9

Please sign in to comment.