esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vdic...@apache.org
Subject svn commit: r884547 - in /incubator/esme/trunk/server/src/main/scala/org/apache/esme: lib/MsgParser.scala model/Message.scala
Date Thu, 26 Nov 2009 13:13:41 GMT
Author: vdichev
Date: Thu Nov 26 13:13:41 2009
New Revision: 884547

URL: http://svn.apache.org/viewvc?rev=884547&view=rev
Log:
Replaced Textile formatter with native parser

Modified:
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala?rev=884547&r1=884546&r2=884547&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala Thu Nov
26 13:13:41 2009
@@ -55,7 +55,7 @@
   }
 
   lazy val begin: Parser[List[MsgInfo]] = 
-  startSpace ~> rep1(url | atName | hashTag | text) <~ spaceEOF
+  startSpace ~> rep1(url | atName | hashTag | emph | strong | text) <~ spaceEOF
 
   lazy val startSpace = rep(' ')
 
@@ -222,11 +222,21 @@
 
   lazy val spaceEOF = rep(' ') ~ EOF
 
-  lazy val text: Parser[MsgText] = rep1(not(spaceEOF) ~ not(url) ~ not(atName) ~
-                                        not(hashTag) ~> anyChar) ^^ {
+  lazy val text: Parser[MsgText] =
+    rep1(not(spaceEOF) ~ not(url) ~ not(atName) ~ not(hashTag) ~ not(emph) ~ not(strong)
~>
+      anyChar) ^^ {
     case xs => MsgText(xs.mkString(""))
   }
 
+  lazy val emph: Parser[Emph] = '_' ~> rep1(not(spaceEOF) ~ not('_') ~ not(hashTag) ~
not(atName) ~> anyChar) <~ '_' ^^ {
+    case xs => Emph(xs.mkString)
+  }
+  
+  lazy val strong: Parser[Strong] = 
+  '*' ~> rep1(not(spaceEOF) ~ not('*') ~ not(hashTag) ~ not(atName) ~> anyChar) <~
'*' ^^ {
+    case xs => Strong(xs.mkString)
+  }
+  
   lazy val EOF: Parser[Elem] = elem("EOF", isEof _)
 
   def perform(in: String): Box[Performances] = _perform(in) match {
@@ -433,6 +443,10 @@
 case class AtName(user: User) extends MsgInfo
 case class HashTag(tag: Tag) extends MsgInfo
 case class URL(url: UrlStore) extends MsgInfo
+case class Emph(text: String) extends MsgInfo
+case class Strong(text: String) extends MsgInfo
 
 case class ResenderName(user: User)
 case class PoolName(pool: AccessPool)
+
+

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala?rev=884547&r1=884546&r2=884547&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala Thu Nov
26 13:13:41 2009
@@ -28,7 +28,6 @@
 import http.js._
 import Helpers._
 import java.util.logging._
-import textile.TextileParser
 
 import scala.xml._
 
@@ -322,10 +321,6 @@
               <xml:group> <a href={"/u/"+id}>{url}</a> </xml:group>)).
           getOrElse(Text("") )
 
-        case t: Text => <xml:group> { TextileParser.toHtml(t.toString()).flatMap
{ e =>
-          if (e.label == "p") e.child else e
-        }} </xml:group>
-
         case x => x
       })
   }
@@ -413,6 +408,8 @@
               case MsgText(text) => Text(text)
               case URL(url) => <url id={url.id.toString}
                   url={url.url.toString} uniqueId={url.uniqueId.is} >{url.url.toString}</url>
+              case Emph(text) => <em>{text}</em>
+              case Strong(text) => <strong>{text}</strong>
             }
           }</body>
         <tags>{



Mime
View raw message