Skip to content

Commit 7fb2836

Browse files
authored
fix(latex): improve rendering of details and tabbed content (#104)
* fix(latex): show title for tabbed contents * fix(remark-latex/lib/compiler.js): included title in a tabbed environment * feat(oi-wiki-export/oi-wiki-export.tex): add a customized tabbed environment * fix(latex): remove quotes around titles * fix(util.js): allow unquote to deal with unescaped quotes * fix(compile.js): unquote details summary * fix(oi-wiki-export.tex): adjust colored box format
1 parent da788bb commit 7fb2836

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

oi-wiki-export/oi-wiki-export.tex

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,9 @@
186186
\else
187187
\begin{mdframed}[%
188188
roundcorner=3pt,
189-
linewidth=0pt,
190-
backgroundcolor=#1!20!white,
189+
linewidth=1pt,
190+
linecolor=#1,
191+
backgroundcolor=white,
191192
frametitle={#2},
192193
frametitlefont={\sffamily},
193194
frametitlerule=false,
@@ -203,6 +204,15 @@
203204
\fi
204205
}
205206

207+
% Define a "tabbed" environment: #1 = title
208+
\newenvironment{tabbed}[1]{%
209+
\begin{itemize}
210+
\item #1 \par
211+
\vspace{0.5em}
212+
}{%
213+
\end{itemize}
214+
}
215+
206216
\captionsetup[figure]{labelsep=space}
207217
\captionsetup[table]{labelsep=space}
208218

@@ -213,7 +223,7 @@
213223
\newcommand{\hytt}[1]{\texttt{\hyphenchar\font="200B #1}}
214224

215225
% minted settings
216-
\setminted{fontsize=\small}
226+
\setminted{fontsize=\small,backgroundcolor=black!5!white}
217227
\newmdenv[%
218228
roundcorner=5pt,
219229
linewidth=0pt,

remark-latex/lib/compiler.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ export default function compiler(options) {
603603
case "detailsContainer": {
604604
// Pymdown details 语法块
605605
const type = node.attributes.class;
606-
const summary = parse(node.children[0]);
606+
const summary = unquote(parse(node.children[0]));
607607

608608
node.children = node.children.slice(1);
609609

@@ -622,8 +622,7 @@ export default function compiler(options) {
622622
node.children = node.children.slice(1);
623623

624624
const content = all(node, parse).join("");
625-
// return "\\begin{tabbed}{{0}}\n{{1}}\n\\end{tabbed}".format(title, content);
626-
return content;
625+
return "\\begin{tabbed}{{0}}\n{{1}}\n\\end{tabbed}".format(title, content);
627626
}
628627
case "tabbedContainerTitle": {
629628
return all(node, parse).join("");

remark-latex/lib/util.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ export function isUrl(str) {
163163
export function unquote(str) {
164164
if (str.startsWith('\\"') && str.endsWith('\\"')) {
165165
return str.slice(2, -2);
166+
} if (str.startsWith('"') && str.endsWith('"')) {
167+
return str.slice(1, -1);
166168
} else {
167169
return str;
168170
}

0 commit comments

Comments
 (0)