Repository navigation
Add unlink-image-auto-links feature
#4151
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
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b82fb88
Add `clean-image-auto-links` feature
kidonng 4192d4c
Unnecessary on wiki pages
kidonng fd579e9
Update source/features/clean-image-auto-links.tsx
kidonng 4bc1b9f
Use isSingleMarkdownFile
kidonng 47a54e3
Update source/features/clean-image-auto-links.tsx
kidonng ba3d47e
Merge branch 'main' into clean-image-auto-links
kidonng 8e03376
Simplify code
kidonng 0e7a8e6
Rename to `unlink-image-auto-links`
kidonng c9527a8
Rename `isSingleMarkdownFile` to `isMarkdownFile`
kidonng ae821c7
Add more file types
kidonng 6838056
Update source/features/unlink-image-auto-links.tsx
kidonng cc6c990
Merge branch 'main' into clean-image-auto-links
yakov116 29795da
Restore collapse-markdown-sections.tsx
fregante 5e25daa
Restore hide-markdown-diff.tsx
fregante 76211a4
Restore vertical-front-matter.tsx
fregante a5415d7
Restore index.ts
fregante File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import select from 'select-dom'; | ||
| import * as pageDetect from 'github-url-detection'; | ||
|
|
||
| import features from '.'; | ||
| import GitHubURL from '../github-helpers/github-url'; | ||
| import {isMarkdownFile} from '../github-helpers'; | ||
|
|
||
| function isMarkupFile(): boolean { | ||
| if (isMarkdownFile()) { | ||
| return true; | ||
| } | ||
|
|
||
| // https://github.com/github/markup/blob/46908504f5099b15a88030749f0aeb52cd2f6799/README.md#markups | ||
| if (/\.(textile|rdoc|org|creole|(media)?wiki|rst|a(scii)?doc|asc|pod)$/.test(location.pathname)) { | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| function getRawUrl(link: HTMLAnchorElement): string { | ||
| if (pageDetect.isSingleFile(link)) { | ||
| const rawLink = new GitHubURL(link.href).assign({route: 'raw'}); | ||
| return rawLink.href; | ||
| } | ||
|
|
||
| return link.href; | ||
| } | ||
|
|
||
| function init(): void { | ||
| for (const image of select.all('.markdown-body a > img')) { | ||
| const link = image.parentElement as HTMLAnchorElement; | ||
|
|
||
| if (image.src === getRawUrl(link)) { | ||
| link.replaceWith(image); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void features.add(__filebasename, { | ||
| include: [ | ||
| pageDetect.isRepoTree, | ||
| () => pageDetect.isSingleFile() && isMarkupFile() | ||
| ], | ||
| init | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's inline all the related extensions here, without using external "markdown" checks. Also it should just
return /blah blah/.test(), no need for if/true/false