fix: tag generate in code block (#925)

This commit is contained in:
boojack 2023-01-08 13:49:26 +08:00 committed by GitHub
parent e29924c8a1
commit 4b860777cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 6 deletions

View file

@ -99,11 +99,14 @@ export const getMatchedNodes = (markdownStr: string): MatchedNode[] => {
if (parser.name === "br") {
return walkthough(retainContent, blockParsers, inlineParsers);
} else {
if (retainContent.startsWith("\n")) {
if (parser.name !== "code block") {
walkthough(matchedStr, [], inlineParsers);
}
if (retainContent.startsWith("\n")) {
return walkthough(retainContent.slice(1), blockParsers, inlineParsers);
}
}
return "";
}
let matchedInlineParser = undefined;

View file

@ -1,13 +1,11 @@
import copy from "copy-to-clipboard";
import hljs from "highlight.js";
import { useTranslation } from "react-i18next";
import { matcher } from "../matcher";
import toastHelper from "../../../components/Toast";
export const CODE_BLOCK_REG = /^```(\S*?)\s([\s\S]*?)```/;
const renderer = (rawStr: string) => {
const { t } = useTranslation();
const matchResult = matcher(rawStr, CODE_BLOCK_REG);
if (!matchResult) {
return <>{rawStr}</>;
@ -27,7 +25,7 @@ const renderer = (rawStr: string) => {
const handleCopyButtonClick = () => {
copy(matchResult[2]);
toastHelper.success(t("message.succeed-copy-code"));
toastHelper.success("Copy succeed");
};
return (

View file

@ -6,7 +6,7 @@
}
> .page-container {
@apply relative w-full min-h-full mx-auto flex flex-row justify-start sm:justify-center items-start;
@apply relative w-full h-auto mx-auto flex flex-row justify-start sm:justify-center items-start;
> .sidebar-wrapper {
@apply flex-shrink-0 ml-calc;

View file

@ -1,5 +1,5 @@
.sidebar-wrapper {
@apply fixed sm:sticky top-0 z-30 sm:z-0 -translate-x-64 sm:translate-x-0 sm:flex flex-col justify-start items-start w-64 h-full py-4 pl-2 bg-white dark:bg-zinc-800 sm:bg-transparent overflow-x-hidden overflow-y-auto transition-transform duration-300 overscroll-contain hide-scrollbar;
@apply fixed sm:sticky top-0 z-30 sm:z-0 -translate-x-64 sm:translate-x-0 sm:flex flex-col justify-start items-start w-64 h-auto max-h-screen py-4 pl-2 bg-white dark:bg-zinc-800 sm:bg-transparent overflow-x-hidden overflow-y-auto transition-transform duration-300 overscroll-contain hide-scrollbar;
&.show {
@apply translate-x-0 shadow-2xl sm:shadow-none;