Skip to content

Instantly share code, notes, and snippets.

@Sansui233
Last active September 11, 2026 16:24
Show Gist options
  • Select an option

  • Save Sansui233/aeb581779e7df8ba22a99f82584338fe to your computer and use it in GitHub Desktop.

Select an option

Save Sansui233/aeb581779e7df8ba22a99f82584338fe to your computer and use it in GitHub Desktop.
Obsidian theme snippets for PDF printing
body {
--font-text:
Noto Serif SC, Noto Serif CJK SC, Hiragino Sans GB, SimSun, serif;
--font-sans: Noto Sans CJK SC, Pingfang SC, Microsoft YaHei;
--font-print-override: var(--font-text);
--font-text-override: IBM Plex Sans;
--font-monospace-override:
consolas NF, cascadia code, SpaceMono Nerd Font, FiraCode, sans-serif;
--strong-color: unset;
--bold-color: unset;
--link-external-color: black;
--link-external-color-hover: #e55e46;
--bold-modifier: 300;
--code-size: 0.875rem;
--table-text-size: 0.9rem;
--table-column-min-width: 5rem;
--table-column-max-width: unset;
--table-cell-vertical-alignment: middle;
--ui-line-black: black;
--text-faint: black;
--codeblock-background-color: #f8f8f8;
--inline-code-background-color: #eaeaea;
font-family: var(--font-text);
}
body.codeblock-customizer.theme-light {
--codeblock-customizer-inline-code-text-color: #222;
--code-normal: #222;
--code-background: var(--inline-code-background-color);
}
body.codeblock-customizer.theme-dark {
--codeblock-customizer-inline-code-text-color: #e55e46;
--code-normal: #e55e46;
--code-background: #313238;
}
.is-unresolved,
.is-unresolved:hover {
--link-decoration: none;
}
/* Underline */
.markdown-source-view.mod-cm6 .cm-hmd-internal-link .cm-underline {
text-decoration-line: none;
}
.markdown-source-view.mod-cm6
.cm-hmd-internal-link
.is-unresolved
.cm-underline {
text-decoration-line: underline;
}
/* Live mode: 空行 */
.markdown-source-view.mod-cm6 .cm-line:not(:has(span, p)):has(br) {
height: unset;
font-size: unset;
}
/* Inline code */
.codeblock-customizer.codeblock-customizer-style-inline-code
.cm-s-obsidian
span.cm-inline-code {
color: #222;
background: var(--inline-code-background-color) !important;
}
/* Heading */
.cm-line.HyperMD-header,
.markdown-rendered h1,
.markdown-rendered h2,
.markdown-rendered h3,
.markdown-rendered h4,
.markdown-rendered h5,
.markdown-rendered h6 {
--h1-font: var(--font-sans);
--h2-font: var(--font-sans);
--h3-font: var(--font-sans);
--h4-font: var(--font-sans);
--h5-font: var(--font-sans);
--h6-font: var(--font-sans);
font-weight: 500;
}
.cm-line.HyperMD-header-2,
.markdown-rendered h2 {
margin: 1.5em auto;
text-align: center;
border-bottom: none;
font-weight: 400;
max-width: 80%;
}
.markdown-source-view.mod-cm6 .HyperMD-header-3,
.cm-line.HyperMD-header-3,
.markdown-rendered h3 {
margin-top: 3rem;
background-color: var(--inline-code-background-color);
padding: 0.2em 0.4em;
}
.markdown-source-view.mod-cm6 .HyperMD-header-6,
.cm-line.HyperMD-header-6,
.markdown-rendered h6 {
padding-bottom: 0.2em;
}
.markdown-source-view.mod-cm6 .HyperMD-header {
padding-top: calc(var(--heading-spacing) - 0.5rem);
padding-bottom: calc(var(--p-spacing) - 0.5rem);
}
.cm-s-obsidian .cm-line.HyperMD-header + .cm-line.HyperMD-header {
padding-top: 0;
padding-bottom: var(--p-spacing);
}
/* Table */
table {
margin: 0 auto;
}
div.table-wrapper {
margin-left: auto;
margin-right: auto;
}
.markdown-rendered td,
.markdown-rendered th {
border: unset;
}
thead,
.markdown-rendered thead,
th,
.markdown-rendered th {
color: var(--text-faint);
}
.markdown-rendered th,
.markdown-rendered td,
.markdown-source-view.mod-cm6 .cm-table-widget .table-cell-wrapper {
padding: 0.5rem;
}
.table-view-table > thead,
.markdown-rendered thead {
border-top: 1.5px solid var(--ui-line-black);
border-bottom: 1.5px solid var(--ui-line-black);
}
.table-view-table > tbody > tr:last-child,
.markdown-rendered tbody > tr:last-child {
border-bottom: 1.5px solid var(--ui-line-black);
}
.table-view-table > tbody > tr:not(:last-child),
.markdown-rendered tbody > tr:not(:last-child) {
border-bottom: 1px solid var(--ui-line-black);
}
.table-view-table > thead > tr > th:not(:last-child),
.table-view-table > tbody > tr > td:not(:last-child),
td:not(:last-child),
.markdown-rendered thead > tr > th:not(:last-child),
.markdown-rendered thead > tr > td:not(:last-child) {
border-right: 1px solid var(--ui-line-black);
}
.table-view-table > thead > tr > th {
font-weight: 500;
font-size: 1rem;
}
.table-view-table > thead > tr > th,
.table-view-table > tbody > tr > td {
max-width: var(--table-column-max-width);
}
/* List */
.cm-s-obsidian .cm-formatting-list {
display: inline-block;
width: 1.5rem;
padding-inline-start: 0.5rem;
}
.cm-line.HyperMD-list-line {
--list-indent: 2rem;
}
.markdown-rendered ul > li {
margin-inline-start: 1.5rem;
}
.markdown-rendered ol ol > li,
.markdown-rendered ul ul > li {
--list-indent: 2rem;
}
/* Quote */
.cmline.HyperMD-quote {
padding-inline-start: 15px;
}
/* HR */
.markdown-rendered hr {
margin-top: calc(var(--p-spacing) + 0.75rem);
margin-bottom: 0.75rem;
}
/* Code Block */
.markdown-source-view.mod-cm6 .cm-content .HyperMD-codeblock-begin {
margin-top: 0.5rem !important;
}
.markdown-source-view.mod-cm6 .cm-content *.HyperMD-codeblock-end {
margin-bottom: 0.5rem !important;
}
.markdown-source-view.mod-cm6 .cm-line.HyperMD-codeblock {
padding-bottom: 0;
}
.markdown-source-view.mod-cm6 .cm-hmd-codeblock {
font-size: var(--code-size);
}
.markdown-rendered pre {
line-height: var(--line-height-normal);
font-size: var(--code-size);
}
/* Plugin Customization */
.outliner-plugin-better-lists .list-bullet::after {
background: var(--list-marker-color);
}
.outliner-plugin-better-lists .cm-formatting-list-ul {
margin-right: 0;
}
.block-language-button {
position: relative;
display: flex;
justify-content: flex-end;
}
.workspace-leaf-content[data-mode="preview"] .my-btn {
cursor: pointer;
position: absolute;
right: 0;
transform: translateY(-50%);
}
.daily-note .daily-note-title {
font-size: var(--h1-size);
color: var(--text-accent);
}
@media print {
@page {
margin: 16mm 10mm 16mm;
}
@page :left {
@bottom-center {
content: counter(page);
font-size: 9pt;
color: #666;
vertical-align: bottom;
margin-bottom: 7mm;
}
}
@page :right {
@bottom-center {
content: counter(page);
font-size: 9pt;
color: #666;
vertical-align: bottom;
margin-bottom: 7mm;
}
}
@page :first {
counter-reset: page -1;
@bottom-center {
content: "❤ Made by Nanmiao Ling";
}
}
@page :blank {
@top-left {
content: none;
}
@top-right {
content: none;
}
@bottom-left {
content: none;
}
@bottom-right {
content: none;
}
}
h1 {
height: 100%;
width: 70%;
text-align: center;
margin: 0 auto;
padding-top: 50%;
}
h1,
h2 {
break-before: page;
}
h2,
h3,
h4,
h5,
h6 {
break-after: avoid;
}
img {
break-inside: avoid;
}
.print .markdown-rendered table,
.print .markdown-rendered th,
.print .markdown-rendered td {
font-size: 0.9rem;
}
.print .markdown-rendered {
font-family: var(--font-text);
}
.print .markdown-rendered h2 {
margin-top: 0;
}
.print .markdown-rendered table {
border-collapse: collapse;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment