Overview
The org preview shows the rendered document next to (or instead of) the
source, the way VS Code's Markdown preview does for .md files. It uses the
same engine as HTML export (Export), so what you see is what
HTML export produces, and it updates as you type.
Opening the Preview
| Action | macOS | Windows/Linux | Command |
|---|---|---|---|
| Open preview (in this group) | Cmd+Shift+V | Ctrl+Shift+V | scimax.org.preview.open |
| Open preview to the side | Cmd+K V | Ctrl+C Shift+V | scimax.org.preview.openToSide |
| Back to the source from preview | Cmd+Shift+V | Ctrl+Shift+V | scimax.org.preview.showSource |
The preview icon in the editor title bar of an org file also opens the preview to the side, and the preview's own title bar has a button that goes back to the source. Each org file has at most one preview; running the command again reveals the existing one.
The older command scimax.org.previewHtml (Scimax: Preview HTML, also
reachable from the export menu) now opens this live preview to the side.
What the Preview Does
Live updates: the preview re-renders shortly after you stop typing (see
scimax.orgPreview.updateDelay) and when you save. The page is updated in place, so it does not flicker and keeps its scroll position.Math: LaTeX fragments (
$x^2$,\[...\], equation environments) are typeset with MathJax.Code: source blocks are highlighted with highlight.js, in a light or dark style that follows the VS Code theme.
Images: local images such as
[[./figure.png]],file:links and Jupyter results in.ob-jupyter/are shown. Images outside the document folder and workspace are allowed as they are found.Theme: colours, fonts and code backgrounds follow the VS Code theme.
Citations:
cite:links are formatted against the files named by#+BIBLIOGRAPHY:/ = as in HTML export. The bibliography is re-read only when the.bibfile changes.#+INCLUDE: directives are expanded.
Settings
| Setting | Default | Description |
|---|---|---|
scimax.orgPreview.updateDelay | 300 | Milliseconds after typing before the preview updates |
scimax.orgPreview.scrollPreviewWithEditor | true | Scroll the preview when the source editor scrolls |
scimax.orgPreview.scrollEditorWithPreview | true | Scroll the source editor when the preview scrolls |
Security
Source blocks are never executed by the preview. Scripts in the document
(for example in #+HTML: blocks or #+HTML_HEAD:) do not run either: the
preview's content security policy allows only its own scripts and the MathJax
and highlight.js files on their CDNs.
Because those libraries load from the network, math and highlighting need an
internet connection; the rest of the preview works offline.