How to adjust the picture in cnblogs article / MarkDown width?

Foreword

MarkDown want to publish the document has been written, need to manually adjust where only pictures. The reason is that the default insert a picture too large, the picture will fill the screen, causing the browser inconvenience.
Personal experience: under the common horizontal screen, the picture should not exceed 2/3 of the screen height, body content should not exceed 2/3 of the width of the screen, so browse the most up liking.

Local notes editor using vNote , is my query after a long period of time, screening and trial, and prefer stable use of a Markdown editing software. Use more handy than others, both the speed, value and color customization.
Since into the local picture, in the .md documents VNote is such a piece of text, copy directly to the Internet, then you need to be processed.
![](_v_images/20190906211935038_10173.png =460x)
To exactly the same as the local style notes show, or take some time, very frustrating process.

process

Blog back garden, there are three optional editors: TinyMCE, Markdown, TextBox, personal understanding as follows.

  • TextBox with Windows notepad, like most streamlined (function minimum), is not considered.

  • TinyMCE similar word, rich text editor, the most versatile (also multi-button).
    In this editor, the size of the image can be adjusted manually inserted, but imprecise. But you can enter HTML source code editor, search png, in alt = "", insert width = "500".
    This method can be achieved demand problem, but you need to find a picture of a picture of the location, and then a bunch of pictures later had to add the code for each subsequent aspect.
    Even with regular expressions in fact, need cumbersome steps, each had to think of a subsequent posting this is the case, is not exhausted, this method also pass.

  • MarkDown 不用多说了,互联网使用最多不敢说,但应该是现在最为推崇的一种码字写文方式,用内容控制样式。
    方便程度介于前两者之间,其实对我来说有时候还是比较麻烦的,ahk的简化输入帮了很大的忙。
    目前还没有找到在博客园的MarkDown编辑器内修改图片宽度的方法。
    例如下图第一三四行这样的写法,图片无法正常显示,第二行的图片可以正常显示。

解决

寻求问题解决办法,搜索引擎。主要参考了这个问题下的回答,五花八门,在博客园编辑器试了下。
Markdown中插入图片怎么定义图片的大小或比例?

  1. 嵌入HTML代码,使用img标签,加上width = "300",或者width = "80%" 。
    <img src="./xxx.png" width = "300" height = "200" alt="图片名称" align=center />
    已经属于HTML的属性了,能修改。其实MarkDown内也有效,但不是原生的,总感觉不太好。
    实在没办法的话,就用它吧,需要将MarkDown的![]()标签转化为HTML的img标签。
    当然是得批量处理,正则表达式出手,除了!,[]()都需要用\进行转义
    方括号跟圆括号在Markdown里面也需要转义,上面偷懒直接代码表示了,实际得输入对应的ASCII码
    查找^!\[\]\((.*cnblogs.com/blog/.*)\),替换<img src="$1" width = "500" />
    对比一下,第一行是默认上传后的,第二张是处理后的。
    ![](https://img2018.cnblogs.com/blog/1816212/201911/1816212-20191106005633853-668571180.png)

    <img src="https://img2018.cnblogs.com/blog/1816212/201911/1816212-20191106005633853-668571180.png" width = "500" />

    此方法好处在于能够精确修改每一张图片的大小,配合Quicker的快捷操作一点都不麻烦,最优解。

  2. 使用支持图片大小更改操作的 Mou 编辑器,加上=100x100。
    ![](./pic/pic1_50.png =100x100)
    此方法在本地能生效,按理来说是最有希望的,但是在博客园的MarkDown编辑器内失效。

  3. 在图片后面加上对应的CSS样式,加上{:height="100px" width="400px"}。
    ![test image size](url){:height="100px" width="400px"}
    在博客园的MarkDown编辑器内无效,经查询是kramdown中InlineAttribute的特性

  4. 找一个支持参数的图床,比如七牛,具体参见图片基本处理 (imageView2)
    http://siwangxinyuan.qiniudn.com/jianshu-42-1280x800-%5BDesktopNexus.com%5D.jpg?imageView/2/w/619/q/90
    非特殊需求,博客园发文就不用图床外链了,不好管理,而且直接复制图片更方便。

  5. mweb编辑器,加上-w数字,数字为缩放大小。
    ![知乎头像-w70](https://pic3.zhimg.com/v2-0a80d2f61233518a3719179a045c41b2_xl.jpg)
    此种方法应该是知乎的MarkDown编辑器支持。不过博客园的测试了下,果然不行。

  6. 直接修改css文件,添加图片样式,再在MarkDown内应用。
    img[src*="#width-full"] { width: 100%; } ![trump.jpg](https://view.moezx.cc/images/2018/05/27/trump.jpg#width-full)
    可以添加几种常用的样式,对图片进行操作,除了高宽,其他css样式也可以应用。

  7. 直接修改css文件,对图片的最大宽度进行限制。
    img { max-width: 80%; }
    此方法应该是次优解,避免部分图片默认尺寸过大同时不影响其他图片大小。完善之后,能够一劳永逸~

拓展

完整版·Markdown 语法说明(简体中文版)

到目前为止, Markdown 还没有办法指定图片的宽高,如果你需要的话,你可以使用普通的 标签。

原来在保存的这篇MD语法中,已经说明了这个问题。个人觉得算是Markdown本身的一个瑕疵吧,毕竟这个问题能原生解决的话,对于纯MD文档的写作已经预览效果都是更好的。
而且对于像我这种强迫症来说,这个问题MD不解决,有点小遗憾,希望原生也能支持修改图片高宽样式。

挖坑

在以上尝试过程中,新问题冒出来了:Mou编辑器、mweb编辑器,kramdown是什么,与MarkDown有什么联系与区别?
再多一点的问题,各类文本编辑器与其渲染效果,有哪些坑?有没有像浏览器与渲染样式那种测评表格?(想法太多了,别打我(;≧皿≦))

Guess you like

Origin www.cnblogs.com/ds37/p/11802849.html