mirror of
https://github.com/usememos/memos.git
synced 2024-09-21 06:55:55 +08:00
fix: tag generate in code block (#925)
This commit is contained in:
parent
e29924c8a1
commit
4b860777cf
|
@ -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;
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue