在 GitLab Flavored Markdown 中创建外部 link

Create external link in GitLab Flavored Markdown

GitLab Flavored Markdown 中是否有 link 外部文件(非 http url)?

正常的 Markdown 超链接语法应该有效:[file description](file:///test/location/file)

file:// 协议未包含在 sanitation filter whitelist referenced by gitlab in the documentation 中。

您可以在安装的 gitlab 中手动编辑 embedded/service/gitlab-rails/lib/gitlab/markdown.rb,自己将协议添加到白名单,然后重新启动 gitlab 以应用更改(只需插入前导 + 的行):

  whitelist = HTML::Pipeline::SanitizationFilter::WHITELIST
  whitelist[:attributes][:all].push('class', 'id')
  whitelist[:elements].push('span')
+ whitelist[:protocols]['a']['href'] = ['file'].concat(whitelist[:protocols]['a']['href'])

  # Remove the rel attribute that the sanitize gem adds, and remove the
  # href attribute if it contains inline javascript

但这可能不是最好的主意,因为它会在升级 gitlab 安装时偶尔引起头痛。

如果没有额外的配置步骤或在客户端安装插件(请参阅 here),所需的 file:// 链接仍将无法按预期打开。