我试图找出最简洁的方法,使用斜体和粗体字体风格,主要是英语散文页。
唯一的依赖:
import scalatags.Text.all._这是第一个版本:
p(id:="with-italics-verbose")("""
Earlier sentence in paragraph.
This is a sentence with
""",
i("very"),
"""
important words, so
""",
b("pay attention."),
"""
Later sentence in same paragraph.
"""
)中断多行字符串,删除一个单独的元素,然后只为几个特殊的单词启动一个新的多行字符串,这真的很麻烦,因此编辑起来很痛苦。
这是第二个版本,使用原始函数和字符串插值的组合:
p(id:="with-italics-raw-interpolate")(raw(s"""
Earlier sentence in paragraph.
This is a sentence with ${i("very")}, important words, so ${b("pay attention")}.
Later sentence in same paragraph.
"""
))这是我所希望的使用ScalaTags的最好方式吗?使用最新的0.6.0版本。
发布于 2016-08-05 03:52:18
如果您真的想要换行,可以手动添加br()标记。但是,在大多数情况下,您可能不希望在原始代码中指定换行符,如果是,则应该使用p()标记。
否则,三元引号不需要它们自己的行,所以您可以使用以下内容运行
div(
"""
This is the first sentence.
The second sentence is """, i("quite"), """ fancy.
This is the third sentence.
"""
)发布于 2017-01-13 13:18:16
我在服务器上就是这样做的:
import scalatags.Text.all._
div(
h1("Welcome to Scala.js"),
p("The ", b("server"), " added this. Time to relax ☕")
)若要在客户端上执行相同操作,请使用import scalatags.JsDom.all._
https://stackoverflow.com/questions/38779699
复制相似问题