mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 10:02:47 +03:00
Merge branch 'release/next-js' of https://github.com/urbit/urbit into npm-packages
This commit is contained in:
commit
a53c1e519b
@ -23,7 +23,7 @@ export default class CodeContent extends Component {
|
||||
style={{ whiteSpace: 'pre' }}
|
||||
backgroundColor='washedGray'
|
||||
>
|
||||
{content.code.output[0].join('\n')}
|
||||
{content.code.output.join('\n')}
|
||||
</Text>
|
||||
) : null;
|
||||
|
||||
|
@ -2,7 +2,6 @@ import React, { Component, useState, useEffect } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import RemarkDisableTokenizers from 'remark-disable-tokenizers';
|
||||
import RemarkBreaks from 'remark-breaks';
|
||||
import urbitOb from 'urbit-ob';
|
||||
import { Text } from '@tlon/indigo-react';
|
||||
import { GroupLink } from "~/views/components/GroupLink";
|
||||
@ -49,14 +48,27 @@ const renderers = {
|
||||
}
|
||||
};
|
||||
|
||||
const MessageMarkdown = React.memo(props => (
|
||||
const MessageMarkdown = React.memo(props => {
|
||||
const { source, ...rest } = props;
|
||||
const blockCode = source.split('```');
|
||||
const codeLines = blockCode.map(codes => codes.split("\n"));
|
||||
const lines = codeLines.reduce((acc, val, i) => {
|
||||
if((i % 2) === 1) {
|
||||
return [...acc, `\`\`\`${val.join('\n')}\`\`\``];
|
||||
} else {
|
||||
return [...acc, ...val];
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
return lines.map((line, i) => (
|
||||
<>
|
||||
{ i !== 0 && <br />}
|
||||
<ReactMarkdown
|
||||
{...props}
|
||||
{...rest}
|
||||
source={line}
|
||||
unwrapDisallowed={true}
|
||||
renderers={renderers}
|
||||
// shim until we uncover why RemarkBreaks and
|
||||
// RemarkDisableTokenizers can't be loaded simultaneously
|
||||
disallowedTypes={['heading', 'list', 'listItem', 'link']}
|
||||
allowNode={(node, index, parent) => {
|
||||
if (
|
||||
node.type === 'blockquote'
|
||||
@ -71,8 +83,14 @@ const MessageMarkdown = React.memo(props => (
|
||||
|
||||
return true;
|
||||
}}
|
||||
plugins={[RemarkBreaks]} />
|
||||
));
|
||||
plugins={[[RemarkDisableTokenizers, {
|
||||
block: DISABLED_BLOCK_TOKENS,
|
||||
inline: DISABLED_INLINE_TOKENS
|
||||
}]]}
|
||||
/>
|
||||
</>
|
||||
))
|
||||
});
|
||||
|
||||
export default function TextContent(props) {
|
||||
const content = props.content;
|
||||
|
Loading…
Reference in New Issue
Block a user