Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: tag generate in code block (#925)

boojack4b860777cf0b
diff --git a/web/src/labs/marked/index.tsx b/web/src/labs/marked/index.tsx
index bbae6c49b..749f19a20 100644
--- a/web/src/labs/marked/index.tsx
+++ b/web/src/labs/marked/index.tsx
@@ -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;
diff --git a/web/src/labs/marked/parser/CodeBlock.tsx b/web/src/labs/marked/parser/CodeBlock.tsx
index f1d7912c4..e9671be60 100644
--- a/web/src/labs/marked/parser/CodeBlock.tsx
+++ b/web/src/labs/marked/parser/CodeBlock.tsx
@@ -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 (
diff --git a/web/src/less/home.less b/web/src/less/home.less
index f92d38054..a73a39cef 100644
--- a/web/src/less/home.less
+++ b/web/src/less/home.less
@@ -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;
diff --git a/web/src/less/siderbar.less b/web/src/less/siderbar.less
index d675dfccd..4f4b0d318 100644
--- a/web/src/less/siderbar.less
+++ b/web/src/less/siderbar.less
@@ -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;