Skip to content

Commit

Permalink
feat: add hr for renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 11, 2021
1 parent ab79d0b commit 7ac5f56
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, h, State } from '@stencil/core';
import QuakeGen from '../../utils/utils';
import QuakeGen from '../../utils/quake-gen';

@Component({
tag: 'quake-render',
Expand All @@ -10,7 +10,12 @@ export class QuakeRender {
@State() markdownData: any[] = [];

componentWillLoad() {
let content = '# [heading+](https://quake.inherd.org)';
let content = `# [heading+](https://quake.inherd.org)
> blockquote
---
`;
this.markdownData = new QuakeGen(content).gen();
}

Expand All @@ -23,11 +28,17 @@ export class QuakeRender {
}

private static conditionRender(item: any) {
let temp = '';
let temp: string;
switch (item.type) {
case 'heading':
temp = <h1 innerHTML={item.text} class='quake-heading' id={item.anchor} />;
break;
case 'blockquote':
temp = <blockquote innerHTML={item.text} />;
break;
case 'hr':
temp = <hr />;
break;
default:
temp = <div>233</div>;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import QuakeGen from './utils';
import QuakeGen from './quake-gen';

describe('render', () => {
it('render heading', () => {
let data = new QuakeGen('# heading+').gen();
expect(data.length).toEqual(1);
});

it('render with links', () => {
it('render heading with links', () => {
let data = new QuakeGen('# [heading+](https://quake.inherd.org)').gen();
expect(data.length).toEqual(1);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class QuakeGen {
const token: Token = this.token;
switch (token.type) {
case 'heading':
// let inline = renderInline(token.text;
const inline = this.renderInline(token.text);
console.log(inline);
this.markdownData.push({
Expand All @@ -53,6 +52,12 @@ class QuakeGen {
anchor: this.slugger.slug(this.unescape(inline)),
});
break;
case 'blockquote':
console.log(token.tokens);
this.markdownData.push({type: 'blockquote', text: token.text, raw: token.raw});
break;
case 'hr':
this.markdownData.push({type: 'hr', raw: token.raw});
default:
console.log(token);
}
Expand Down

0 comments on commit 7ac5f56

Please sign in to comment.