【问题标题】:What is the correct address for an image in a markdown document in VSTS?VSTS 中 Markdown 文档中图像的正确地址是什么?
【发布时间】:2017-06-21 13:10:04
【问题描述】:

我在 Visual Studio Team Services 中托管的 git 存储库的根目录中有一个 README.md 文件。

当我通过项目门户导航到 Web 浏览器中的文件时,我可以看到正确呈现的降价,但图像除外。我想在 README 文件中添加一些屏幕截图,并想知道引用存储在 root of the repository/doc/images/image01.png 文件夹中的图像的正确方法

由于 README 文件也存储在存储库的根目录中,我认为它只是一个相对链接。在我的计算机(OSX)上使用 Visual Studio Code 时,我可以使用相对路径,并且使用图像标签正确呈现图像,如下所示:

![Alt text](doc/images/readmeFileComparison.png?raw=true "Readme file side by side comparison")

在使用浏览器(示例 url)查看 README 文件时,图像标签是否必须不同才能让我查看图像:

https://myaccount.visualstudio.com/ProjectName/_git/repositoryName?path=%2FREADME.md&version=GBmaster&_a=contents

guidance from Microsoft,但一定有我遗漏的东西。渲染降价时,我得到一个丢失的图像标签。如果我在新选项卡中打开图像,我会收到 HTTP 500 错误和以下消息:

有关此错误的更多信息

项目 doc/images/pullNewChangesFromMaster.png?raw=true 不 存在于指定版本,或者您没有权限 访问它。

即使地址有或缺少地址中的前导正斜杠,我也会收到相同的错误。

 ![Alt text](doc/images/pullNewChangesFromMaster.png?raw=true "About to Pull down the new changes")

 ![Alt text](/doc/images/pullNewChangesFromMaster.png?raw=true "About to Pull down the new changes")

【问题讨论】:

  • 指导没有提到?raw=true:你试过没有?raw=true吗?
  • 这就是答案,要回答问题吗?
  • 太棒了!我添加了一个答案来说明正确的语法。

标签: git markdown azure-devops visual-studio-code


【解决方案1】:

阅读Guidance page from Microsoft,我没有看到任何地方提到过?raw=true

所以最好在没有它的情况下尝试你的相对链接。

![Alt text](doc/images/pullNewChangesFromMaster.png "About to Pull down the new changes")

【讨论】:

  • 简单。谢谢,我不应该错过的。让另一双眼睛审视您的作品,从中寻找新的视角,真是太好了。
【解决方案2】:

在处理markdown文件中的图片时,区分两种可能的错误很重要:链接错误和语法错误。

1- 链接错误

当链接断开时,一个损坏的图像和您在[] 中输入的文本将显示在渲染文件中。示例:

![not found text](link/to/the/image.png "hover text")

2- 语法错误

在某些情况下,渲染器不接受该语法。在这种情况下,它将显示您的整个文本。

![not found text](link/to/the image.png "hover text")

结果是这样的:

第二个例子的问题是它的 URL 中有一个空格字符。地址中的所有空格都应替换为%20,如下所示:

![not found text](link/to/the%20image.png "hover text")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-25
    • 2020-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多