Skip to content

Commit

Permalink
moved Pattern and TagsNotToClose to a HtmlTag companion object
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippus committed Feb 21, 2017
1 parent a019082 commit b8a8ac1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/scaladoc/scala/tools/nsc/doc/base/comment/Body.scala
Expand Up @@ -73,9 +73,8 @@ object EntityLink {
def unapply(el: EntityLink): Option[(Inline, LinkTo)] = Some((el.title, el.link))
}
final case class HtmlTag(data: String) extends Inline {
private val Pattern = """(?ms)\A<(/?)(.*?)[\s>].*\z""".r
private val (isEnd, tagName) = data match {
case Pattern(s1, s2) =>
case HtmlTag.Pattern(s1, s2) =>
(! s1.isEmpty, Some(s2.toLowerCase))
case _ =>
(false, None)
Expand All @@ -85,11 +84,14 @@ final case class HtmlTag(data: String) extends Inline {
isEnd && tagName == open.tagName
}

private val TagsNotToClose = Set("br", "img")
def close = tagName collect {
case name if !TagsNotToClose(name) && !data.endsWith(s"</$name>") => HtmlTag(s"</$name>")
case name if !HtmlTag.TagsNotToClose(name) && !data.endsWith(s"</$name>") => HtmlTag(s"</$name>")
}
}
object HtmlTag {
private val Pattern = """(?ms)\A<(/?)(.*?)[\s>].*\z""".r
private val TagsNotToClose = Set("br", "img")
}

/** The summary of a comment, usually its first sentence. There must be exactly one summary per body. */
final case class Summary(text: Inline) extends Inline

0 comments on commit b8a8ac1

Please sign in to comment.