diff options
author | Kato Kazuyoshi <kato.kazuyoshi@gmail.com> | 2013-03-20 00:55:06 +0900 |
---|---|---|
committer | Kato Kazuyoshi <kato.kazuyoshi@gmail.com> | 2013-03-25 20:56:31 +0900 |
commit | b4344e121c7e195f5244cd704d5296274d503dd1 (patch) | |
tree | b465b3e2bc621b8136960dcd7591d7d961f08c53 /src/compiler | |
parent | fcc22e22248992abffe2506ddef7c0f7c0b23044 (diff) | |
download | scala-b4344e121c7e195f5244cd704d5296274d503dd1.tar.gz scala-b4344e121c7e195f5244cd704d5296274d503dd1.tar.bz2 scala-b4344e121c7e195f5244cd704d5296274d503dd1.zip |
SI-6580 Scaladoc: Should not close void elements
Because it will generate a useless element like "</img>".
To made matters worse, Scaladoc used to generate the element with
attributes (like </img src="...">). That's why we had SI-6580.
Diffstat (limited to 'src/compiler')
-rwxr-xr-x | src/compiler/scala/tools/nsc/doc/base/comment/Body.scala | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/base/comment/Body.scala b/src/compiler/scala/tools/nsc/doc/base/comment/Body.scala index 02e662da85..eb0d751f3e 100755 --- a/src/compiler/scala/tools/nsc/doc/base/comment/Body.scala +++ b/src/compiler/scala/tools/nsc/doc/base/comment/Body.scala @@ -75,16 +75,20 @@ object EntityLink { def unapply(el: EntityLink): Option[(Inline, LinkTo)] = Some((el.title, el.link)) } final case class HtmlTag(data: String) extends Inline { - def canClose(open: HtmlTag) = { - open.data.stripPrefix("<") == data.stripPrefix("</") + private val Pattern = """(?ms)\A<(/?)(.*?)[\s>].*\z""".r + private val (isEnd, tagName) = data match { + case Pattern(s1, s2) => + (! s1.isEmpty, Some(s2.toLowerCase)) + case _ => + (false, None) } - def close = { - if (data.indexOf("</") == -1) - Some(HtmlTag("</" + data.stripPrefix("<"))) - else - None + def canClose(open: HtmlTag) = { + isEnd && tagName == open.tagName } + + private val TagsNotToClose = Set("br", "img") + def close = tagName collect { case name if !TagsNotToClose(name) => HtmlTag(s"</$name>") } } /** The summary of a comment, usually its first sentence. There must be exactly one summary per body. */ |