Skip to content

Feature/minor fixes #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
tutorial summary in markdown
  • Loading branch information
ShMcK committed Jan 14, 2020
commit c60678e11bb5574963902a308ea2f9354e09a09b
29 changes: 28 additions & 1 deletion web-app/src/components/Markdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,49 @@ import './prism'
// markdown highlighter instance
const md: MarkdownIt = new MarkdownIt({
breaks: true,
// highlight: syntaxHighlight,
html: true,
linkify: true,
})
// add emoji: https://github.com/markdown-it/markdown-it-emoji
.use(markdownEmoji)
// add syntax highlighting through prism
.use(prism, {
defaultLanguage: 'js',
})

// const mdFeatures = [
// 'table',
// 'code',
// 'fence',
// 'blockquote',
// 'hr',
// 'list',
// 'reference',
// 'heading',
// 'lheading',
// 'html_block',
// 'paragraph',
// 'html_inline',
// 'autolink',
// 'link',
// 'image',
// ]

// TODO: markdownIt with rules disabling most features
// const minimalMarkdownIt = new MarkdownIt({
// breaks: false,
// html: true,
// linkify: false,
// }).disable(mdFeatures)

interface Props {
children: string
minimal?: boolean
}

const Markdown = (props: Props) => {
let html: string
// TODO: set md to minimal rule set if specified
try {
html = md.render(props.children)
} catch (error) {
Expand Down
3 changes: 2 additions & 1 deletion web-app/src/containers/New/TutorialList/TutorialItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react'
import { css, jsx } from '@emotion/core'
import Card from '../../../components/Card'
import Markdown from '../../../components/Markdown'

const styles = {
card: {
Expand Down Expand Up @@ -39,7 +40,7 @@ const LanguageIcon = () => (
const TutorialItem = (props: Props) => (
<Card onClick={props.onSelect} css={styles.card}>
<h3>{props.title || 'Title'}</h3>
<p>{props.description || 'Description'}</p>
<Markdown minimal>{props.description || 'Description'}</Markdown>
<div css={styles.languages}>
<LanguageIcon />
</div>
Expand Down