mirror of https://github.com/usememos/memos.git
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") {
|
if (parser.name === "br") {
|
||||||
return walkthough(retainContent, blockParsers, inlineParsers);
|
return walkthough(retainContent, blockParsers, inlineParsers);
|
||||||
} else {
|
} else {
|
||||||
if (retainContent.startsWith("\n")) {
|
if (parser.name !== "code block") {
|
||||||
walkthough(matchedStr, [], inlineParsers);
|
walkthough(matchedStr, [], inlineParsers);
|
||||||
|
}
|
||||||
|
if (retainContent.startsWith("\n")) {
|
||||||
return walkthough(retainContent.slice(1), blockParsers, inlineParsers);
|
return walkthough(retainContent.slice(1), blockParsers, inlineParsers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
let matchedInlineParser = undefined;
|
let matchedInlineParser = undefined;
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
import copy from "copy-to-clipboard";
|
import copy from "copy-to-clipboard";
|
||||||
import hljs from "highlight.js";
|
import hljs from "highlight.js";
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { matcher } from "../matcher";
|
import { matcher } from "../matcher";
|
||||||
import toastHelper from "../../../components/Toast";
|
import toastHelper from "../../../components/Toast";
|
||||||
|
|
||||||
export const CODE_BLOCK_REG = /^```(\S*?)\s([\s\S]*?)```/;
|
export const CODE_BLOCK_REG = /^```(\S*?)\s([\s\S]*?)```/;
|
||||||
|
|
||||||
const renderer = (rawStr: string) => {
|
const renderer = (rawStr: string) => {
|
||||||
const { t } = useTranslation();
|
|
||||||
const matchResult = matcher(rawStr, CODE_BLOCK_REG);
|
const matchResult = matcher(rawStr, CODE_BLOCK_REG);
|
||||||
if (!matchResult) {
|
if (!matchResult) {
|
||||||
return <>{rawStr}</>;
|
return <>{rawStr}</>;
|
||||||
|
|
@ -27,7 +25,7 @@ const renderer = (rawStr: string) => {
|
||||||
|
|
||||||
const handleCopyButtonClick = () => {
|
const handleCopyButtonClick = () => {
|
||||||
copy(matchResult[2]);
|
copy(matchResult[2]);
|
||||||
toastHelper.success(t("message.succeed-copy-code"));
|
toastHelper.success("Copy succeed");
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
> .page-container {
|
> .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 {
|
> .sidebar-wrapper {
|
||||||
@apply flex-shrink-0 ml-calc;
|
@apply flex-shrink-0 ml-calc;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
.sidebar-wrapper {
|
.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 {
|
&.show {
|
||||||
@apply translate-x-0 shadow-2xl sm:shadow-none;
|
@apply translate-x-0 shadow-2xl sm:shadow-none;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue