空行は,段落を分ける。
+ 段落と段落の間に空行を2行以上入れると、「<div class="pggap"></div>」を出力する。
+
*/
bool WikiBlockParagraph::nextLine (uiterator b, uiterator e) {
if (*b == kWikiP) {
}
/* ============================================================ */
+bool WikiBlockBlank::nextLine (uiterator b, uiterator e) {
+ if (b == e) {
+ count ++;
+ return true;
+ } else {
+ switch (*b) { // paragraph以外の全て
+ case kWikiH:
+ case kWikiPRE:
+ case kWikiPRE2:
+ case kWikiUL:
+ case kWikiOL:
+ case kWikiNL:
+ case kWikiDL:
+ case kWikiTABLE:
+ count = 0;
+ break;
+ default:
+ if ((*b == kWikiQUOTE && e - b == 1) ||
+ matchHead (b, e, CharConst (uWikiDIV)) ||
+ (wiki->curform == NULL && matchHead (b, e, CharConst (uWikiFORM))) ||
+ (wiki->curform == NULL && matchHead (b, e, CharConst (uWikiELEMENT))) ||
+ matchHead (b, e, CharConst ("----"))) {
+ count = 0;
+ } else {
+ if (count >= 2)
+ enable = true;
+ }
+ }
+ return false;
+ }
+}
+
+void WikiBlockBlank::addLine (uiterator b, uiterator e) {
+ count ++;
+}
+
+void WikiBlockBlank::output (MotorOutput* out) {
+ if (enable) {
+ out->out_raw (CharConst ("<div class=\"pggap\"></div>\n"));
+ }
+}
+
+/* ============================================================ */
void WikiFormat::pass1 (const ustring& text, WikiLine::linevec* block, bool fsuper) {
SplitterNL sp (text);
WikiLine* wl = scanner.cur ();
if (! wl)
return;
-
- uiterator b = wl->begin;
- uiterator e = wl->end;
-
if (wl->fn) {
wl->fn (wl, this);
} else {
+ uiterator b = wl->begin;
+ uiterator e = wl->end;
+
if (b == e) { // empty line
if (cur) {
- cur->close ();
- cur = NULL;
+ switch (cur->type) {
+ case WikiBlock::BlockParagraph:
+ cur->close ();
+ cur = new WikiBlockBlank (this);
+ blockp->push_back (cur);
+ cur->addLine (b, e);
+ break;
+ case WikiBlock::BlockBlank:
+ cur->addLine (b, e);
+ break;
+ default:
+ cur->close ();
+ cur = NULL;
+ }
}
} else if (matchSkip (b, e, CharConst ("//"))) { // comment
} else if (checkClose (b, e)) {
BlockElement,
BlockHR,
BlockRaw,
+ BlockBlank,
} blockType;
typedef enum {
CloseNA,
virtual void output (MotorOutput* out);
};
+class WikiBlockBlank: public WikiBlock {
+ public:
+ int count;
+ bool enable;
+
+ WikiBlockBlank (WikiFormat* w): WikiBlock (BlockBlank, w) {
+ count = 0;
+ enable = false;
+ };
+ virtual ~WikiBlockBlank () {};
+
+ virtual bool nextLine (uiterator b, uiterator e);
+ virtual void addLine (uiterator b, uiterator e);
+ virtual void output (MotorOutput* out);
+};
+inline WikiBlockBlank* WikiBlockBlank_type (WikiBlock* b) {
+ assert (b->type == WikiBlock::BlockBlank);
+ return (WikiBlockBlank*)b;
+}
+
class WikiFormat {
public:
typedef enum {