From 3a7ad6299ea0d4f1ee2eda68a51222bc9ee341b6 Mon Sep 17 00:00:00 2001 From: "cinwell.li" Date: Fri, 29 Jun 2018 21:27:41 +0800 Subject: [PATCH] feat: support image resizing, resolve #508 (#545) * feat: support image resizing, resolve #508 * add docs --- docs/de-de/helpers.md | 34 ++++++++++++++++++++++------------ docs/helpers.md | 34 ++++++++++++++++++++++------------ docs/zh-cn/helpers.md | 34 ++++++++++++++++++++++------------ src/core/render/compiler.js | 10 ++++++++++ 4 files changed, 76 insertions(+), 36 deletions(-) diff --git a/docs/de-de/helpers.md b/docs/de-de/helpers.md index 570c74ca..ab08bda1 100644 --- a/docs/de-de/helpers.md +++ b/docs/de-de/helpers.md @@ -60,17 +60,27 @@ You will get `link`html. Do not worry, you can still set ti ## Github Task Lists ```md -* [ ] foo -* bar -* [x] baz -* [] bam <~ not working - * [ ] bim - * [ ] lim +- [ ] foo +- bar +- [x] baz +- [] bam <~ not working + - [ ] bim + - [ ] lim ``` -* [ ] foo -* bar -* [x] baz -* [] bam <~ not working - * [ ] bim - * [ ] lim +- [ ] foo +- bar +- [x] baz +- [] bam <~ not working + - [ ] bim + - [ ] lim + +## Image resizing + +```md +![logo](https://docsify.js.org/_media/icon.svg ':size=50x100') +![logo](https://docsify.js.org/_media/icon.svg ':size=100') +``` + +![logo](https://docsify.js.org/_media/icon.svg ':size=50x100') +![logo](https://docsify.js.org/_media/icon.svg ':size=100') diff --git a/docs/helpers.md b/docs/helpers.md index 59a299cf..764b88a8 100644 --- a/docs/helpers.md +++ b/docs/helpers.md @@ -66,17 +66,27 @@ You will get `link`html. Do not worry, you can still set ti ## Github Task Lists ```md -* [ ] foo -* bar -* [x] baz -* [] bam <~ not working - * [ ] bim - * [ ] lim +- [ ] foo +- bar +- [x] baz +- [] bam <~ not working + - [ ] bim + - [ ] lim ``` -* [ ] foo -* bar -* [x] baz -* [] bam <~ not working - * [ ] bim - * [ ] lim +- [ ] foo +- bar +- [x] baz +- [] bam <~ not working + - [ ] bim + - [ ] lim + +## Image resizing + +```md +![logo](https://docsify.js.org/_media/icon.svg ':size=50x100') +![logo](https://docsify.js.org/_media/icon.svg ':size=100') +``` + +![logo](https://docsify.js.org/_media/icon.svg ':size=50x100') +![logo](https://docsify.js.org/_media/icon.svg ':size=100') diff --git a/docs/zh-cn/helpers.md b/docs/zh-cn/helpers.md index f29f0fc2..eab5cbc3 100644 --- a/docs/zh-cn/helpers.md +++ b/docs/zh-cn/helpers.md @@ -56,17 +56,27 @@ docsify 扩展了一些 Markdown 语法,可以让文档更易读。 ## Github 任务列表 ```md -* [ ] foo -* bar -* [x] baz -* [] bam <~ not working - * [ ] bim - * [ ] lim +- [ ] foo +- bar +- [x] baz +- [] bam <~ not working + - [ ] bim + - [ ] lim ``` -* [ ] foo -* bar -* [x] baz -* [] bam <~ not working - * [ ] bim - * [ ] lim +- [ ] foo +- bar +- [x] baz +- [] bam <~ not working + - [ ] bim + - [ ] lim + +## Image resizing + +```md +![logo](https://docsify.js.org/_media/icon.svg ':size=50x100') +![logo](https://docsify.js.org/_media/icon.svg ':size=100') +``` + +![logo](https://docsify.js.org/_media/icon.svg ':size=50x100') +![logo](https://docsify.js.org/_media/icon.svg ':size=100') diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index 82544ce9..49242084 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -257,6 +257,16 @@ export class Compiler { attrs += ` title="${title}"` } + const size = config.size + if (size) { + const sizes = size.split('x') + if (sizes[1]) { + attrs += 'width=' + sizes[0] + ' height=' + sizes[1] + } else { + attrs += 'width=' + sizes[0] + } + } + if (!isAbsolutePath(href)) { url = getPath(contentBase, getParentPath(router.getCurrentPath()), href) }