--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<opml version="1.0">
+ <head>
+ <title>BlackQuill</title>
+ <ownerName></ownerName>
+ </head>
+ <body>
+ <outline text="Manage BlackQuill implementation plan">
+ <outline text="<blockquote>">
+ <outline text="> Ahead Style">
+ <outline text="A line"></outline>
+ <outline text="Lines"></outline>
+ </outline>
+ </outline>
+ <outline text="<h1>-<h6>">
+ <outline text="Underline Style">
+ <outline text="2013/05/E">
+ <outline text="Done"></outline>
+ </outline>
+ </outline>
+ <outline text="# ahead Style">
+ <outline text="2013/05/E">
+ <outline text="Done"></outline>
+ </outline>
+ </outline>
+ <outline text="# Surrounded Style">
+ <outline text="2013/05/E">
+ <outline text="Done"></outline>
+ </outline>
+ </outline>
+ </outline>
+ <outline text="<i>">
+ <outline text="Surrounded by * Style">
+ <outline text="2013/05/E">
+ <outline text="Done"></outline>
+ </outline>
+ </outline>
+ </outline>
+ <outline text="<em>">
+ <outline text="Surrounded by ** Style">
+ <outline text="2013/05/E">
+ <outline text="Done"></outline>
+ </outline>
+ </outline>
+ </outline>
+ <outline text="<ul>">
+ <outline text="* Style">
+ <outline text="2013/05/E">
+ <outline text="Done"></outline>
+ </outline>
+ </outline>
+ <outline text="Convert to OPML"></outline>
+ </outline>
+ <outline text="<ol>">
+ <outline text="Numbered Style">
+ <outline text="2013/05/E">
+ <outline text="Done"></outline>
+ </outline>
+ </outline>
+ </outline>
+ </outline>
+ </body>
+</opml>
\ No newline at end of file
private val log:Log = LogFactory.getLog(classOf[BQParser])
private val Syntax = LinkedHashMap(
- "^(.*?)((\\s+\\d+?\\.\\s.+?\\\\,\\s*?)+)\\\\,\\s*?(.*?)$$" -> ("ol",surroundByListTAG _),
- "^(.*?)((\\s+[\\*|\\+|\\-]\\s.+?\\\\,\\s*?)+)\\\\,\\s*?(.*?)$$" -> ("ul",surroundByListTAG _),
- "^(.*?)\\*(.+?)\\*(.*?)$$" -> ("i",surroundByGeneralTAG _),
+ "^(.*?\\\\,)((>.*?\\\\,)+?)\\\\,(.*?)$$" -> ("blockquote",surroundByBlockquoteTAG _),
+ "^(.*?\\\\,)>(.*?)\\\\,\\\\,(.*?)$$" -> ("blockquote",surroundByGeneralTAG _),
+ "^(.*?)((\\s+\\d+?\\.\\s.+?\\\\,\\s*?)+?)(.*?)$$" -> ("ol",surroundByListTAG _),
+ "^(.*?)((\\s+(?:\\*|\\+|\\-)\\s.+?\\\\,\\s*?)+?)(.*?)$$" -> ("ul",surroundByListTAG _),
"^(.*?)\\*\\*(.+?)\\*\\*(.*?)$$" -> ("em",surroundByGeneralTAG _),
- "^(.*?)(#+)\\s(.+?)\\\\,(.*?)$$" -> ("h",surroundByHeadTAG _)
+ "^(.*?)\\*(.+?)\\*(.*?)$$" -> ("i",surroundByGeneralTAG _),
+ "^(.*\\\\,)(.*?)\\\\,(\\-+|=+)\\s*\\\\,(.*)$$" -> ("h",surroundByHeadTAGUnderlineStyle _),
+ "^(.*?)(#{1,6})\\s(.+?)(\\s#{1,6}?){0,1}\\\\,(.*?)$$" -> ("h",surroundByHeadTAG _)
//"^(.*?)(\\\\,.+?\\\\,)(.*?)$$" -> ("p",surroundByAbstructTAG _)
)
+
+ private def surroundByBlockquoteTAG(doc:String, regex:String, TAG:String):String = {
+ val p = new Regex(regex, "before","inTAG","midInTag","following")
+ val m = p findFirstMatchIn(doc)
+
+ var bef = ""
+ var fol = ""
+ var contentStr = ""
+ if(m != None){
+ val mid = m.get.group("inTAG")
+ log info "***-->" + mid
-/* private def ulStyles(index:Int):String = {
-
- }
+ if(m.get.group("before") != None){bef = m.get.group("before")}else{bef = ""}
+ if(m.get.group("following") != None){fol = m.get.group("following")}else{fol = ""}
+
+ log info "=>" + mid
+ if(mid != ""){
+ val mat = """(>(.+?\\,))+?""".r.findAllMatchIn(mid)
+
+ for(mt <- mat){
+ contentStr += mt.group(2)
+ log info "^^^" + mt
+ }
+ }
- private def olStyles(index:Int):String =
+ log info "-->" + contentStr
+ return surroundByBlockquoteTAG(bef, regex, TAG) +
+ "<blockquote>" + contentStr + "</blockquote>" + surroundByBlockquoteTAG(fol, regex, TAG)
+ }
+ doc
}
-*/
+
private def surroundByListTAG(doc:String, regex:String, TAG:String):String = {
val p = new Regex(regex, "before","elements","element","following")
val m = p findFirstMatchIn(doc)
var i = indent
var list = List.empty[Tuple3[String,Int,String]]
for(elem <- doc){
- val m = s"""((\\s+?)$sign\\s(.+?)\\\\,)""".r.findFirstMatchIn(elem)
+ val m = s"""((\\s+?)$sign\\s(.+?)\\,)""".r.findFirstMatchIn(elem)
list = (m.get.group(1),m.get.group(2).size,m.get.group(3))::list
}
tree.add(new TreeNode(s"</$sp>"*((i - indent)/indentWidth + 1)))
return tree
}
- val r = s"""^(\\s*)${sign}.*?$$""".r("firstSpace")
- val wS = r.findFirstMatchIn(s)
+ val r1 = s"""(\\s*)${sign}.*?\\,""".r
+ val wS1 = r1.findFirstMatchIn(s)
var str = ""
-
+ val r2 = s"""(\\s*)${sign}.*(\\\\,<br />.*?</blockquote>\\\\,)""".r
+ val wS2 = r2.findFirstMatchIn(s)
+ log debug "===>" + s
+
+ var wS:Option[Regex.Match] = null
+ if(wS2 != None){wS = wS2}else if(wS1 != None){wS = wS1}
if(wS != None){
- for(e <- _surroundByListTAG(docList.reverse,"li",wS.get.group("firstSpace").size)){
+ for(e <- _surroundByListTAG(docList.reverse,"li",wS.get.group(1).size)){
str += e.toString()
- }
+ }
+ if(wS == wS2){str += wS.get.group(2)}
+
+ log debug "---->" + str
surroundByListTAG(bef,regex,TAG) + str + surroundByListTAG(fol,regex,TAG)
}else{doc}
}
+ private def surroundByHeadTAGUnderlineStyle(doc:String, regex:String, TAG:String):String = {
+ if(doc == ""){return doc}
+
+ log debug "-->" + doc
+ val p = new Regex(regex, "before","inTAG","style","following")
+ val m = p findFirstMatchIn(doc)
+ var bef = ""
+ var fol = ""
+ var contentStr = ""
+ var headSign = TAG
+ if(m != None){
+ if(m.get.group("before") != None){bef = m.get.group("before")}else{bef = ""}
+ if(m.get.group("following") != None){fol = m.get.group("following")}else{fol = ""}
+ contentStr = m.get.group("inTAG")
+
+ if(m.get.group("style").contains("-")){
+ headSign += "2"
+ }else{
+ headSign += "1"
+ }
+
+ return surroundByHeadTAGUnderlineStyle(bef, regex, TAG) +
+ s"<$headSign>$contentStr</$headSign>\\," + surroundByHeadTAGUnderlineStyle(fol, regex, TAG)
+ }
+ doc
+ }
+
private def surroundByHeadTAG(doc:String, regex:String, TAG:String):String = {
if(doc == ""){return doc}
log debug "--> " + doc
- val p = new Regex(regex, "before","headSize","inTAG","following")
+ val p = new Regex(regex, "before","startHead","inTAG","endHead","following")
val m = p findFirstMatchIn(doc)
+ var contentStr = ""
if(m != None){
var bef = ""
var fol = ""
-
+
if(m.get.group("before") != None){bef = m.get.group("before")}else{bef = ""}
if(m.get.group("following") != None){fol = m.get.group("following")}else{fol = ""}
- val headSize = m.get.group("headSize").size
+ contentStr = m.get.group("inTAG")
+
+ val headSize = m.get.group("startHead").size
+ val endHead = m.get.group("endHead")
+ log debug "-->" + endHead
val headTAG = TAG + headSize
+ if(endHead != null){
+ val m2 = """^\s(#+?)$$""".r("wantSize").findFirstMatchIn(endHead)
+ if(m2 != None){
+ val size = m2.get.group("wantSize")
+ if(size.size != headSize){
+ contentStr += " " + size
+ log warn "Curious header expression was found. " +
+ s" BlackQuill represents this <$headTAG>$contentStr</$headTAG> ."
+ }
+ }
+ }
+
return surroundByHeadTAG(bef,regex,TAG) +
- s"<${headTAG}>" + m.get.group("inTAG") + s"</${headTAG}>\\," +
+ s"<${headTAG}>$contentStr</${headTAG}>\\," +
surroundByHeadTAG(fol,regex,TAG)
}
doc
)
private val specialChar = LinkedHashMap(
- """\-\-""".r -> "—","""<=""".r -> "⇔","""<\->""".r -> "↔","""\->""".r ->"→","""<\-""".r ->"←",
- """=>""".r -> "⇒","""<=""".r -> "⇐","""\|\|^""".r -> "⇑",
- """\|\|/""".r -> "⇓","""\|/""".r -> "↓","""\|^""".r -> "↑","""\+\_""".r -> "±","""!=""".r -> "≠",
+ """[^\-]\-\-[^\-+]""".r -> "—","""<=""".r -> "⇔","""<\->""".r -> "↔","""\->""".r ->"→","""<\-""".r ->"←",
+ """=>""".r -> "⇒","""<=""".r -> "⇐","""\|\|\^""".r -> "⇑",
+ """\|\|/""".r -> "⇓","""\|/""".r -> "↓","""\|\^""".r -> "↑","""\+\_""".r -> "±","""!=""".r -> "≠",
"""~=""".r -> "≅","""<\_""".r -> "≤",""">\_""".r -> "&ge","""\|FA""".r -> "∀","""\|EX""".r -> "∃",
"""\|=""".r -> "≡","""\(\+\)""".r -> "⊕","""\(\-\)""".r -> "⊖","""\(X\)""".r -> "⊗",
"""\(c\)""".r -> "©","""\(R\)""".r ->"®","""\(SS\)""".r -> "§","""\(TM\)""".r -> "™",
- """!in""".r -> "∉", """<""".r->"<",""">""".r->">")
+ """!in""".r -> "∉", """<""".r->"<","""[^\\,|^>+]>""".r->">")
private def passThrough(text:String):String = {text}
private def specialCharConvert(text:String):String = {