【问题标题】:embed openstreetmap iframe in github markdown在 github markdown 中嵌入 openstreetmap iframe
【发布时间】:2018-07-02 08:06:45
【问题描述】:

从 openstreetmap 页面上的共享选项卡,我可以将地图视图导出为 HTML,例如:

<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.openstreetmap.org/export/embed.html?bbox=6.047544479370118%2C46.23053702499607%2C6.061706542968751%2C46.23821801159735&amp;layer=mapnik" style="border: 1px solid black"></iframe>
<br/><small><a href="https://www.openstreetmap.org/#map=17/46.23438/6.05463">View Larger Map</a></small>

我想将其嵌入到 github 上的 README.md 页面中,例如

四处搜索,最接近在 markdown 中嵌入 iframes 的是 gitlab guide。之后我尝试了&lt;figure class="video_container"&gt; 标签,但在 gitlab 或 github 上都看不到它。

# how to find us?

we will be here:
<figure class="video_container">
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.openstreetmap.org/export/embed.html?bbox=6.047544479370118%2C46.23053702499607%2C6.061706542968751%2C46.23821801159735&amp;layer=mapnik" style="border: 1px solid black"></iframe>
</figure>

我是否遗漏了某些东西,或者这是否更好地留给了真正的 HTML,并且超出了 markdown 可以/应该做的事情?

【问题讨论】:

标签: iframe openstreetmap github-flavored-markdown


【解决方案1】:

GFM 不支持

不支持&lt;iframe&gt; 嵌入到 GitHub 风格的 Markdown (GFM) 中。这是from their specs的官方立场:

6.11 不允许的原始 HTML(扩展名)

GFM 启用 tagfilter 扩展,其中 在呈现 HTML 输出时将过滤以下 HTML 标签

&lt;title&gt; &lt;textarea&gt; &lt;style&gt; &lt;xmp&gt; &lt;iframe&gt; &lt;noembed&gt; &lt;noframes&gt; &lt;script&gt; &lt;plaintext&gt;

[...] 这些标签是特别选择的,因为它们改变了 HTML 以一种独特的方式被解释的方式 [...],这在其他渲染的 Markdown 内容的上下文中通常是不受欢迎的。

所有其他 HTML 标记保持不变。


可能的解决方法

other answers 中提到的视频解决方案类似,您可以嵌入地图的屏幕截图,并将其作为链接到您的 OSM 地图部分的 URL :

【讨论】:

    猜你喜欢
    • 2019-07-21
    • 2020-07-25
    • 2019-05-29
    • 2018-06-16
    • 2011-02-14
    • 1970-01-01
    • 1970-01-01
    • 2018-07-03
    • 2011-08-10
    相关资源
    最近更新 更多