如何修復或更改隨機標記的 json 片段?

如何修復或更改隨機標記的 json 片段?

所以我的問題是我的 json 片段被標記為紅色,但我不想將它們標記為紅色。我的 JSON 是什麼樣子的:

[
{obj1}
{obj2}
{obj3}
]

我的片段如下圖:

[
{obj1}

...

]

並且......用紅色標記勾勒出來(看起來表明存在一些錯誤)。

我的 json 片段的序言如下所示:

\newminted{json}{breaklines,frame=bottomline,rulecolor=\color{snipgray},framerule=0.6pt}

我的截圖看起來:

\begin{snip}\captionof{listing}{Bla bla bla}\label{lst:a3}
\begin{jsoncode}
[
{"bla":1,
"bla2":"4"
}
...
]
\end{jsoncode}
\end{snip}

答案1

minted發現語法錯誤(例如...)時,它會繪製一個fcolorbox.您可以在以下範圍內重新定義此命令minted以防止繪製框,如下所示https://github.com/gpoore/minted/issues/69#issuecomment-81612590

為了便於將來參考,請提供完整的最小工作範例(MWE)而不是幾個片段,如下所示。我對其進行了一些簡化(這是 MWE 的“最小”部分)。另外:這與xetex.

微量元素:

\documentclass{article}
\usepackage{etoolbox}        % for \AtBeginEnvironment
\usepackage{minted}
\definecolor{snipgray}{rgb}{0.25,0.25,0.25}
\newminted{json}{frame=bottomline,rulecolor=\color{snipgray},framerule=0.6pt}

\AtBeginEnvironment{jsoncode}{%
  \renewcommand{\fcolorbox}[4][]{#4}}

\begin{document}
    \begin{jsoncode}
    [
    {"bla":1,
    "bla2":"4"
    }
    ...
    ]
    \end{jsoncode}
\end{document}

結果: 在此輸入影像描述

相關內容