markdown-viewer-rs 0.10.0

Render a Markdown file with GitHub styling and live-reload it in your browser
/* markdown-viewer UI: toolbar, sidebar (contents / files), help, copy
   buttons. Uses GitHub's colour variables so it follows the theme. */
.mdv-ui, .mdv-ui * { box-sizing: border-box; }
.mdv-ui {
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  color: var(--fgColor-default);
}
.mdv-ui button {
  font: inherit; color: inherit; background: none; border: 0; cursor: pointer;
}
/* Icons. Only in buttons: the slides of presentation mode are .mdv-ui
   too, and their diagrams (and math) are SVGs that must keep their size. */
.mdv-ui button svg { width: 16px; height: 16px; fill: currentColor; display: block; }

/* Toolbar */
.mdv-toolbar {
  position: fixed; top: 10px; right: 12px; z-index: 20;
  display: flex; align-items: center; gap: 2px; padding: 3px;
  background: var(--bgColor-default); border: 1px solid var(--borderColor-muted);
  border-radius: 8px; opacity: .55; transition: opacity .15s;
}
.mdv-toolbar:hover, .mdv-toolbar:focus-within { opacity: 1; }
.mdv-toolbar button { padding: 5px 6px; border-radius: 6px; color: var(--fgColor-muted); }
.mdv-toolbar button:hover { background: var(--bgColor-neutral-muted); color: var(--fgColor-default); }
.mdv-toolbar button[aria-pressed="true"] { color: var(--fgColor-accent); }
.mdv-stats { padding: 0 8px 0 6px; color: var(--fgColor-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .mdv-stats { display: none; } }
.mdv-stats { cursor: pointer; }
:root[data-mdv-stats="off"] .mdv-stats { display: none; }

/* Sidebar */
.mdv-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px; z-index: 15;
  display: flex; flex-direction: column;
  background: var(--bgColor-muted); border-right: 1px solid var(--borderColor-muted);
  transform: translateX(-100%); transition: transform .18s ease;
}
html.mdv-sidebar-open .mdv-sidebar { transform: none; box-shadow: 0 0 24px rgba(0,0,0,.08); }
@media (min-width: 1200px) {
  html.mdv-sidebar-open body { padding-left: 280px; }
  html.mdv-sidebar-open .mdv-sidebar { box-shadow: none; }
}
.mdv-tabs { display: flex; gap: 4px; padding: 10px 10px 6px; border-bottom: 1px solid var(--borderColor-muted); }
.mdv-tabs button { padding: 4px 10px; border-radius: 6px; color: var(--fgColor-muted); font-weight: 600; }
.mdv-tabs button[aria-selected="true"] { background: var(--bgColor-neutral-muted); color: var(--fgColor-default); }
.mdv-tabs .mdv-close { margin-left: auto; padding: 4px 6px; }
.mdv-panel { flex: 1; overflow-y: auto; padding: 8px 6px 24px; }
.mdv-panel[hidden] { display: none; }
.mdv-panel a {
  display: block; padding: 3px 8px; border-radius: 6px; color: var(--fgColor-default);
  text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mdv-panel a:hover { background: var(--bgColor-neutral-muted); }
.mdv-panel a.mdv-active { color: var(--fgColor-accent); background: var(--bgColor-neutral-muted); font-weight: 600; }
.mdv-panel .mdv-l2 { padding-left: 20px; }
.mdv-panel .mdv-l3 { padding-left: 32px; color: var(--fgColor-muted); }
.mdv-panel .mdv-l4 { padding-left: 44px; color: var(--fgColor-muted); font-size: 12px; }
.mdv-panel .mdv-dir { color: var(--fgColor-muted); font-size: 12px; padding: 8px 8px 2px; }
.mdv-empty { padding: 8px; color: var(--fgColor-muted); }
.mdv-filter {
  width: 100%; margin: 2px 0 8px; padding: 5px 8px; font: inherit; color: inherit;
  background: var(--bgColor-default); border: 1px solid var(--borderColor-default); border-radius: 6px;
}

/* Help overlay and toast */
.mdv-overlay {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.35);
}
.mdv-overlay[hidden] { display: none; }
.mdv-help {
  min-width: 320px; max-width: min(620px, 90vw); max-height: 88vh; overflow-y: auto;
  padding: 16px 20px; border-radius: 10px;
  background: var(--bgColor-default); border: 1px solid var(--borderColor-default);
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.mdv-help h2 { font-size: 15px; margin: 0 0 10px; }
.mdv-help table { border-collapse: collapse; width: 100%; }
.mdv-help td { padding: 3px 0; }
.mdv-help td:first-child { padding-right: 16px; white-space: nowrap; }
.mdv-help kbd {
  display: inline-block; min-width: 20px; padding: 1px 5px; text-align: center;
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  border: 1px solid var(--borderColor-default); border-bottom-width: 2px; border-radius: 5px;
  background: var(--bgColor-muted);
}
.mdv-toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 30;
  padding: 6px 12px; border-radius: 6px; pointer-events: none;
  background: var(--fgColor-default); color: var(--bgColor-default);
  opacity: 0; transition: opacity .2s;
}
.mdv-toast.mdv-show { opacity: .92; }

