Skip to content

Improved MarkdownViewer #1490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2024

Conversation

KamilDev
Copy link
Contributor

@KamilDev KamilDev commented Dec 4, 2024

Features

  • Uses the latest github-markdown.css file that contains styling support for both dark and light mode.
  • Table of Contents has an improved design, and:
    • The width can be resized.
    • TOC headings are automatically highlighted to help track your position in the file.
  • Improved fullscreen layout based on Github.com behavior.
  • External links clicked will open in default browser instead of doing nothing.
  • Uses markdownItAnchor to allow heading anchor links in the file to work.
  • Uses highlight.js to provide syntax highlighting to codeblocks.

Changes

  • Made changes to allow the md2html.html file to use relative file imports for better maintainability.
  • MarkdownViewer can now easily be customized by users by modifying files in <Quicklook data folder>/QuickLook.Plugin.MarkdownViewer/
  • Caching and localStorage is now supported thanks to these changes.
  • Prevent default behavior of spacebar scrolling the page, while we use spacebar to dismiss the preview.
  • Sets WebView DefaultBackgroundColor to prevent white flash in dark mode. After the page has loaded, sets DefaultBackgroundColor back to white to have the expected default behavior on HTML pages that don't specify any background color.

Clean up

  • Removed the need for jQuery.
  • Removed old polyfill code.

Screenshots

New:
Screenshot 2024-12-04 214042

Old:
Screenshot 2024-12-04 223338

#### Features
- Uses the latest [github-markdown.css](https://github.com/sindresorhus/github-markdown-css/blob/main/github-markdown.css) file that contains styling support for both dark and light mode.
- Table of Contents has an improved design, and:
	- The width can be resized.
	- TOC headings are automatically highlighted to help track your position in the file.
- Improved fullscreen layout based on Github.com behavior.
- External links clicked will open in default browser instead of doing nothing.
- Uses [markdownItAnchor](https://github.com/valeriangalliat/markdown-it-anchor) to allow heading anchor links in the file to work.
- Uses [highlight.js](https://github.com/highlightjs/highlight.js) to provide syntax highlighting to codeblocks.
#### Changes
- Made changes to allow the `md2html.html` file to use relative file imports for better maintainability.
- MarkdownViewer can now easily be customized by users by modifying files in `<Quicklook data folder>/QuickLook.Plugin.MarkdownViewer/`
- Caching and `localStorage` is now supported thanks to these changes.
- Prevent default behavior of spacebar scrolling the page, while we use spacebar to dismiss the preview.
- Sets `WebView` `DefaultBackgroundColor` to prevent white flash in dark mode. After the page has loaded, sets `DefaultBackgroundColor` back to white to have the expected default behavior on HTML pages that don't specify any background color.
#### Clean up
- Removed the need for `jQuery`.
- Removed old polyfill code.
@emako emako merged commit 06e796a into QL-Win:master Dec 6, 2024
@KamilDev KamilDev deleted the feature/improve-markdown-viewer branch December 6, 2024 02:59
@emako
Copy link
Member

emako commented Dec 6, 2024

@KamilDev Could you provide any markdown file to test the code about // Open in default browser?

@KamilDev
Copy link
Contributor Author

KamilDev commented Dec 6, 2024

Here's a test file with some links:
example.md

The Microsoft Store and Spotify links should work, for a real example. The rest are used to see that the app name associated with the URI is correct. If no app is installed that handles the URI, or it's invalid, Windows will show the native message that no app is installed to handle the URI.

The behavior should be the same when viewing .html, since the code is now in WebpagePanel.

@KamilDev KamilDev mentioned this pull request Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants