summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKato Kazuyoshi <kato.kazuyoshi@gmail.com>2011-03-25 22:55:19 +0000
committerKato Kazuyoshi <kato.kazuyoshi@gmail.com>2011-03-25 22:55:19 +0000
commitc402bdde2ecdbc1f63e90a603263e722ffee7202 (patch)
tree46caa318ca3ad4e9343de3beabd0dfa02dc245d7 /src
parent22d1ae7fa498df9ca80a686ca28ce5f816b6f945 (diff)
downloadscala-c402bdde2ecdbc1f63e90a603263e722ffee7202.tar.gz
scala-c402bdde2ecdbc1f63e90a603263e722ffee7202.tar.bz2
scala-c402bdde2ecdbc1f63e90a603263e722ffee7202.zip
[scaladoc] Stop wiki syntax parsing inside HTML.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala
index 7485533641..02fadb94fd 100644
--- a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala
@@ -172,7 +172,7 @@ trait CommentFactory { thisFactory: ModelFactory with CommentFactory =>
/** Safe HTML tags that can be kept. */
protected val SafeTags =
- new Regex("""((&\w+;)|(&#\d+;)|(<code( [^>]*)?>.*?</code>)|(</?(abbr|acronym|address|area|a|bdo|big|blockquote|br|button|b|caption|cite|col|colgroup|dd|del|dfn|em|fieldset|form|hr|img|input|ins|i|kbd|label|legend|link|map|object|optgroup|option|param|pre|q|samp|select|small|span|strong|sub|sup|table|tbody|td|textarea|tfoot|th|thead|tr|tt|var)( [^>]*)?/?>))""")
+ new Regex("""((&\w+;)|(&#\d+;)|(</?(abbr|acronym|address|area|a|bdo|big|blockquote|br|button|b|caption|cite|code|col|colgroup|dd|del|dfn|em|fieldset|form|hr|img|input|ins|i|kbd|label|legend|link|map|object|optgroup|option|param|pre|q|samp|select|small|span|strong|sub|sup|table|tbody|td|textarea|tfoot|th|thead|tr|tt|var)( [^>]*)?/?>))""")
protected val safeTagMarker = '\u000E'
@@ -515,10 +515,50 @@ trait CommentFactory { thisFactory: ModelFactory with CommentFactory =>
/* INLINES */
+ val OPEN_TAG = "^<([A-Za-z]+)( [^>]*)?(/?)>$".r
+ val CLOSE_TAG = "^</([A-Za-z]+)>$".r
+ private def readHTMLFrom(begin: HtmlTag): String = {
+ val list = mutable.ListBuffer.empty[String]
+ val stack = mutable.ListBuffer.empty[String]
+
+ begin.close match {
+ case Some(HtmlTag(CLOSE_TAG(s))) =>
+ stack += s
+ case _ =>
+ return ""
+ }
+
+ do {
+ readUntil { char == safeTagMarker || char == endOfText }
+ val str = getRead()
+ nextChar()
+
+ list += str
+
+ str match {
+ case OPEN_TAG(s, _, standalone) => {
+ if (standalone != "/") {
+ stack += s
+ }
+ }
+ case CLOSE_TAG(s) => {
+ if (s == stack.last) {
+ stack.remove(stack.length-1)
+ }
+ }
+ case _ => ;
+ }
+ } while (stack.length > 0 && char != endOfText);
+
+ return list.mkString("")
+ }
def inline(isInlineEnd: => Boolean): Inline = {
def inline0(): Inline = {
- if (char == safeTagMarker) htmlTag()
+ if (char == safeTagMarker) {
+ val tag = htmlTag()
+ HtmlTag(tag.data + readHTMLFrom(tag))
+ }
else if (check("'''")) bold()
else if (check("''")) italic()
else if (check("`")) monospace()
@@ -563,7 +603,7 @@ trait CommentFactory { thisFactory: ModelFactory with CommentFactory =>
}
- def htmlTag(): Inline = {
+ def htmlTag(): HtmlTag = {
jump(safeTagMarker)
readUntil(safeTagMarker)
if (char != endOfText) jump(safeTagMarker)