/* Copy buttons on code blocks */
.markdown-body .mdv-code { position: relative; }
.markdown-body .mdv-copy {
  position: absolute; top: 8px; right: 8px; padding: 5px; line-height: 0;
  color: var(--fgColor-muted); background: var(--bgColor-muted);
  border: 1px solid var(--borderColor-default); border-radius: 6px; cursor: pointer;
  opacity: 0; transition: opacity .15s;
}
.markdown-body .mdv-copy svg { width: 16px; height: 16px; fill: currentColor; }
.markdown-body .mdv-code:hover .mdv-copy, .markdown-body .mdv-copy:focus { opacity: 1; }
.markdown-body .mdv-copy.mdv-copied { color: #1a7f37; border-color: #1a7f37; }

/* Jump to edit: briefly highlight the changed block */
@keyframes mdv-flash {
  from { background-color: var(--bgColor-attention-muted); box-shadow: 0 0 0 6px var(--bgColor-attention-muted); }
  to { background-color: transparent; box-shadow: 0 0 0 6px transparent; }
}
.markdown-body .mdv-flash { animation: mdv-flash 1.6s ease-out; border-radius: 4px; }

/* Search results in the Files panel */
.mdv-panel a.mdv-hit { white-space: normal; padding-top: 5px; padding-bottom: 5px; }
.mdv-hit-file { display: block; font-size: 12px; color: var(--fgColor-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mdv-hit-text { display: block; font-size: 12px; overflow-wrap: anywhere; }
.mdv-hit mark { background: var(--bgColor-attention-muted); color: inherit; border-radius: 2px; }

/* Image and diagram zoom */
.markdown-body img:not(a img), .markdown-body div.mermaid { cursor: zoom-in; }
.mdv-zoom { position: fixed; inset: 0; z-index: 45; background: rgba(0,0,0,.82); overflow: hidden; cursor: grab; }
.mdv-zoom.mdv-dragging { cursor: grabbing; }
.mdv-zoom-stage { position: absolute; left: 50%; top: 50%; transform-origin: 0 0; }
.mdv-zoom-stage > img, .mdv-zoom-stage > svg {
  display: block; max-width: 92vw; max-height: 92vh; border-radius: 6px;
  background: var(--bgColor-default); box-shadow: 0 12px 48px rgba(0,0,0,.4);
}
.mdv-zoom-stage > svg { max-height: none; padding: 16px; }

/* Presentation mode */
.mdv-present {
  position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column;
  background: var(--bgColor-default);
}
.mdv-present .markdown-body.mdv-slide {
  flex: 1; display: flex; flex-direction: column; overflow-y: auto;
  /* "safe" keeps tall slides scrollable from their top. */
  justify-content: safe center;
  width: 100%; max-width: 1200px; margin: 0 auto; padding: 5vh 6vw;
  font-size: clamp(18px, 2.1vw, 32px);
}
.mdv-present .mdv-slide-inner { flex-shrink: 0; }
.mdv-present .mdv-slide h1, .mdv-present .mdv-slide h2 { border-bottom: none; }
/* Diagrams fill the slide (Mermaid caps them at their natural width). */
.mdv-present .mdv-slide div.mermaid svg { width: 100%; max-width: 100% !important; height: auto; max-height: 65vh; }
.mdv-present-bar { padding: 8px 18px; text-align: right; color: var(--fgColor-muted); font-variant-numeric: tabular-nums; }

/* Text size (+ / -), remembered between runs */
.markdown-body { zoom: var(--mdv-scale, 1); }

/* Wrap toggle next to each code block's copy button */
.markdown-body .mdv-wrap-btn {
  position: absolute; top: 8px; right: 44px; padding: 3px 8px; line-height: 1.2;
  font: 14px -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--fgColor-muted); background: var(--bgColor-muted);
  border: 1px solid var(--borderColor-default); border-radius: 6px; cursor: pointer;
  opacity: 0; transition: opacity .15s;
}
.markdown-body .mdv-code:hover .mdv-wrap-btn, .markdown-body .mdv-wrap-btn:focus { opacity: 1; }
.markdown-body .mdv-wrap-btn[aria-pressed="true"] { color: var(--fgColor-accent); border-color: var(--fgColor-accent); opacity: 1; }
.markdown-body .mdv-code-figure .mdv-code .mdv-copy, .markdown-body .mdv-code-figure .mdv-code .mdv-wrap-btn { top: 6px; }

/* Changes since the last git commit (D) */
/* A bar in the left margin, the full height of the block (like an
   editor's gutter), without moving anything. */
.markdown-body .mdv-git-added, .markdown-body .mdv-git-modified { position: relative; }
.markdown-body .mdv-git-added::after, .markdown-body .mdv-git-modified::after {
  content: ""; position: absolute; left: -14px; top: 0; bottom: 0; width: 3px; border-radius: 2px;
  pointer-events: none;
}
.markdown-body .mdv-git-added::after { background: #1a7f37; }
.markdown-body .mdv-git-modified::after { background: #bf8700; }
/* Table rows can't hold a positioned bar; mark their first cell instead. */
.markdown-body tr.mdv-git-added::after, .markdown-body tr.mdv-git-modified::after { content: none; }
.markdown-body tr.mdv-git-added > :first-child { box-shadow: inset 3px 0 0 #1a7f37; }
.markdown-body tr.mdv-git-modified > :first-child { box-shadow: inset 3px 0 0 #bf8700; }
/* Removed lines: a red line above the block that follows them. */
.markdown-body .mdv-git-deleted { box-shadow: 0 -3px 0 -1px #cf222e; }
@media print {
  .markdown-body .mdv-git-added::after, .markdown-body .mdv-git-modified::after { content: none; }
  .markdown-body .mdv-git-deleted, .markdown-body tr > :first-child { box-shadow: none; }
}

/* Broken links (l) */
.mdv-broken { max-height: 70vh; overflow-y: auto; width: min(560px, 90vw); }
.mdv-broken-item {
  display: block; width: 100%; text-align: left; padding: 6px 8px; border-radius: 6px;
}
.mdv-broken-item:hover { background: var(--bgColor-neutral-muted); }
.mdv-broken .mdv-hit-text { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }

/* Task boxes that update the file (served pages). */
.markdown-body input.task-list-item-checkbox:not([disabled]) { cursor: pointer; }

/* Sortable tables: click a header. The arrow shows the current order. */
.markdown-body table.mdv-sortable thead th { cursor: pointer; user-select: none; }
.markdown-body table.mdv-sortable thead th:hover { background: var(--bgColor-muted); }
.markdown-body table.mdv-sortable th[aria-sort]::after {
  content: "â–²"; display: inline-block; margin-left: 4px; font-size: 0.7em; color: var(--fgColor-muted);
}
.markdown-body table.mdv-sortable th[aria-sort="descending"]::after { content: "â–¼"; }

/* About, in the help */
.mdv-help h2:not(:first-child) { margin-top: 18px; }
.mdv-help .mdv-about td { padding: 2px 0; vertical-align: top; }
.mdv-help .mdv-about td:first-child { padding-right: 16px; color: var(--fgColor-muted); white-space: nowrap; }
.mdv-help .mdv-about td:last-child { overflow-wrap: anywhere; }
.mdv-help .mdv-about a, .mdv-help .mdv-about-links a { color: var(--fgColor-accent); text-decoration: none; }
.mdv-help .mdv-about a:hover, .mdv-help .mdv-about-links a:hover { text-decoration: underline; }
.mdv-help .mdv-about-links { margin: 10px 0 8px; color: var(--fgColor-muted); }
.mdv-help .mdv-about-copy {
  padding: 3px 10px; font: inherit; font-size: 12px; color: inherit; cursor: pointer;
  background: var(--bgColor-muted); border: 1px solid var(--borderColor-default); border-radius: 6px;
}
.mdv-help .mdv-about-copy:hover { border-color: var(--fgColor-muted); }

/* Credits, in the help */
.mdv-help h3 { font-size: 13px; margin: 12px 0 4px; color: var(--fgColor-muted); font-weight: 600; }
.mdv-help .mdv-credits-intro { margin: 0 0 6px; color: var(--fgColor-muted); }
.mdv-help .mdv-credits { list-style: none; margin: 0; padding: 0; }
.mdv-help .mdv-credits li { padding: 1px 0; }
.mdv-help .mdv-credits-crates { columns: 2; column-gap: 24px; }
.mdv-help .mdv-credits-crates li { break-inside: avoid; }
.mdv-help .mdv-credits a { color: var(--fgColor-accent); text-decoration: none; }
.mdv-help .mdv-credits a:hover { text-decoration: underline; }
.mdv-help .mdv-credit-version { color: var(--fgColor-muted); font-size: 12px; }
.mdv-help .mdv-credit-license {
  margin-left: 6px; padding: 0 5px; font-size: 11px; border-radius: 8px; white-space: nowrap;
  color: var(--fgColor-muted); border: 1px solid var(--borderColor-default);
}
@media (max-width: 520px) { .mdv-help .mdv-credits-crates { columns: 1; } }

/* Settings dialog */
.mdv-settings { width: min(560px, 92vw); }
.mdv-settings .mdv-settings-file { margin: 0 0 6px; color: var(--fgColor-muted); font-size: 12px; overflow-wrap: anywhere; }
.mdv-settings .mdv-settings-note { color: var(--fgColor-muted); font-size: 12px; margin: 0; }
.mdv-settings .mdv-settings-error { color: var(--fgColor-danger); }
.mdv-settings h3 { margin-top: 16px; padding-bottom: 4px; border-bottom: 1px solid var(--borderColor-muted); }
.mdv-setting {
  display: grid; grid-template-columns: 1fr minmax(180px, 46%); gap: 2px 12px; align-items: center;
  padding: 6px 0;
}
.mdv-setting .mdv-setting-status { grid-column: 1 / -1; font-size: 12px; color: var(--fgColor-success); min-height: 0; }
.mdv-setting .mdv-setting-status:empty { display: none; }
.mdv-setting.mdv-setting-check { grid-template-columns: auto 1fr; }
.mdv-setting input[type="checkbox"] { margin: 0; width: 16px; height: 16px; }
.mdv-setting select, .mdv-setting input[type="text"], .mdv-setting input[type="number"] {
  width: 100%; padding: 4px 8px; font: inherit; color: inherit;
  background: var(--bgColor-default); border: 1px solid var(--borderColor-default); border-radius: 6px;
}
.mdv-setting select:focus, .mdv-setting input:focus { outline: 2px solid var(--focus-outlineColor, #0969da); outline-offset: -1px; }
.mdv-setting-rules { display: flex; flex-direction: column; gap: 2px; }
.mdv-setting-rules label { display: flex; align-items: center; gap: 4px; }

/* Source view (v): the highlighted Markdown in place of the page. */
.mdv-source-view { display: none; }
/* The page keeps its layout while hidden (content-visibility, not
   display: none), so going back to a long page is quick. */
:root[data-mdv-view="source"] article.markdown-body {
  content-visibility: hidden; contain-intrinsic-size: 0; height: 0; padding-top: 0; padding-bottom: 0;
}
:root[data-mdv-view="source"] .mdv-source-view { display: block; }
.mdv-source-view .mdv-source-code {
  padding: 16px 16px 16px 0; font-size: 13px; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
/* Chunks off screen aren't laid out (long files open quickly); about 200
   lines of 20px until measured. Line numbers come from data-line, since
   skipped chunks would cut CSS counters off. */
.mdv-source-view .mdv-chunk { display: block; content-visibility: auto; contain-intrinsic-size: auto 4000px; }
.mdv-source-view .mdv-line { display: block; padding-left: 4.2em; text-indent: -4.2em; }
.mdv-source-view .mdv-line::before {
  content: attr(data-line);
  display: inline-block; width: 3.2em; margin-right: 1em; text-align: right; text-indent: 0;
  color: var(--fgColor-muted); opacity: .7; user-select: none;
}
.mdv-source-view .mdv-line:hover { background: var(--bgColor-neutral-muted); }
@media print { :root[data-mdv-view="source"] .mdv-source-view .mdv-line:hover { background: none; } }

/* Source view feedback: a pulsing button and a status label while the
   source loads and highlights. */
.mdv-toolbar button.mdv-busy { animation: mdv-pulse 1s ease-in-out infinite; color: var(--fgColor-accent); }
@keyframes mdv-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .mdv-toolbar button.mdv-busy { animation: none; } }
.mdv-source-status {
  position: fixed; top: 46px; right: 12px; z-index: 20; padding: 3px 10px; border-radius: 12px;
  font: 12px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--fgColor-muted); background: var(--bgColor-default); border: 1px solid var(--borderColor-default);
}
.mdv-source-status[hidden] { display: none; }
.mdv-source-view .mdv-source-loading { color: var(--fgColor-muted); padding: 24px 0; }