Support and render Markdown in model meta [ci skip]

This commit is contained in:
Ines Montani 2019-08-01 18:33:10 +02:00
parent 944a66c326
commit 3072eb28c2
1 changed files with 7 additions and 5 deletions

View File

@ -14,7 +14,7 @@ import Icon from '../components/icon'
import Link from '../components/link' import Link from '../components/link'
import Grid from '../components/grid' import Grid from '../components/grid'
import Infobox from '../components/infobox' import Infobox from '../components/infobox'
import { join, arrayToObj, abbrNum } from '../components/util' import { join, arrayToObj, abbrNum, markdownToReact } from '../components/util'
const MODEL_META = { const MODEL_META = {
core: 'Vocabulary, syntax, entities, vectors', core: 'Vocabulary, syntax, entities, vectors',
@ -43,6 +43,10 @@ const MODEL_META = {
compat: 'Latest compatible model version for your spaCy installation', compat: 'Latest compatible model version for your spaCy installation',
} }
const MARKDOWN_COMPONENTS = {
code: InlineCode,
}
function getModelComponents(name) { function getModelComponents(name) {
const [lang, type, genre, size] = name.split('_') const [lang, type, genre, size] = name.split('_')
return { lang, type, genre, size } return { lang, type, genre, size }
@ -192,10 +196,8 @@ const Model = ({ name, langId, langName, baseUrl, repo, compatibility, hasExampl
python -m spacy download {name} python -m spacy download {name}
</CodeBlock> </CodeBlock>
</Aside> </Aside>
{meta.description && <p>{meta.description}</p>} {meta.description && markdownToReact(meta.description, MARKDOWN_COMPONENTS)}
{isError && error} {isError && error}
<Table> <Table>
<tbody> <tbody>
{rows.map(({ label, tag, help, content }, i) => {rows.map(({ label, tag, help, content }, i) =>
@ -243,7 +245,7 @@ const Model = ({ name, langId, langName, baseUrl, repo, compatibility, hasExampl
) )
)} )}
</Grid> </Grid>
{meta.notes && <p>{meta.notes}</p>} {meta.notes && markdownToReact(meta.notes, MARKDOWN_COMPONENTS)}
{hasInteractiveCode && ( {hasInteractiveCode && (
<CodeBlock title="Try out the model" lang="python" executable={true}> <CodeBlock title="Try out the model" lang="python" executable={true}>
{[ {[