Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #17 from JanGuillermo/1.0.2
Browse files Browse the repository at this point in the history
🚢 Ship 1.0.2
  • Loading branch information
JanGuillermo committed Sep 16, 2020
2 parents eb2ac00 + 491cb35 commit 4ffcbb7
Show file tree
Hide file tree
Showing 37 changed files with 488 additions and 107,283 deletions.
8 changes: 1 addition & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@ module.exports = {
},
plugins: ['prettier'],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',

'prettier/prettier': ['error']
},
overrides: [
{
files: [
'**/__tests__/*.{j,t}s?(x)',
'**/tests/unit/**/*.spec.{j,t}s?(x)'
],
files: ['**/__tests__/*.{j,t}s?(x)', '**/__tests__/**/*.spec.{j,t}s?(x)'],
env: {
jest: true
}
Expand Down
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**/*
!dist/**/*
!LICENSE.md
!package*.json
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.2] - 2020-09-15
### Added
- Added information on README for including LaTeX + highlight.js styles

### Changed
- Split test cases into individual plugin test files
- Utilize Vue's Compositions API for the component

### Fixed
- [Syntax highlighting indentation issues #14](https://github.com/JanGuillermo/vue3-markdown-it/issues/14)

### Removed
- Omitted the production library folder
- Omitted the includes for LaTeX + highlight.js styles
- `dedent` dependency
- `highlight.js` dependency

## [1.0.1] - 2020-09-14
### Added
- Released vue3-markdown-it with support for 14 plugins:
- [markdown-it](https://github.com/markdown-it/markdown-it) - __The one__ that started it all
- [markdown-it-abbr](https://github.com/markdown-it/markdown-it-abbr) - Add abbreviations
- [markdown-it-anchor](https://github.com/valeriangalliat/markdown-it-anchor) - Add anchors
- [markdown-it-deflist](https://github.com/markdown-it/markdown-it-deflist) - Add definition lists
- [markdown-it-emoji](https://github.com/markdown-it/markdown-it-emoji) - Add emojis
- [markdown-it-footnote](https://github.com/markdown-it/markdown-it-footnote) - Add footnotes
- [markdown-it-highlightjs](https://github.com/valeriangalliat/markdown-it-highlightjs) - Add highlighting for code blocks
- [markdown-it-ins](https://github.com/markdown-it/markdown-it-ins) - Add `<ins>` tags
- [markdown-it-latex](https://github.com/tylingsoft/markdown-it-latex) - Add LaTeX formatting
- [markdown-it-mark](https://github.com/markdown-it/markdown-it-mark) - Add marking/highlighting
- [markdown-it-strikethrough-alt](https://github.com/jay-hodgson/markdown-it-strikethrough-alt) - Add strikethrough
- [markdown-it-sub](https://github.com/markdown-it/markdown-it-sub) - Add subscript
- [markdown-it-sup](https://github.com/markdown-it/markdown-it-sup) - Add superscript
- [markdown-it-task-lists](https://github.com/revin/markdown-it-task-lists) - Add task lists
- [markdown-it-toc-done-right](https://github.com/nagaozen/markdown-it-toc-done-right) - Add table of contents

[1.0.2]: https://github.com/JanGuillermo/vue3-markdown-it/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/JanGuillermo/vue3-markdown-it/releases/tag/v1.0.1
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ const app = createApp();
app.use(VueMarkdownIt);
```

#### CSS
### CSS
If you want to use LaTeX, you'll have to import a CSS file from [markdown-it-latex](https://github.com/tylingsoft/markdown-it-latex).
```js
import 'vue3-markdown-it/lib/vue3-markdown-it.css';
import 'markdown-it-latex/dist/index.css';
```

If you want to use highlighting for code blocks, you'll have to import a CSS file from [highlight.js](https://github.com/highlightjs/highlight.js). View more styles [here](https://github.com/highlightjs/highlight.js/tree/master/src/styles). The code sample below imports the Monokai styling.
```js
import 'highlight.js/styles/monokai.css';
```

### Single Use
Expand Down
1 change: 1 addition & 0 deletions __tests__/mocks/style.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
16 changes: 16 additions & 0 deletions __tests__/plugins/markdown-it-abbr.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import render from '#/render';

describe('markdown-it-abbr tests', () => {
let source, result;

it('should be able to support abbreviations', async () => {
source = `
*[D4C]: Dirty Deeds Done Dirt Cheap
D4C is such a bizarre stand.
`;
result = render(source);

await global.wrapper.setProps({ source });
expect(global.wrapper.html()).toContain(result);
});
});
17 changes: 17 additions & 0 deletions __tests__/plugins/markdown-it-anchor.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import render from '#/render';

describe('markdown-it-anchor tests', () => {
let source, result;

it('should be able to support anchors', async () => {
source = `
# First header
Lorem ipsum.
`;
result = render(source);

await global.wrapper.setProps({ source });
expect(global.wrapper.html()).toContain(result);
expect(global.wrapper.html()).toContain('first-header');
});
});
23 changes: 23 additions & 0 deletions __tests__/plugins/markdown-it-deflist.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import render from '#/render';

describe('markdown-it-deflist tests', () => {
let source, result;

it('should be able to support definition lists', async () => {
source = `
First Term
: This is the definition of the first term.
Second Term
: This is one definition of the second term.
: This is another definition of the second term.
`;
result = render(source);

await global.wrapper.setProps({ source });
expect(global.wrapper.html()).toContain(result);
expect(global.wrapper.html()).toContain('</dl>');
expect(global.wrapper.html()).toContain('</dt>');
expect(global.wrapper.html()).toContain('</dd>');
});
});
14 changes: 14 additions & 0 deletions __tests__/plugins/markdown-it-emoji.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import render from '#/render';

describe('markdown-it-emoji tests', () => {
let source, result;

it('should be able to support emojis', async () => {
source = ':tada:';
result = render(source);

await global.wrapper.setProps({ source });
expect(global.wrapper.html()).toContain(result);
expect(global.wrapper.text()).toEqual('🎉');
});
});
24 changes: 24 additions & 0 deletions __tests__/plugins/markdown-it-footnote.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import render from '#/render';

describe('markdown-it-footnote tests', () => {
let source, result;

it('should be able to support footnotes', async () => {
source = `
Here is a footnote reference,[^1] and another.[^longnote]
[^1]: Here is the footnote.
[^longnote]: Here's one with multiple blocks.
Subsequent paragraphs are indented to show that they
belong to the previous footnote.
`;
result = render(source);

await global.wrapper.setProps({ source });
expect(global.wrapper.html()).toContain(result);
expect(global.wrapper.html()).toContain('footnote-ref');
expect(global.wrapper.html()).toContain('footnote-backref');
});
});
20 changes: 20 additions & 0 deletions __tests__/plugins/markdown-it-highlightjs.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import render from '#/render';

describe('markdown-it-highlightjs tests', () => {
let source, result;

it('should be able to support highlighting', async () => {
source = `
\`\`\`
this is code
\`\`\`
this isn't code
`;
result = render(source);

await global.wrapper.setProps({ source });
expect(global.wrapper.html()).toContain(result);
expect(global.wrapper.html()).toContain('hljs');
});
});
14 changes: 14 additions & 0 deletions __tests__/plugins/markdown-it-ins.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import render from '#/render';

describe('markdown-it-ins tests', () => {
let source, result;

it('should be able to support <insert> tags', async () => {
source = '++inserted++';
result = render(source);

await global.wrapper.setProps({ source });
expect(global.wrapper.html()).toContain(result);
expect(global.wrapper.html()).toContain('</ins>');
});
});
14 changes: 14 additions & 0 deletions __tests__/plugins/markdown-it-latex.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import render from '#/render';

describe('markdown-it-latex tests', () => {
let source, result;

it('should be able to support LaTeX', async () => {
source = '`$E = mc^2$`';
result = render(source);

await global.wrapper.setProps({ source });
expect(global.wrapper.html()).toContain(result);
expect(global.wrapper.html()).toContain('katex');
});
});
14 changes: 14 additions & 0 deletions __tests__/plugins/markdown-it-mark.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import render from '#/render';

describe('markdown-it-mark tests', () => {
let source, result;

it('should be able to support <mark> tags', async () => {
source = '==marked==';
result = render(source);

await global.wrapper.setProps({ source });
expect(global.wrapper.html()).toContain(result);
expect(global.wrapper.html()).toContain('</mark>');
});
});
14 changes: 14 additions & 0 deletions __tests__/plugins/markdown-it-strikethrough-alt.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import render from '#/render';

describe('markdown-it-strikethrough-alt tests', () => {
let source, result;

it('should be able to support strikethrough', async () => {
source = '--vue3-markdown-it sucks--';
result = render(source);

await global.wrapper.setProps({ source });
expect(global.wrapper.html()).toContain(result);
expect(global.wrapper.html()).toContain('</s>');
});
});
14 changes: 14 additions & 0 deletions __tests__/plugins/markdown-it-sub.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import render from '#/render';

describe('markdown-it-sub tests', () => {
let source, result;

it('should be able to support subscript', async () => {
source = 'H~2~0';
result = render(source);

await global.wrapper.setProps({ source });
expect(global.wrapper.html()).toContain(result);
expect(global.wrapper.html()).toContain('</sub>');
});
});
14 changes: 14 additions & 0 deletions __tests__/plugins/markdown-it-sup.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import render from '#/render';

describe('markdown-it-sup tests', () => {
let source, result;

it('should be able to support superscript', async () => {
source = '29^th^';
result = render(source);

await global.wrapper.setProps({ source });
expect(global.wrapper.html()).toContain(result);
expect(global.wrapper.html()).toContain('</sup>');
});
});
17 changes: 17 additions & 0 deletions __tests__/plugins/markdown-it-task-lists.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import render from '#/render';

describe('markdown-it-task-lists tests', () => {
let source, result;

it('should be able to support task lists', async () => {
source = `
- [ ] unchecked
- [x] checked
`;
result = render(source);

await global.wrapper.setProps({ source });
expect(global.wrapper.html()).toContain(result);
expect(global.wrapper.html()).toContain('checkbox');
});
});
22 changes: 22 additions & 0 deletions __tests__/plugins/markdown-it-toc-done-right.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import render from '#/render';

describe('markdown-it-toc-done-right tests', () => {
let source, result;

it('should be able to support table of contents', async () => {
source = `
[[toc]]
# First heading
Swag
## Second heading
Awesome sauce!
`;
result = render(source);

await global.wrapper.setProps({ source });
expect(global.wrapper.html()).toContain(result);
expect(global.wrapper.html()).toContain('table-of-contents');
});
});
17 changes: 17 additions & 0 deletions __tests__/plugins/markdown-it.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import render from '#/render';

describe('markdown-it tests', () => {
let source, result;

it('should initialize properly', async () => {
expect(global.wrapper.text()).toEqual('');
});

it('should update with "<h2>Hello World!</h2>"', async () => {
source = '## Hello World!';
result = render(source);

await global.wrapper.setProps({ source });
expect(global.wrapper.html()).toContain(result);
});
});
35 changes: 35 additions & 0 deletions __tests__/render.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import MarkdownIt from 'markdown-it';
import MarkdownItAbbr from 'markdown-it-abbr';
import MarkdownItAnchor from 'markdown-it-anchor';
import MarkdownItDeflist from 'markdown-it-deflist';
import MarkdownItEmoji from 'markdown-it-emoji';
import MarkdownItFootnote from 'markdown-it-footnote';
import MarkdownItHighlightjs from 'markdown-it-highlightjs';
import MarkdownItIns from 'markdown-it-ins';
import MarkdownItLatex from 'markdown-it-latex';
import MarkdownItMark from 'markdown-it-mark';
import MarkdownItStrikethroughAlt from 'markdown-it-strikethrough-alt';
import MarkdownItSub from 'markdown-it-sub';
import MarkdownItSup from 'markdown-it-sup';
import MarkdownItTasklists from 'markdown-it-task-lists';
import MarkdownItTOC from 'markdown-it-toc-done-right';

const md = new MarkdownIt();
const render = (source) => md.render(source);

md.use(MarkdownItAbbr)
.use(MarkdownItAnchor)
.use(MarkdownItDeflist)
.use(MarkdownItEmoji)
.use(MarkdownItFootnote)
.use(MarkdownItHighlightjs)
.use(MarkdownItIns)
.use(MarkdownItLatex)
.use(MarkdownItMark)
.use(MarkdownItStrikethroughAlt)
.use(MarkdownItSub)
.use(MarkdownItSup)
.use(MarkdownItTasklists)
.use(MarkdownItTOC);

export default render;

0 comments on commit 4ffcbb7

Please sign in to comment.