0

我正在将中间人用于具有不同 YAML 文件中数据的静态网站。我想将其中一些数据拆分为多行。我浏览了文档和不同的论坛,但没有找到任何对我有用的东西。

下面是我的 YAML 文件的代码。“|” 应该完全符合我的要求,但文本仍显示为一个巨大的独特段落,带有正常空格而不是新行。我在这里遗漏了什么明显的东西吗?

  day_1:    |
            Marrakech-tizi n’tichka-teloute kasbah-ait ben haddou kasbah-ourazazate-agdz

            We will collect you from your Marrakech accommadation (Riad or hotel)
            at 9 am with a private and air-conditioned transportation then start
            your desert tour by heading towards the high atlas and crossing
            Tizi n’tichka Pass 2260m.

            We follow the one thousand kasbahs road via ounila valley till arriving
            to the Kasbah of teloute, an ancient gathering of old trading caravans
            coming from the large sahara desert.

            Afterwards we visit The earthen Kasbah Of Ait ben Haddou classified as
            UNSECO world Heritage Site and a backdrop of films location as well.
            We take a break to have lunch in Ait ben Haddou Site, we continue our
            journey crossing the Mountains of Anti-atlas and Ourazazate site Or the
            Hollywood of Africa. Arriving to Agdz, which is a small town located
            among palmtree groves, you spend the overnight in one of well-selected
            accommadation with evening and morning meals included.
4

1 回答 1

0

您没有展示如何使用 YAML,但很可能您只是将 YAML 数据粘贴到 HTML 中,这显然会导致一个段落(HTML 不会像 LaTeX 或 Markdown 那样用空行分割段落,您需要使用<p>标签)。

我不特别了解中间人,但是对于大多数静态站点生成器,您希望在 YAML 中拥有具有内部结构(如段落)的数据——相反,您希望使用生成器为您提供的任何标记/模板语言(ERB 似乎是中间人的默认设置;它似乎也支持 Markdown,这是一种将文本转换为适当 HTML 段落的方法)。

如果您真的希望数据是 YAML,则需要将数据的结构(在这种情况下为段落)映射到 YAML 结构,除非您想插入一个解析器来处理您的数据,然后再将其转储到生成的 HTML 中(不确定这是否是可能的)。一种方法是将您的数据定义为 YAML 序列:

- paragraph 1
  foo bar
- Lorem ipsum
  dolor sit amet

等等。然后,您需要遍历序列并<p>...<p/>在从中生成 HTML 时将每个项目包装到其中。

于 2019-03-19T11:15:21.983 回答