Skip to content

Commit

Permalink
Changed null to Null. Closes #94
Browse files Browse the repository at this point in the history
  • Loading branch information
dpp committed Oct 13, 2009
1 parent ac8706d commit 511e198
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 118 deletions.
105 changes: 9 additions & 96 deletions lift-textile/src/main/scala/net/liftweb/textile/TextileParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,6 @@ object TextileParser {
* @author Martin Odersky
*/
private case class MyOffsetPosition(source: _root_.java.lang.CharSequence, offset: Int, index: Array[Int]) extends Position {

/* /** An index that contains all line starts, including first line, and eof */
private lazy val index: Array[Int] = {
var lineStarts = new ArrayBuffer[Int]
lineStarts += 0
for (i <- 0 until source.length)
if (source.charAt(i) == '\n') lineStarts += (i + 1)
lineStarts += source.length
lineStarts.toArray
}
*/

/** The line number referred to by the position; line numbers start at 1 */
lazy val line: Int = {
var lo = 0
Expand Down Expand Up @@ -239,10 +227,10 @@ object TextileParser {

def peek[T](p: Parser[T]): Parser[T] = Parser { in =>
p(in) match {
case s @ Success(v, _) => Success(v, in)
case e @ Error(msg, _) => Error(msg, in)
case f @ Failure(msg, _) => Failure(msg, in)
}
case s @ Success(v, _) => Success(v, in)
case e @ Error(msg, _) => Error(msg, in)
case f @ Failure(msg, _) => Failure(msg, in)
}
}

lazy val document : Parser[Lst] = rep(paragraph) ^^ Lst
Expand Down Expand Up @@ -596,26 +584,11 @@ object TextileParser {
new ~(t2, Nil)

}
/*
new ~(List[Textile](CharBlock(" " * bg)),
new ~(new ~(reduceCharBlocks(ln), attrs),
List(CharBlock(" " * end))))}
*/

/*
lazy val spaceOrStart: UnitParser = beginl | accept(' ')
lazy val spaceOrEnd: UnitParser = accept(' ') | discard(endOfLine)
*/

// TODO: generalize formattedLineElem some more
lazy val bold: Parser[Textile] =
formattedLineElem(accept("**")) ^^ flatten4(Special * "b")
/*
(accept("**") ~> rep(attribute)) ~
(rep1(not(discard(accept("**") |
endOfLine)) ~>
lineElem_notStrong) <~ accept("**")) ^^ {
case attrs ~ ln => Bold(reduceCharBlocks(ln), attrs) }
*/

lazy val strong: Parser[Textile] = formattedLineElem('*') ^^ flatten4(Strong)

Expand Down Expand Up @@ -846,8 +819,6 @@ object TextileParser {
}
}



case class StyleElem(name : String, value : String) extends Textile {
def toHtml = null
override def toString = name+":"+value
Expand Down Expand Up @@ -886,20 +857,7 @@ object TextileParser {
override def toHtml : NodeSeq = super.toHtml ++ Text("\n")
}

case class Lst(elems : List[Textile]) extends ATextile(elems, Nil) {
/*
def performOnWikiAnchor(f : (WikiAnchor) => Any) : Unit = {
def findWikiAnchor(in : List[Textile], f : (WikiAnchor) => Any) : Unit = {
in match {
case (s : WikiAnchor) :: rest => {f(s) ; findWikiAnchor(rest, f)}
case (s : ATextile) :: rest => {findWikiAnchor(s.theElems, f); findWikiAnchor(rest, f)}
case x :: rest => {findWikiAnchor(rest, f)}
case _ => Nil
}
}
findWikiAnchor(List(this), f)
}*/
}
case class Lst(elems : List[Textile]) extends ATextile(elems, Nil)

// drop the last EOL to prevent needless <br />
// TODO: find a better solution.. it's not quite clear to me where newlines are meaningful
Expand Down Expand Up @@ -950,10 +908,6 @@ object TextileParser {
def toHtml : NodeSeq = Text(" "+8212.toChar+" ")
}

/* case class BOL extends Textile {
def toHtml : NodeSeq = Text("")
}*/

case object EOL extends Textile {
// return the characters because Scala's XML library returns <br></br> in the
// toString for the element and this causes 2 line breaks in some browsers
Expand Down Expand Up @@ -995,7 +949,7 @@ object TextileParser {

case class BlockQuote(elems : List[Textile], attrs : List[Attribute]) extends ATextile(elems, attrs) {
override def toHtml : NodeSeq = {
val par : NodeSeq = XmlElem(null, "p", null, TopScope, flattenAndDropLastEOL(elems) : _*) ++ Text("\n")
val par : NodeSeq = XmlElem(null, "p", Null, TopScope, flattenAndDropLastEOL(elems) : _*) ++ Text("\n")
XmlElem(null, "blockquote", fromStyle(attrs), TopScope, par : _*) ++ Text("\n")
}
}
Expand Down Expand Up @@ -1023,7 +977,7 @@ object TextileParser {
case class Footnote(elems : List[Textile], attrs : List[Attribute], num : String) extends ATextile(elems, attrs) {
override def toHtml : NodeSeq = {
XmlElem(null, "p", fromStyle(AnyAttribute("id", "fn"+num) :: attrs), TopScope,
(XmlElem(null, "sup", null, TopScope, Text(num) : _*) :: flattenAndDropLastEOL(elems)) : _*) ++ Text("\n")
(XmlElem(null, "sup", Null, TopScope, Text(num) : _*) :: flattenAndDropLastEOL(elems)) : _*) ++ Text("\n")
}
}

Expand Down Expand Up @@ -1095,13 +1049,6 @@ object TextileParser {
flattenAndDropLastEOL(last)
}
}
/*
case class Bold(elems : List[Textile], attrs : List[Attribute]) extends ATextile(elems, attrs) {
override def toHtml : NodeSeq = {
XmlElem(null, "b", fromStyle(attrs), TopScope, flattenAndDropLastEOL(elems) : _*)
}
}*/


case class Cite(first: List[Textile], elems : List[Textile],
attrs : List[Attribute], last:List[Textile]) extends ATextile(elems, attrs){
Expand All @@ -1111,38 +1058,10 @@ object TextileParser {
flattenAndDropLastEOL(last)

}
/*
case class Code(elems : List[Textile], attrs : List[Attribute]) extends ATextile(elems, attrs) {
override def toHtml : NodeSeq = XmlElem(null, "code", fromStyle(attrs), TopScope, flattenAndDropLastEOL(elems) : _*)
}*/
/*
case class Delete(elems : List[Textile], attrs : List[Attribute]) extends ATextile(elems, attrs) {
override def toHtml : NodeSeq = XmlElem(null, "del", fromStyle(attrs), TopScope, flattenAndDropLastEOL(elems) : _*)
}
*/
/*
case class Ins(elems : List[Textile], attrs : List[Attribute]) extends ATextile(elems, attrs) {
override def toHtml : NodeSeq = XmlElem(null, "ins", fromStyle(attrs), TopScope, flattenAndDropLastEOL(elems) : _*)
}
*/
/*
case class Super(elems : List[Textile], attrs : List[Attribute]) extends ATextile(elems, attrs) {
override def toHtml : NodeSeq = XmlElem(null, "sup", fromStyle(attrs), TopScope, flattenAndDropLastEOL(elems) : _*)
}
*/
/*
case class Sub(elems : List[Textile], attrs : List[Attribute]) extends ATextile(elems, attrs) {
override def toHtml : NodeSeq = XmlElem(null, "sub", fromStyle(attrs), TopScope, flattenAndDropLastEOL(elems) : _*)
}
*/

case class Pre(elems : List[Textile], attrs : List[Attribute]) extends ATextile(elems, attrs) {
override def toHtml : NodeSeq = XmlElem(null, "pre", fromStyle(attrs), TopScope, flattenAndDropLastEOL(elems) : _*) ++ Text("\n")
}
/*
case class Span(elems : List[Textile], attrs : List[Attribute]) extends ATextile(elems, attrs) {
override def toHtml : NodeSeq = XmlElem(null, "span", fromStyle(attrs), TopScope, flattenAndDropLastEOL(elems) : _*)
}*/


case class Anchor(elems : List[Textile], href : String, alt : String, attrs : List[Attribute], disableLinks: Boolean) extends ATextile(elems, attrs) {
def allAttrs = AnyAttribute("href", href) :: attrs
Expand Down Expand Up @@ -1188,12 +1107,6 @@ object TextileParser {

// wikiFunc.map(ignore => Elem(null, "a", fromStyle(allAttrs), TopScope, Text(alt) : _*)) getOrElse Text(alt)
}
/*
case class WikiAnchor(elems: List[Textile], href: String, alt: String, attrs: List[Attribute], wikiFunc: Option[RewriteFunc]) extends ATextile(elems, attrs) {
// var rootUrl = ""
def allAttrs = wikiFunc.map(wf => AnyAttribute("href", wf(href)) :: attrs) getOrElse attrs
override def toHtml: NodeSeq = wikiFunc.map(ignore => XmlElem(null, "a", fromStyle(allAttrs), TopScope, Text(alt) : _*)) getOrElse Text(alt)
}*/

val example =
"""I am <em>very</em> serious
Expand Down
50 changes: 28 additions & 22 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,30 @@
<author></author>
</properties>
<body>
<!-- mini guide
<action
dev="Name of developer who committed the change"
type="add|fix|remove|update"
issue="(optional) Id of the issue related to this change"
due-to="(optional)Name of the person 'non-committer' to be credited for this change"
>
description
</action>
see http://maven.apache.org/plugins/maven-changes-plugin/usage.html for full guide
-->
<!-- mini guide
<action
dev="Name of developer who committed the change"
type="add|fix|remove|update"
issue="(optional) Id of the issue related to this change"
due-to="(optional)Name of the person 'non-committer' to be credited for this change"
>
description
</action>
see http://maven.apache.org/plugins/maven-changes-plugin/usage.html for full guide
-->

<release version="1.1-SNAPSHOT" date="" description="">
<action dev="Alex Boisvert" type="update">Issue 57: Improve error message if database is not supported</action>
<action dev="Alex Boisvert" type="update">Issue 77: Change net.liftweb.mapper.ByList to take a Seq[T] instead of a List[T]</action>
<action dev="Timothy Perrett" type="update">Issue 88: Boxed payment status so that IPN cancelations appear as Empty. Breaking API change for implementors.</action>
</release>
<release version="1.1-M6" date="2009-09-08" description="Lift 1.1 Milestone 6"/>
<action dev="dpp" type="fix" issue="94" due-to="vdichev">
Textile parser outputs non-valid output. Changed some null to Null.
</action>
</release>
<release version="1.1-M6" date="2009-10-08" description="Lift 1.1 Milestone 6"/>
>>>>>>> Changed null to Null. Closes #94:src/changes/changes.xml
<release version="1.1-M5" date="2009-09-08" description="Lift 1.1 Milestone 5"/>
<release version="1.1-M4" date="2009-08-04" description="Lift 1.1 Milestone 4">
<action dev="Marius Danciu" type="add">Added HTTP abstraction for making Lift container agnostic.</action>
Expand Down Expand Up @@ -131,10 +137,10 @@
Added Cookie support.
</action>
<action dev="Steve Jenson" type="update">
Updating our version of jQuery to 1.2.3.
Updating our version of jQuery to 1.2.3.
</action>
<action dev="Steve Jenson" type="add">
Added a new method to MetaMapper that lets you find models by PreparedStatement. findByPreparedStatement
Added a new method to MetaMapper that lets you find models by PreparedStatement. findByPreparedStatement
</action>
</release>
<release version="0.5" date="2008-02-05" description="">
Expand All @@ -146,18 +152,18 @@
<action dev="David Pollak" type="add">Added JSON support including: - S.buildJSONFunc - JSONHandler class - Lots of fancy JavaScript expression building</action>
<action dev="David Pollak" type="update">When lift is running in test mode, the default form generators will insert lift:field_name attribute into the form fields to aid in testing</action>
<action dev="David Pollak" type="update">
Added json2.js (and minified version)
Enhanced the resource serving stuff so that:
- The path is defined in LiftServlet and changable (defaults to "classpath")
- Moved the resource location from the root to "toserve" (can be changed) to avoid any possible way of serving up classes
- The white list is a Partial Function for more flexibility
- The white list by default contains jquery.js and json.js
- There's a re-writer to re-write the request into an actual file (so jquery.js gets re-written to jquery-1.2.2-min.js)
</action>
Added json2.js (and minified version)
Enhanced the resource serving stuff so that:
- The path is defined in LiftServlet and changable (defaults to "classpath")
- Moved the resource location from the root to "toserve" (can be changed) to avoid any possible way of serving up classes
- The white list is a Partial Function for more flexibility
- The white list by default contains jquery.js and json.js
- There's a re-writer to re-write the request into an actual file (so jquery.js gets re-written to jquery-1.2.2-min.js)
</action>
<action dev="David Pollak" type="add">Parser Combinator Helper routines</action>
<action dev="David Pollak" type="update">MappedField.toForm now returns a Can[NodeSeq] so a field can be omitted from a form</action>
<action dev="David Pollak" type="add">Added the "record" and "record_mgt" packages with half-baked record and field stuff in them
</action>
</action>
<action dev="David Pollak" type="update">Added LocInfo and LocInfoVal to SiteMap for storing CSS and other tidbits about each menu item </action>
<action dev="David Pollak" type="update">Fixed the 'Welcome to the your project' type-o</action>
<action dev="David Pollak" type="update">Further abstracted the whole logging thing. There's a default log4j setup that can be overriden. The LiftLogger trait is made concrete in Log4JLogger, but the generic LiftLogger creation is done by function that can be modified in LogBoot: var loggerByName: String => LiftLogger = _logger; var loggerByClass: Class => LiftLogger = _loggerCls; One can insert a new logging system into lift by replacing the loggerByName and loggerByClass functions with appropriate functions that return a LiftLogger.</action>
Expand Down

0 comments on commit 511e198

Please sign in to comment.