Permalink
Browse files

Checking in a few more things done on the train while a crazy little …

…girl drove me nuts because I was hung over from Oktoberfest.
  • Loading branch information...
Tristan Juricek
Tristan Juricek committed Oct 5, 2009
1 parent e117835 commit dd61625265bc2b5eed253f19d8efba1d02d41280
@@ -160,7 +160,18 @@ Otherwise the paragraph is a simple `Block` type (does not contain other
def markdown = span.toMarkdown
- def xml = <p>{ span.toXML }</p>
+ /**
+ If this paragraph only contains HTMLSpan elements, then just pass that
+ information through without a paragraph marker.
+ */
+ def xml =
+ if ( isHTML ) span.toXML else <p>{ span.toXML }</p>
+
+ def isHTML : Boolean = ! span.exists( s => s match {
+ case html : HTMLSpan => false
+ case t:Text => ! t.content.trim.isEmpty
+ case _ => true
+ } )
// See the Paragraph toString, equals, hashCode implementations
}
@@ -268,26 +279,6 @@ A block quote is really another markdown document, quoted.
}
-## `HTMLBlock` ##
-
-We consider this to be already formatted HTML. The content here is specificed as a
-string - everything else is just basically passed directly back.
-
- // In knockoff2/HTMLBlock.scala
- // See the HTMLBlock package and imports
-
- class HTMLBlock( val html : String, val position : Position )
- extends SimpleBlock {
-
- val span = new HTMLSpan( html )
-
- def xml : Node = Unparsed( html )
-
- def markdown = html
-
- // See the HTMLBlock toString, equals, hashCode implementations
- }
-
## `CodeBlock` ##
The code block is a chunk of preformatted text to this system. Note that this means
@@ -725,34 +716,6 @@ entire content; whitespace will be missing in complex cases.
)
}
-### `HTMLBlock`
-
-#### `HTMLBlock` - Package and Imports
-
- // The HTMLBlock package and imports
- package knockoff2
-
- import scala.xml.{ Node, Unparsed }
- import scala.util.parsing.input.Position
-
-#### `HTMLBlock` - `toString`, `equals`, `hashCode`
-
- // The HTMLBlock toString, equals, hashCode implementations
- override def toString = "HTMLBlock(" + html + ")"
-
- override def hashCode : Int = html.hashCode
-
- override def equals( rhs : Any ) : Boolean = rhs match {
- case t : HTMLBlock => t.canEqual( this ) && ( this sameElements t )
- case _ => false
- }
-
- def sameElements( h : HTMLBlock ) : Boolean = {
- ( h.html == html ) &&
- ( h.position == position )
- }
-
- def canEqual( t : HTMLBlock ) : Boolean = t.getClass == getClass
### `CodeBlock`
@@ -65,9 +65,6 @@ customizing the `ElementFactory` is pretty simple. You create a subtype of
def blockquote( c : BlockSeq, p : Position ) : Blockquote =
new Blockquote( c, p )
- def htmlBlock( h : String, p : Position ) : HTMLBlock =
- new HTMLBlock( h, p )
-
def codeBlock( s : String, p : Position ) : CodeBlock =
codeBlock( text(s), p )
@@ -22,9 +22,6 @@ class ElementFactory {
def blockquote( c : BlockSeq, p : Position ) : Blockquote =
new Blockquote( c, p )
- def htmlBlock( h : String, p : Position ) : HTMLBlock =
- new HTMLBlock( h, p )
-
def codeBlock( s : String, p : Position ) : CodeBlock =
codeBlock( text(s), p )
@@ -1,30 +0,0 @@
-package knockoff2
-
-import scala.xml.{ Node, Unparsed }
-import scala.util.parsing.input.Position
-
-class HTMLBlock( val html : String, val position : Position )
-extends SimpleBlock {
-
- val span = new HTMLSpan( html )
-
- def xml : Node = Unparsed( html )
-
- def markdown = html
-
- override def toString = "HTMLBlock(" + html + ")"
-
- override def hashCode : Int = html.hashCode
-
- override def equals( rhs : Any ) : Boolean = rhs match {
- case t : HTMLBlock => t.canEqual( this ) && ( this sameElements t )
- case _ => false
- }
-
- def sameElements( h : HTMLBlock ) : Boolean = {
- ( h.html == html ) &&
- ( h.position == position )
- }
-
- def canEqual( t : HTMLBlock ) : Boolean = t.getClass == getClass
-}
@@ -11,7 +11,18 @@ extends SimpleBlock {
def markdown = span.toMarkdown
- def xml = <p>{ span.toXML }</p>
+ /**
+ If this paragraph only contains HTMLSpan elements, then just pass that
+ information through without a paragraph marker.
+ */
+ def xml =
+ if ( isHTML ) span.toXML else <p>{ span.toXML }</p>
+
+ def isHTML : Boolean = ! span.exists( s => s match {
+ case html : HTMLSpan => false
+ case t:Text => ! t.content.trim.isEmpty
+ case _ => true
+ } )
override def toString = "Paragraph(" + markdown + ")"
@@ -1,7 +1,7 @@
Subject: Things I have To Do
-* Arg, an empty line between two code blocks is significant: should become an empty
- line in the code.
+* HTML pass-through is missing comment support, and for some reason, the <hr>'s are
+ also messed up.
* Fix the smaller markdown tests.
* Why are things being evaluated twice?

0 comments on commit dd61625

Please sign in to comment.