/

本页目录

HTML

标准 Markdown 规范允许自由混用 Markdown 与 HTML,因为它们本就是为仅依赖 HTML 渲染的解析器而设计的。

**Hello** <em>world</em>!

另一方面,Quarkdown 强烈倡导目标无关性(target agnosticism),以维持在全部受支持渲染目标之间的一致渲染效果。

目前,仅支持 HTML 渲染(注意:PDF 导出并非渲染目标,它是在 HTML 后处理之上工作的)。不过未来有计划支持更多目标,例如 LaTeX。在这种情况下,原生目标将不再能处理 HTML 内容。

因此,Quarkdown 放弃了混合内容的支持,转而专注于用专用函数来覆盖最常见的 HTML 变通方案。

示例 1

  • 标准 Markdown 中通过 HTML 实现的折叠块:
    <details>
    <summary>Title of the collapsible block</summary>
    Content of the collapsible block.
    </details>
  • 在 Quarkdown 中,使用 .collapse 函数实现相同效果:
    .collapse {Title of the collapsible block}
        Content of the collapsible block.

示例 2

  • HTML 中的带样式容器:
    <div style="border: 1px solid black; padding: 8px;">
        This is a styled container.
    </div>
  • 在 Quarkdown 中,使用 .container 实现相同效果:
    .container border:{black} borderwidth:{1} padding:{8}
        This is a styled container.

强制注入 HTML

作为最后手段,如果你所需要的功能开箱即不支持,可以考虑调用 .html 函数,它会将内容直接渲染到最终文档中——只要渲染目标是 HTML。

示例 3

**Hello** .html {<em>world</em>}!

Hello world!

示例 4

.html
    <div style="transform: scaleY(0.6);">
        My HTML container
    </div>
My HTML container

  • 渲染输出是未经净化的内容,可能存在安全漏洞。
  • 这种方式并非目标无关的,因为其他渲染目标会忽略所提供的内容。