This repository contains two main React components designed to handle typography and Markdown-based text rendering with flexibility and responsiveness.
This component showcases styled text with different case usages and typographical emphasis. It includes:
react-markdown
.TextWidget
: Demonstrates encapsulation of Markdown logic within reusable widgets.antd
: For UI components like Flex
and Select
.TextWidget
.import DifferentCaseTypographySample from "./DifferentCaseTypographySample";
function App() {
return <DifferentCaseTypographySample />;
}
export default App;
A utility component designed to process and render Markdown content with added responsiveness.
react-markdown
for Markdown-to-HTML conversion.react-wrap-balancer
for better text alignment and wrapping.isMarkdown
identifies valid Markdown content.function isMarkdown(text) {
const markdownPatterns = {
header: /^#+\s/,
emphasis: /[*_]/,
list: /^(\\s*[-+*]|\\d+\\.)\\s/,
link: /\\[.*\\]\\(.*\\)/,
image: /!\\[.*\\]\\(.*\\)/,
};
for (let pattern in markdownPatterns) {
if (
Object.hasOwnProperty.call(markdownPatterns, pattern) &&
markdownPatterns[pattern].test(text)
) {
return true;
}
}
return false;
}
import TextWidget from "./TextWidget";
function App() {
const sampleText = "## Hello World\nThis is a sample Markdown content.";
return <TextWidget text={sampleText} />;
}
export default App;