重新定义 markdown 中的 quote 后,如何恢复到其初始定义?该定义未知或可能因风格而异

重新定义 markdown 中的 quote 后,如何恢复到其初始定义?该定义未知或可能因风格而异

quote在 markdown 中重新定义创建具有背景颜色和边框的漂亮块引用之后,我该如何返回到之前的quote定义,
这是未知的,因为 markdown 首先初始化了它,而我不知道如何、用什么?

这里是pdf显示我遇到的问题:我决定在块引用上放置一个带边框的绿色背景,然后当我决定这样做时,我无法完全删除这个背景和边框……
我没有办法确保回到以前的状态。

pdf紧接着是生成它的 markdown 文件。

在此处输入图片描述

---
header-includes:
- \usepackage{tcolorbox}
- \usepackage{fvextra}

geometry: margin=2cm
fontsize: 12pt
output: pdf
classoption: fleqn
---

\DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,breakanywhere,breaksymbol=,breakanywheresymbolpre=,commandchars=\\\{\}}

\newcommand{\cadreAvantage}{\renewtcolorbox{quote}{colback=green!5!white,arc=0pt,outer arc=0pt,colframe=green!75!black,code={\tcbset{enlarge left by=1cm}}}}
\newcommand{\cadreAttention}{\renewtcolorbox{quote}{colback=orange!5!white,arc=0pt,outer arc=0pt,colframe=orange!80!black,code={\tcbset{enlarge left by=1cm}}}}
\newcommand{\cadreTransparent}{\renewtcolorbox{quote}{colback=white!5!white,arc=0pt,outer arc=0pt,boxrule=0pt,lowerbox=invisible,code={\tcbset{enlarge left by=1cm}}}}

I begin a text, and then do a blockquote `> ....`

   > Here a normal blockquote: I don't know how _markdown_ defines it  
   > it's the classical one, without border, nothing: only a left padding

Then, I wish to put some text under a green blockquote

\cadreAvantage

   > This blockquote will be more visible  
   > Nice green, it is really attractive

But how to go back to the previous blockquote shape, the one that comes with markdown?

   > If a do another blockquote without changing anything, its still green

Defining `quote` to nothing with a `\renewtcolorbox{quote}{}` doesn't return to normal:

   > I have cancelled `quote` definition here  
   > It's grey...

I have a workaround : defining a transparent blockquote

\cadreTransparent

   > But it still have borders, I cannot remove them,  
   > and its not really what previously existed.

How may I rollback `quote` to its previous definition?  
considering that I don't really know what it was, only markdown knows how it initialized `quote` (it might even depend even on your operating system, distro, environment flavor...)

so that they will look as if I'd never changed them...  

\cadreAttention

   > Until I decide doing so again?

I believe that I don't really need to know what this initial definition is.  
I think (but you might have a better idea) that what I need is to be able to save it once, and to restore it each time its needed.

So that I will have command in my markdown like:

/saveQuote
abc
/cadreAvantage
   > def
/restoreQuote
jkl
/cadreAttention
   > mno
/restoreQuote
   > this one is the normal blockquote

(该pdf文件是由pandoc -f markdown-implicit_figures test.md -o test.pdf命令创建的)。

答案1

您可以quote通过以下方式保护环境:

\let\oldQuote\quote 
\let\endoldQuote\endquote

并使用以下命令恢复:

\let\quote\oldQuote 
\let\endquote\endoldQuote
---
header-includes:
- \usepackage{tcolorbox}
- \usepackage{fvextra}
- \let\oldQuote\quote \let\endoldQuote\endquote
- \newcommand{\restoreQuote}{\let\quote\oldQuote \let\endquote\endoldQuote}
- \DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,breakanywhere,breaksymbol=,breakanywheresymbolpre=,commandchars=\\\{\}}
- \newcommand{\cadreAvantage}{\renewtcolorbox{quote}{colback=green!5!white,arc=0pt,outer arc=0pt,colframe=green!75!black,code={\tcbset{enlarge left by=1cm}}}}
- \newcommand{\cadreAttention}{\renewtcolorbox{quote}{colback=orange!5!white,arc=0pt,outer arc=0pt,colframe=orange!80!black,code={\tcbset{enlarge left by=1cm}}}}
- \newcommand{\cadreTransparent}{\renewtcolorbox{quote}{colback=white!5!white,arc=0pt,outer arc=0pt,boxrule=0pt,lowerbox=invisible,code={\tcbset{enlarge left by=1cm}}}}

geometry: margin=2cm
fontsize: 12pt
output: pdf
classoption: fleqn
---


I begin a text, and then do a blockquote `> ....`

   > Here a normal blockquote: I don't know how _markdown_ defines it  
   > it's the classical one, without border, nothing: only a left padding

Then, I wish to put some text under a green blockquote

\cadreAvantage

   > This blockquote will be more visible  
   > Nice green, it is really attractive

But how to go back to the previous blockquote shape, the one that comes with markdown?

   > If a do another blockquote without changing anything, its still green

Defining `quote` to nothing with a `\renewtcolorbox{quote}{}` doesn't return to normal:

   > I have cancelled `quote` definition here  
   > It's grey...

I have a workaround : defining a transparent blockquote

\cadreTransparent

   > But it still have borders, I cannot remove them,  
   > and its not really what previously existed.

How may I rollback `quote` to its previous definition?  
considering that I don't really know what it was, only markdown knows how it initialized `quote` (it might even depend even on your operating system, distro, environment flavor...)

so that they will look as if I'd never changed them...  

\cadreAttention

   > Until I decide doing so again?

I believe that I don't really need to know what this initial definition is.  
I think (but you might have a better idea) that what I need is to be able to save it once, and to restore it each time its needed.

So that I will have command in my markdown like:

> ``` abc
> 
> \cadreAvantage
> 
> > def
> 
> \restoreQuote
> 
> jkl
> 
> \cadreAttention
> 
> > mno
> 
> \restoreQuote
> 
> > this one is the normal blockquote ```
> 
> abc
> 
> \cadreAvantage
> 
> > def
> 
> \restoreQuote
> 
> jkl
> 
> \cadreAttention
> 
> > mno
> 
> \restoreQuote
> 
> > this one is the normal blockquote

在此处输入图片描述

相关内容