翡翠中的断线怎么样?
我很确定这是显而易见的,但我没有找到任何示例代码片段。 插入换行符的最佳方法是什么(又名“好的 ol' br/”)?
据我所知,如果我在空行的开头放置一个“br”,它会呈现为
但如果我必须显示几行文本,则生成的代码非常冗长:
.poem
p
| Si chiamava Tatiana, la sorella…
br
| Noi siamo i primi, almeno lo crediamo
br
| Che un tale nome arditamente nella
br
| Cornice d’un romanzo introduciamo.
br
| E che dunque? E’ piacevole, sonoro.
br
| Lo so che a molti privo di decoro
br
| Apparirà, già fuori moda, e degno
br
| Piuttosto d’un ancella, certo segno,
br
| confessiamolo pur senza paura,
br
| di quanto s’è noialtri al gusto avversi
br
| nei nostri nomi (a non parlar di versi). |br
br
| Credemmo conquistare la cultura,
br
| e non ne abbiamo preso, in conclusione,
br
| che la ricerca dell’affettazione.
有更好的方法来解决这个问题吗? (顺便说一句,我对图像标签要求同样的事情......)
I'm pretty sure that this is a no-brainer but I didn't find any snippet of sample code.
What's the best way to insert line breaks (aka the good ol' br/)?
As far as I can see if I put a "br" at the beginning of an empty line, it is rendered as <br/>
but if I have to show several lines of text, the resulting code is quite verbose:
.poem
p
| Si chiamava Tatiana, la sorella…
br
| Noi siamo i primi, almeno lo crediamo
br
| Che un tale nome arditamente nella
br
| Cornice d’un romanzo introduciamo.
br
| E che dunque? E’ piacevole, sonoro.
br
| Lo so che a molti privo di decoro
br
| Apparirà, già fuori moda, e degno
br
| Piuttosto d’un ancella, certo segno,
br
| confessiamolo pur senza paura,
br
| di quanto s’è noialtri al gusto avversi
br
| nei nostri nomi (a non parlar di versi). |br
br
| Credemmo conquistare la cultura,
br
| e non ne abbiamo preso, in conclusione,
br
| che la ricerca dell’affettazione.
Is there a better way to solve this?
(incidentally I'm asking for the same thing with the image tag...)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
最干净、最简单的解决方案是使用样式属性
white-space: pre;
例如:The cleanest and easiest solution is to use the style attribute
white-space: pre;
eg:我想通了。只需在其中添加一个老式的
标签即可。你会很高兴:)更新:Jade 现在支持仅使用
br
进行换行。I figured it out. Just go ahead and throw a good ol' fashioned
<br />
tag in there. You'll be golden : )UPDATE: Jade now supports using just
br
for line breaks.这似乎不是一个答案,所以:
您还可以通过使用 Jade/Pug 的内联标记格式添加内联
br
标记来完成此操作,例如:Produces:
This doesn't seem to be an answer, so:
You can also do it by adding inline
br
tags using Jade/Pug's inline tag format, e.g.:Produces:
这样您就知道..如果您要提取此信息..例如从 SQL 数据库中手动输入换行符(例如在表单的文本区域中),您可以在服务器上执行以下操作你的输出
然后在jade中使用
!让 jade 知道您正在将原始 html 插入到您尝试渲染
源的变量中:https://github.com com/visionmedia/jade#tag-text
so that you're aware.. if you're pulling this information.. say from an SQL database where you've already manually entered in line breaks (say in a textarea of a form) you can do the following on the server to your output
and then in jade use
the ! lets jade know that you're inserting raw html into the variable you're trying to render out
source: https://github.com/visionmedia/jade#tag-text
稳健地每行一个 div:
或简单地使用 pre:
样式 pre.poem { font-family:ariel }
robustly with a div per line:
or simply with a pre:
style pre.poem { font-family:ariel }
我能够在@haxxxton之后执行以下操作
例如,可以使用函数
p!= contentParse(post.description)
在jade模板中使用它I was able to do the following after @haxxxton
For example, it can be used in a jade template using the function
p!= contentParse(post.description)
这也很有效。
this also works well.
为您的段落指定一种样式,以保留换行符并以点结束 p 行:
Give your paragraph a style to keep the newlines and end the p line with a dot:
我正在从 PUG 模板生成 SASS 文件
我需要将
每个
项目放在一个新行上。这对我有用:
I was generating a SASS file from PUG template
and I needed
each
item on a new line.This is what worked for me:
或者
or
以防万一您在第一次搜索时没有使用年份过滤器:
如何使用 Jade HTML 添加 br 标签
将文本放在前面带有 | 的新行:
Just in case you have not used the year filter on the first search:
How to add br tag with Jade HTML
Put the text on a new line with a preceding |:
试试这个:
Try this: