### Install gh-markdown-preview extension Source: https://github.com/yusukebe/gh-markdown-preview/blob/master/README.md Installs the extension using the GitHub CLI. ```bash gh extension install yusukebe/gh-markdown-preview ``` -------------------------------- ### Install and Upgrade Extension Source: https://context7.com/yusukebe/gh-markdown-preview/llms.txt Commands to install or update the gh-markdown-preview extension via the GitHub CLI. ```bash # Install the extension gh extension install yusukebe/gh-markdown-preview # Upgrade to the latest version gh extension upgrade markdown-preview ``` -------------------------------- ### GET / Source: https://context7.com/yusukebe/gh-markdown-preview/llms.txt Serves the main HTML preview page with GitHub styling. ```APIDOC ## GET / ### Description Serves the main HTML preview page with GitHub styling. ### Method GET ### Endpoint / ### Response #### Success Response (200) - **body** (HTML) - The rendered HTML page with GitHub styling. ``` -------------------------------- ### Display Version Information Source: https://context7.com/yusukebe/gh-markdown-preview/llms.txt Check the currently installed version of the extension. ```bash # Show version gh markdown-preview --version ``` -------------------------------- ### Upgrade gh-markdown-preview extension Source: https://github.com/yusukebe/gh-markdown-preview/blob/master/README.md Updates the installed extension to the latest version. ```bash gh extension upgrade markdown-preview ``` -------------------------------- ### GET /__/md Source: https://context7.com/yusukebe/gh-markdown-preview/llms.txt Returns the raw HTML body for a given markdown file. ```APIDOC ## GET /__/md ### Description Returns the raw HTML body for a given markdown file. ### Method GET ### Endpoint /__/md ### Parameters #### Query Parameters - **path** (string) - Optional - The file path of the markdown file to render. ### Response #### Success Response (200) - **body** (HTML) - The raw HTML content of the rendered markdown. ``` -------------------------------- ### View Help and Options Source: https://context7.com/yusukebe/gh-markdown-preview/llms.txt Display the full list of available command-line arguments and their defaults. ```bash # Full help output gh markdown-preview --help # Options: # --dark-mode Force dark mode # --markdown-mode Force "markdown" mode (rather than default "gfm") # --disable-auto-open Disable auto opening your browser # --disable-reload Disable live reloading # -h, --help help for gh-markdown-preview # --host string Hostname this server will bind (default "localhost") # --light-mode Force light mode # -p, --port int TCP port number of this server (default 3333) # --verbose Show verbose output # --version Show the version ``` -------------------------------- ### View command options Source: https://github.com/yusukebe/gh-markdown-preview/blob/master/README.md List of available flags and configuration options for the preview server. ```text --dark-mode Force dark mode --markdown-mode Force "markdown" mode (rather than default "gfm") --disable-auto-open Disable auto opening your browser --disable-reload Disable live reloading -h, --help help for gh-markdown-preview --host string Hostname this server will bind (default "localhost") --light-mode Force light mode -p, --port int TCP port number of this server (default 3333) --verbose Show verbose output --version Show the version ``` -------------------------------- ### Configure Server Host and Port Source: https://context7.com/yusukebe/gh-markdown-preview/llms.txt Options to bind the local server to a specific hostname or custom port. ```bash # Use a custom port gh markdown-preview README.md --port 8080 # Bind to a specific hostname gh markdown-preview README.md --host 0.0.0.0 # Combined host and port configuration gh markdown-preview README.md --host 127.0.0.1 --port 9000 ``` -------------------------------- ### Preview Markdown from stdin Source: https://github.com/yusukebe/gh-markdown-preview/blob/master/README.md Methods for piping content or redirecting input to the previewer. ```bash echo "# Hello" | gh markdown-preview cat README.md | gh markdown-preview gh markdown-preview - < README.md ``` -------------------------------- ### Set Theme Mode Source: https://context7.com/yusukebe/gh-markdown-preview/llms.txt Force light or dark mode to override system preferences. ```bash # Force dark mode gh markdown-preview README.md --dark-mode # Force light mode gh markdown-preview README.md --light-mode # Default: Uses system preference (prefers-color-scheme) gh markdown-preview README.md ``` -------------------------------- ### Enable Verbose Output Source: https://context7.com/yusukebe/gh-markdown-preview/llms.txt Display detailed debug information for troubleshooting. ```bash # Enable verbose output for debugging gh markdown-preview README.md --verbose ``` -------------------------------- ### Preview Markdown files Source: https://github.com/yusukebe/gh-markdown-preview/blob/master/README.md Commands to preview specific files or automatically detect README files in the current directory. ```bash gh markdown-preview README.md ``` ```bash gh markdown-preview ``` -------------------------------- ### Toggle Rendering Mode Source: https://context7.com/yusukebe/gh-markdown-preview/llms.txt Switch between GitHub Flavored Markdown (default) and standard Markdown rendering. ```bash # Default: GitHub Flavored Markdown mode gh markdown-preview README.md # Force standard markdown mode (disables GFM features) gh markdown-preview README.md --markdown-mode ``` -------------------------------- ### Markdown Loading and Rendering Source: https://github.com/yusukebe/gh-markdown-preview/blob/master/cmd/template.html Fetches Markdown content via AJAX and initializes Mermaid diagrams and copy buttons. ```javascript function loadmd() { $.ajax({ url: "/__/md?path=" + window.location.pathname.slice(1), success: function (result) { $("#markdown-body").html(result).promise().done(function(){ var count = $("#markdown-body a").length; $("#markdown-body a").each(function(i){ var a = $(this); if (a.attr("id") != undefined ) { var id = a.attr("id").replace("user-content-", ""); a.attr("id", id); } if (i+1 === count) { if(location.hash) { var url = location.href; location.href = location.hash; history.replaceState(null,null,url); } } MathJax.typeset(); }); {{ if eq .Mode "dark" }} const mermaidJsTheme = 'dark'; {{ else if eq .Mode "light" }} const mermaidJsTheme = 'default'; {{ else }} const mermaidJsTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'default'; {{ end }} mermaid.initialize({ startOnLoad: false, theme: mermaidJsTheme }); $('div.highlight-source-mermaid > pre').each(async function(i, pre) { const originalText = pre.textContent; const id = 'mermaid-diagram-' + i; try { const { svg } = await mermaid.render(id, originalText); $(pre).html(svg); // Store original text for copy functionality $(pre).data('original-text', originalText); // Add copy button after rendering const button = $(``); $(pre).css("position", "relative").append(button); button.on('click', function () { navigator.clipboard.writeText(originalText).then(function () { button.html(tickIcon); setTimeout(() => { button.html(copyIcon) }, 1000); }, function () { alert('Failed to copy'); }); }); } catch (error) { console.error('Mermaid rendering error:', error); $(pre).html('