• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

BlackQuill


Commit MetaInfo

Revision7b953e23c1b293f32c1e9d19a711e78f2f11b42f (tree)
Time2013-06-03 00:30:44
AuthorSet <set.minami@gmai...>
CommiterSet

Log Message

commit

Change Summary

Incremental Difference

--- a/mdTest/test5.bq
+++ b/mdTest/test5.bq
@@ -8,7 +8,7 @@ bbbbb<-testccccccc
88 ### TITLE2
99 <link href="test->test" />
1010 <!-- これはコメント -->
11-<link href="test2->test2" />
11+<link href="test2-test2" />
1212 <!-- これも
1313 コメント
1414 -->
@@ -54,12 +54,11 @@ bbbbb<-testccccccc
5454 6. F
5555 7. G
5656
57- * A
58- * B
59- * C
60- * D
61- * E
62-
57+ * A
58+ * B
59+ * C
60+ * D
61+ * E
6362 ### aaaaa ###
6463 # aaa1
6564 # aaa2 #
@@ -69,42 +68,34 @@ bbbbb<-testccccccc
6968 # aaa ##
7069 aaa5
7170 ---
72-
73-
7471 >abc
7572 >def
7673
7774 >abc
7875 >ghi
79-
76+aaa
8077 >abc
8178 >jkl
8279 mno
83-
8480 >abc *def*
8581 >ghi **jkl**
8682 >mno
8783
8884 >abc
89->
9085 > * def
9186 > * ghi
9287 >jkl
93-
9488 aaaaaaaaaaaaaaaaaaaaa
9589 aaaaaaaaaaaaaaaa
9690 aaaaaaaaaaa
9791 > bbb
98-
9992 cccccccccccccc
10093 cccccccccccccccc
10194 ccccccccccc
102-
10395 >aaa
10496 >bbb
105-
106-<!-- >>ccc
97+>>ccc
10798 >>ddd
108->eee -->
99+>eee
109100
110101 あああ
\ No newline at end of file
--- a/src/main/scala/org/blackquill/engine/BQParser.scala
+++ b/src/main/scala/org/blackquill/engine/BQParser.scala
@@ -19,8 +19,9 @@ class BQParser {
1919 private val log:Log = LogFactory.getLog(classOf[BQParser])
2020
2121 private val Syntax = LinkedHashMap(
22- "^(.*?\\\\,)((>.*?\\\\,)+?)\\\\,(.*?)$$" -> ("blockquote",surroundByBlockquoteTAG _),
23- "^(.*?\\\\,)>(.*?)\\\\,\\\\,(.*?)$$" -> ("blockquote",surroundByGeneralTAG _),
22+ //"^()((>.*?\\\\,)+?)\\\\,(.*?)$$" -> ("blockquote",surroundByBlockquoteTAG _),
23+ "^(.*?\\\\,)((>.*?\\\\,)+?)(\\\\,.*?)$$" -> ("blockquote",surroundByBlockquoteTAG _),
24+ //"^(.*?\\\\,)>(.*?)\\\\,\\\\,(.*?)$$" -> ("blockquote",surroundByGeneralTAG _),
2425 "^(.*?)((\\s+\\d+?\\.\\s.+?\\\\,)+)(.*?)$$" -> ("ol",surroundByListTAG _),
2526 "^(.*?)((\\s+(?:\\*|\\+|\\-)\\s.+?\\\\,)+)(.*?)$$" -> ("ul",surroundByListTAG _),
2627 "^(.*?)\\*\\*(.+?)\\*\\*(.*?)$$" -> ("em",surroundByGeneralTAG _),
@@ -33,30 +34,47 @@ class BQParser {
3334 private def surroundByBlockquoteTAG(doc:String, regex:String, TAG:String):String = {
3435 val p = new Regex(regex, "before","inTAG","midInTag","following")
3536 val m = p findFirstMatchIn(doc)
36-
37+ log info "[" + doc + "]"
38+
3739 var bef = ""
3840 var fol = ""
3941 var contentStr = ""
4042 if(m != None){
41- val mid = m.get.group("inTAG")
43+ var mid = m.get.group("inTAG")
4244 log info "***-->" + mid
4345
44- if(m.get.group("before") != None){bef = m.get.group("before")}else{bef = ""}
46+ if(m.get.group("before") != None){
47+ bef = m.get.group("before")
48+ if(bef.startsWith(">")){
49+ mid = bef + mid
50+ bef = ""
51+ }
52+ }else{bef = ""}
4553 if(m.get.group("following") != None){fol = m.get.group("following")}else{fol = ""}
4654
4755 log info "=>" + mid
48- if(mid != ""){
49- val mat = """(>(.+?\\,))+?""".r.findAllMatchIn(mid)
56+ if(mid != null){
57+ val mat = """(.+?\\,)+?""".r.findAllMatchIn(mid)
58+
59+ var inCurrentBQ = true
5060
5161 for(mt <- mat){
52- contentStr += mt.group(2)
62+ if(!mt.group(1).startsWith(">")||mt.group(1) == "\\\\,"){
63+ inCurrentBQ = false
64+ }
65+ if(inCurrentBQ){
66+ contentStr += mt.group(1).tail
67+ }else{
68+ log info "(" + mt.group(1) + ")"
69+ fol += mt.group(1)}
5370 log info "^^^" + mt
5471 }
5572 }
56-
73+ log info "bef=" + bef + " mid=" + contentStr + " fol=" + fol
5774 log info "-->" + contentStr
5875 return surroundByBlockquoteTAG(bef, regex, TAG) +
59- "<blockquote>" + contentStr + "</blockquote>" + surroundByBlockquoteTAG(fol, regex, TAG)
76+ s"<$TAG>\\," + surroundByBlockquoteTAG(contentStr, regex, TAG) + s"</$TAG>\\," +
77+ surroundByBlockquoteTAG(fol, regex, TAG)
6078 }
6179 doc
6280 }
@@ -108,7 +126,7 @@ class BQParser {
108126 sign = "\\d+?\\."
109127 }
110128
111- log info ":::" + s
129+ log debug ":::" + s
112130 var docList = List[String]()
113131 for(elem <- s"""(\\s+?$sign\\s.+?\\\\,)+?""".r.findAllMatchIn(s)){
114132 docList = elem.group(1)::docList
@@ -120,7 +138,7 @@ class BQParser {
120138 var tree = new TreeNode[String]("")
121139 if(doc.isEmpty){return tree}
122140
123- log info "====>" + doc
141+ log debug "====>" + doc
124142 tree.add(new TreeNode("<" + sp + s""" style=\"list-style-type:${styles(indent)}\">"""))
125143 var i = indent
126144 var list = List.empty[Tuple3[String,Int,String]]
@@ -154,7 +172,7 @@ class BQParser {
154172 return tree
155173 }
156174
157- log info "->" + docList
175+ log debug "->" + docList
158176 val r1 = s"""(\\s*)${sign}.*?\\\\,""".r
159177 val wS1 = r1.findFirstMatchIn(s)
160178 var str = ""
@@ -169,7 +187,7 @@ class BQParser {
169187 }
170188 if(wS == wS2){str += wS.get.group(2)}
171189
172- log info "!---->" + str
190+ log debug "!---->" + str
173191 surroundByListTAG(bef,regex,TAG) + str + surroundByListTAG(fol,regex,TAG)
174192 }else{doc}
175193 }