Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(md-enhance): add imageSize option, close #1929
- Loading branch information
1 parent
68bd24b
commit d48cc56
Showing
14 changed files
with
662 additions
and
94 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,108 @@ | ||
--- | ||
title: Image | ||
icon: pic | ||
--- | ||
|
||
Improve image syntax in Markdown to support color scheme and size. | ||
|
||
<!-- more --> | ||
|
||
## Config | ||
|
||
::: code-tabs#language | ||
|
||
@tab TS | ||
|
||
```ts {7-10} | ||
// .vuepress/config.ts | ||
import { mdEnhancePlugin } from "vuepress-plugin-md-enhance"; | ||
|
||
export default { | ||
plugins: [ | ||
mdEnhancePlugin({ | ||
// Enable image mark | ||
imageMark: true, | ||
// Enable image size | ||
imageSize: true, | ||
}), | ||
], | ||
}; | ||
``` | ||
|
||
@tab JS | ||
|
||
```js {7-10} | ||
// .vuepress/config.js | ||
const { mdEnhancePlugin } = require("vuepress-plugin-md-enhance"); | ||
|
||
module.exports = { | ||
plugins: [ | ||
mdEnhancePlugin({ | ||
// Enable image mark | ||
imageMark: true, | ||
// Enable image size | ||
imageSize: true, | ||
}), | ||
], | ||
}; | ||
``` | ||
|
||
::: | ||
|
||
## Image Mark | ||
|
||
GFM supports marking pictures by ID suffix so that pictures are only displayed in a specific mode. We support both GitHub’s markup and the easy markup `#light` and `#dark`. | ||
|
||
You can enable it using `imageMark` option. | ||
|
||
```md | ||
![GitHub Light](/assets/icon/github-light.png#gh-dark-mode-only) | ||
![GitHub Dark](/assets/icon/github-dark.png#gh-light-mode-only) | ||
|
||
![GitHub Light](/assets/icon/github-light.png#dark) | ||
![GitHub Dark](/assets/icon/github-dark.png#light) | ||
``` | ||
|
||
::: details Case | ||
|
||
The above demo will render the following result | ||
|
||
![GitHub Light](/assets/icon/github-light.png#gh-dark-mode-only) | ||
![GitHub Dark](/assets/icon/github-dark.png#gh-light-mode-only) | ||
|
||
![GitHub Light](/assets/icon/github-light.png#dark) | ||
![GitHub Dark](/assets/icon/github-dark.png#light) | ||
|
||
::: | ||
|
||
### Advanced | ||
|
||
You can pass an object to `imageMark` to config ID marks, available options are: | ||
|
||
```ts | ||
interface ImageMarkOptions { | ||
/** lightmode only IDs */ | ||
light?: string[]; | ||
/** darkmode only IDs */ | ||
dark?: string[]; | ||
} | ||
``` | ||
|
||
## Image Size | ||
|
||
You can use `=widthxheight` to specify the image size when setting `imageSize: true` in plugin options. | ||
|
||
```md | ||
![Alt](/example.png =200x300) | ||
|
||
![Alt](/example.jpg "Image title" =200x) | ||
![Alt](/example.bmp =x300) | ||
``` | ||
|
||
The above markdown will be parsed as: | ||
|
||
```html | ||
<img src="/example.png" width="200" height="300" /> | ||
<img src="/example.jpg" title="Image title" width="200" /> | ||
<img src="/example.bmp" height="300" /> | ||
``` |
This file contains 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 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 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
Oops, something went wrong.