我如何让YAML忽略同一文件中的原始HTML [英] How can I get YAML to ignore raw HTML in same file

查看:111
本文介绍了我如何让YAML忽略同一文件中的原始HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图制作一个使用YAML将条目转换为代码的平面文件PHP博客,但我无法找到如何让YAML忽略HTML标签以及第二个---之后的所有内容:

  --- 
title =文章标题
tags =tag1 tag2 tag3
someInportentVariable =一些Inportent内容
---

这是一些条目内容。< / p>
< p> Line2。< / p>
< p> Line3。< / p>
< p>等等...< / p>

如何才能做到这一点?

<这里是我的意思的例子: https://github.com/claco/claco.github.com/blob/master/_posts/2002-10-05-marry-a-sysadmin.textile 。 p>

更新:对于想与我联系的人,请转到我的新的计算器帐户 RobinLilfelt

解决方案

您可能想要做的是对待HTML为引用的标量文字。您可以通过使用 --- | 开始HTML部分并缩进所有行来完成此操作。



例如:

  --- 
title =条目标题
tags =tag1 tag2 tag3
someInportentVariable =一些Inportent内容
postBody:|
< p>这是一些条目内容。< / p>
< p> Line2。< / p>
< p> Line3。< / p>
< p>等等...< / p>


I am trying to make a flatfile PHP blog that uses YAML to convert the entries to code, but I can't find out how to get YAML to ignore the HTML tags and everything after the second "---":

---
title = "Entry title"
tags = "tag1 tag2 tag3"
someInportentVariable = "Some Inportent Content"
---

<p>This is some entry content.</p>
<p>Line2.</p>
<p>Line3.</p>
<p>And so on...</p>

How can I be able do that?

Here's a example of what I mean: https://github.com/claco/claco.github.com/blob/master/_posts/2002-10-05-marry-a-sysadmin.textile.

Update: For people who wants to contact me, head over to my new stackoverflow account, RobinLilfelt.

解决方案

What you probably want to do is treat the HTML as a quoted scalar literal. You do this by starting the HTML section with --- | and indenting all of the lines.

e.g.:

---
title = "Entry title"
tags = "tag1 tag2 tag3"
someInportentVariable = "Some Inportent Content"
postBody: |
  <p>This is some entry content.</p>
  <p>Line2.</p>
  <p>Line3.</p>
  <p>And so on...</p>

这篇关于我如何让YAML忽略同一文件中的原始HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