OSDN Git Service

div tag option and function updates.
[hmh/hhml.git] / wiki / wikiformat.cc
index eddd786..a47e444 100644 (file)
@@ -132,9 +132,20 @@ void  WikiBlockComplex::outputBlock (MotorOutput* out) {
  ^行頭が他のマークアップ文字になるときは,行頭に^を書く。
  
  空行は,段落を分ける。
-
  段落と段落の間に空行を2行以上入れると、「<div class="pggap"></div>」を出力する。
 
+{div:greenbox
+マークアップ文字以外の文字で書き出すと,段落になる。
+^行頭が他のマークアップ文字になるときは,行頭に^を書く。
+
+空行は,段落を分ける。
+
+
+段落と段落の間に空行を2行以上入れると、「<div class="pggap"></div>」を出力する。
+}
+
 */
 bool  WikiBlockParagraph::nextLine (uiterator b, uiterator e) {
     if (*b == kWikiP) {
@@ -217,11 +228,16 @@ void  WikiBlockParagraph::output (MotorOutput* out) {
 /* ============================================================ */
 /*DOC:
 ===タイトル===
+行頭に=を書くと,タイトルになる。行末の=は,省略可。
+
  =タイトル1=
  ==タイトル2==
  ===タイトル3===#anchor1
-
-行頭に=を書くと,タイトルになる。行末の=は,省略可。
+{div:greenbox
+=タイトル1=
+==タイトル2==
+===タイトル3===#anchor1
+}
 
 */
 
@@ -378,6 +394,9 @@ bool  WikiBlockH::checkEmpty () {
 ===フォーマット済みテキストブロック===
   行頭に空白文字を書くと,<pre>〜</pre>タグで囲まれます。
 インライン要素の解釈は行われない。
+{div:greenbox
+ 行頭に空白文字を書くと,<pre>〜</pre>タグで囲まれます。
+}
 
 */
 bool  WikiBlockPreformatRaw::nextLine (uiterator b, uiterator e) {
@@ -454,12 +473,16 @@ void  WikiBlockItemText::output (MotorOutput* out) {
     if (indentHack) {
        outputBlock (out);
     } else {
-       out->out_raw (CharConst ("<li"));
-       attrib.output (out);
-       out->out_raw (CharConst (">"));
-       out->out_toText (html);
-       outputBlock (out);
-       out->out_raw (CharConst ("</li>\n"));
+       if (html.length () > 0) {
+           out->out_raw (CharConst ("<li"));
+           attrib.output (out);
+           out->out_raw (CharConst (">"));
+           out->out_toText (html);
+           outputBlock (out);
+           out->out_raw (CharConst ("</li>\n"));
+       } else {
+           outputBlock (out);
+       }
     }
 }
 
@@ -473,6 +496,8 @@ void  WikiBlockItemText::output (MotorOutput* out) {
  +インデント1
  ++インデント1-1
  *''[OPTION1:OPTION2:...:]''TEXT
+ *id=item1:class=style1:onclick=[[ignore:]]:TEXT
+
 行頭に「*」を書くと,<UL>タグによるリスト,「#」を書くと<NL>タグによる番号付きリスト,「+」を書くとnobullクラス指定の<UL>タグによるリスト。
 
 オプションパラメータ
@@ -487,6 +512,16 @@ void  WikiBlockItemText::output (MotorOutput* out) {
 |'''onchange='''''Link''||onchange属性。Javascriptリンク。|
 |'''start='''''Number''||start属性。OLのみ。|
 
+{div:greenbox
+*項目1
+**項目1-1
+#ナンバリング1
+##ナンバリング1-2
++インデント1
+++インデント1-1
+*id=item1:class=style1:onclick=[[ignore:]]:TEXT
+}
+
 */
 bool  WikiBlockItem::nextLine (uiterator b, uiterator e) {
     if (*b == ch) {
@@ -598,6 +633,10 @@ void  WikiBlockItem::outputBlock (MotorOutput* out) {
 ===定義リスト===
  ;見出し:説明文
 
+{div:greenbox
+;見出し:説明文
+}
+
 */
 bool  WikiBlockItemDL::nextLine (uiterator b, uiterator e) {
     if (*b == kWikiDL) {
@@ -673,8 +712,8 @@ void  WikiBlockItemDL::output (MotorOutput* out) {
 行オプションで指定できる属性はセルオプションと同じものである。
 
 +・セルオプション
- |header:名前|class=big:東武|
- |header:
+// |header:名前|class=big:東武|
+// |header:
 
 |table:w=100%:行オプション,セルオプション|t:w=20%|c:w=10%|t:|
 |h:オプション|h:省略形|h:説明|
@@ -1319,7 +1358,8 @@ void  WikiBlockQuote::output (MotorOutput* out) {
 |'''onfocus='''''Link''||onfocus属性。Javascriptリンク。|
 |'''onblur='''''Link''||onblur属性。Javascriptリンク。|
 |'''onchange='''''Link''||onchange属性。Javascriptリンク。|
-|'''ClassList'''||class=は省略できる。|
+|''ClassList''||class=は省略できる。|
+|'''#nop'''||divタグを出力しない。pタグを抑制する。|
 
 */
 bool  WikiBlockDiv::nextLine (uiterator b, uiterator e) {
@@ -1327,14 +1367,24 @@ bool  WikiBlockDiv::nextLine (uiterator b, uiterator e) {
 }
 
 void  WikiBlockDiv::addLine (uiterator b, uiterator e) {
-//    bool  rc = matchSkip (b, e, CharConst ("{div:"));
-    bool  rc = matchSkip (b, e, CharConst (uWikiDIV));
+    bool  rc = matchSkip (b, e, CharConst (uWikiDIV)); // {div:
     assert (rc);
     WikiMotor  motor (b, e, wiki);
     WikiMotorObjVecPtr  vec (new WikiMotorObjVec);
 
     motor.compile (*vec);
     attrib.shiftAttrib (vec);
+    {
+       std::vector<ustring>::const_iterator  b = attrib.directlist.begin ();
+       std::vector<ustring>::const_iterator  e = attrib.directlist.end ();
+       for (; b < e; ++ b) {
+           if (match (*b, CharConst ("#nop"))) {
+               nopflag = true;
+           } else {
+               wiki->errorMsg.append (*b).append (CharConst (": bad attribute.\n"));
+           }
+       }
+    }
 }
 
 WikiBlock::closeType  WikiBlockDiv::closeLine (uiterator b, uiterator e) {
@@ -1350,21 +1400,39 @@ WikiBlock::closeType  WikiBlockDiv::closeLine (uiterator b, uiterator e) {
 void  WikiBlockDiv::output (MotorOutput* out) {
     bool  nonl = false;
 
-    if (block.size () == 1 && block[0].type == BlockParagraph) {
-       WikiBlockParagraph*  b = WikiBlockParagraph_type (&block[0]);
-       if (! b->pflag) {
-           b->singleTag = true;
-           nonl = true;
+    if (nopflag) {
+       boost::ptr_vector<WikiBlock>::iterator  b = block.begin ();
+       boost::ptr_vector<WikiBlock>::iterator  e = block.end ();
+       for (; b < e; ++ b) {
+           if (b->type == BlockParagraph) {
+               WikiBlockParagraph*  p = WikiBlockParagraph_type (&(*b));
+               if (! p->pflag) {
+                   p->singleTag = true;
+                   nonl = true;
+               }
+           }
+       }
+    } else {
+       if (block.size () == 1 && block[0].type == BlockParagraph) {
+           WikiBlockParagraph*  b = WikiBlockParagraph_type (&block[0]);
+           if (! b->pflag) {
+               b->singleTag = true;
+               nonl = true;
+           }
        }
+       out->out_raw (CharConst ("<div"));
+       attrib.output (out);
+       if (nonl)
+           out->out_raw (CharConst (">"));
+       else
+           out->out_raw (CharConst (">\n"));
     }
-    out->out_raw (CharConst ("<div"));
-    attrib.output (out);
-    if (nonl)
-       out->out_raw (CharConst (">"));
-    else
-       out->out_raw (CharConst (">\n"));
     outputBlock (out);
-    out->out_raw (CharConst ("</div>\n"));
+    if (! nopflag) {
+       out->out_raw (CharConst ("</div>\n"));
+    } else {
+       out->out_raw (uLF);
+    }
 }
 
 /* ============================================================ */