ext/dtext/dtext.c in dtext_rb-1.0.11 vs ext/dtext/dtext.c in dtext_rb-1.0.12
- old
+ new
@@ -26,10 +26,11 @@
const char * a2;
const char * b1;
const char * b2;
bool f_inline;
bool f_strip;
+ bool f_mentions;
bool list_mode;
bool header_mode;
GString * output;
GArray * stack;
GQueue * dstack;
@@ -69,15 +70,15 @@
static const int BLOCK_H4 = 26;
static const int BLOCK_H5 = 27;
static const int BLOCK_H6 = 28;
-#line 1038 "ext/dtext/dtext.rl"
+#line 1047 "ext/dtext/dtext.rl"
-#line 79 "ext/dtext/dtext.c"
+#line 80 "ext/dtext/dtext.c"
static const unsigned char _dtext_to_state_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -172,11 +173,11 @@
static const int dtext_en_table = 306;
static const int dtext_en_list = 308;
static const int dtext_en_main = 249;
-#line 1041 "ext/dtext/dtext.rl"
+#line 1050 "ext/dtext/dtext.rl"
static inline void underscore_string(char * str, size_t len) {
for (size_t i=0; i<len; ++i) {
if (str[i] == ' ') {
str[i] = '_';
@@ -473,10 +474,11 @@
sm->a2 = NULL;
sm->b1 = NULL;
sm->b2 = NULL;
sm->f_inline = false;
sm->f_strip = false;
+ sm->f_mentions = true;
sm->stack = g_array_sized_new(FALSE, TRUE, sizeof(int), 16);
sm->dstack = g_queue_new();
sm->list_nest = 0;
sm->list_mode = false;
sm->header_mode = false;
@@ -490,42 +492,43 @@
g_array_free(sm->stack, FALSE);
g_queue_free(sm->dstack);
g_free(sm);
}
-static StateMachine * parse_helper(const char * src, size_t len, bool f_strip, bool f_inline) {
+static StateMachine * parse_helper(const char * src, size_t len, bool f_strip, bool f_inline, bool f_mentions) {
StateMachine * sm = NULL;
StateMachine * link_content_sm = NULL;
sm = (StateMachine *)g_malloc0(sizeof(StateMachine));
init_machine(sm, src, len);
sm->f_strip = f_strip;
sm->f_inline = f_inline;
+ sm->f_mentions = f_mentions;
-#line 506 "ext/dtext/dtext.c"
+#line 509 "ext/dtext/dtext.c"
{
sm->cs = dtext_start;
( sm->top) = 0;
( sm->ts) = 0;
( sm->te) = 0;
( sm->act) = 0;
}
-#line 1368 "ext/dtext/dtext.rl"
+#line 1379 "ext/dtext/dtext.rl"
-#line 517 "ext/dtext/dtext.c"
+#line 520 "ext/dtext/dtext.c"
{
if ( ( sm->p) == ( sm->pe) )
goto _test_eof;
_resume:
switch ( _dtext_from_state_actions[ sm->cs] ) {
case 58:
#line 1 "NONE"
{( sm->ts) = ( sm->p);}
break;
-#line 527 "ext/dtext/dtext.c"
+#line 530 "ext/dtext/dtext.c"
}
switch ( sm->cs ) {
case 249:
switch( (*( sm->p)) ) {
@@ -2740,49 +2743,49 @@
tr437: sm->cs = 312; goto _again;
tr296: sm->cs = 312; goto f3;
tr297: sm->cs = 313; goto f3;
f7:
-#line 97 "ext/dtext/dtext.rl"
+#line 98 "ext/dtext/dtext.rl"
{
sm->a1 = sm->p;
}
goto _again;
f4:
-#line 101 "ext/dtext/dtext.rl"
+#line 102 "ext/dtext/dtext.rl"
{
sm->a2 = sm->p;
}
goto _again;
f3:
-#line 105 "ext/dtext/dtext.rl"
+#line 106 "ext/dtext/dtext.rl"
{
sm->b1 = sm->p;
}
goto _again;
f5:
-#line 109 "ext/dtext/dtext.rl"
+#line 110 "ext/dtext/dtext.rl"
{
sm->b2 = sm->p;
}
goto _again;
f61:
#line 1 "NONE"
{( sm->te) = ( sm->p)+1;}
goto _again;
f38:
-#line 262 "ext/dtext/dtext.rl"
+#line 263 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
append(sm, true, "<a rel=\"nofollow\" href=\"/posts?tags=");
append_segment_uri_escaped(sm, sm->a1, sm->a2 - 1);
append(sm, true, "\">");
append_segment_html_escaped(sm, sm->a1, sm->a2 - 1);
append(sm, true, "</a>");
}}
goto _again;
f36:
-#line 270 "ext/dtext/dtext.rl"
+#line 271 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
GString * segment = g_string_new_len(sm->a1, sm->a2 - sm->a1);
GString * lowercase_segment = NULL;
underscore_string(segment->str, segment->len);
@@ -2801,11 +2804,11 @@
g_string_free(lowercase_segment, TRUE);
g_string_free(segment, TRUE);
}}
goto _again;
f37:
-#line 291 "ext/dtext/dtext.rl"
+#line 292 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
GString * segment = g_string_new_len(sm->a1, sm->a2 - sm->a1);
GString * lowercase_segment = NULL;
underscore_string(segment->str, segment->len);
@@ -2824,90 +2827,90 @@
g_string_free(lowercase_segment, TRUE);
g_string_free(segment, TRUE);
}}
goto _again;
f27:
-#line 408 "ext/dtext/dtext.rl"
+#line 416 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_push(sm, &INLINE_B);
append(sm, true, "<strong>");
}}
goto _again;
f18:
-#line 413 "ext/dtext/dtext.rl"
+#line 421 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
if (dstack_check(sm, INLINE_B)) {
dstack_pop(sm);
append(sm, true, "</strong>");
} else {
append(sm, true, "[/b]");
}
}}
goto _again;
f29:
-#line 422 "ext/dtext/dtext.rl"
+#line 430 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_push(sm, &INLINE_I);
append(sm, true, "<em>");
}}
goto _again;
f20:
-#line 427 "ext/dtext/dtext.rl"
+#line 435 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
if (dstack_check(sm, INLINE_I)) {
dstack_pop(sm);
append(sm, true, "</em>");
} else {
append(sm, true, "[/i]");
}
}}
goto _again;
f32:
-#line 436 "ext/dtext/dtext.rl"
+#line 444 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_push(sm, &INLINE_S);
append(sm, true, "<s>");
}}
goto _again;
f21:
-#line 441 "ext/dtext/dtext.rl"
+#line 449 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
if (dstack_check(sm, INLINE_S)) {
dstack_pop(sm);
append(sm, true, "</s>");
} else {
append(sm, true, "[/s]");
}
}}
goto _again;
f35:
-#line 450 "ext/dtext/dtext.rl"
+#line 458 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_push(sm, &INLINE_U);
append(sm, true, "<u>");
}}
goto _again;
f26:
-#line 455 "ext/dtext/dtext.rl"
+#line 463 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
if (dstack_check(sm, INLINE_U)) {
dstack_pop(sm);
append(sm, true, "</u>");
} else {
append(sm, true, "[/u]");
}
}}
goto _again;
f34:
-#line 464 "ext/dtext/dtext.rl"
+#line 472 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_push(sm, &INLINE_TN);
append(sm, true, "<span class=\"tn\">");
}}
goto _again;
f25:
-#line 469 "ext/dtext/dtext.rl"
+#line 477 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_close_before_block(sm);
if (dstack_check(sm, BLOCK_TN)) {
dstack_pop(sm);
@@ -2919,29 +2922,29 @@
append_block(sm, "[/tn]");
}
}}
goto _again;
f31:
-#line 497 "ext/dtext/dtext.rl"
+#line 505 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
g_debug("inline [quote]");
dstack_close_before_block(sm);
{( sm->p) = (( sm->ts))-1;}
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
}}
goto _again;
f33:
-#line 520 "ext/dtext/dtext.rl"
+#line 528 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
g_debug("inline [spoiler]");
g_debug(" push <span>");
dstack_push(sm, &INLINE_SPOILER);
append(sm, true, "<span class=\"spoiler\">");
}}
goto _again;
f22:
-#line 527 "ext/dtext/dtext.rl"
+#line 535 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
g_debug("inline [/spoiler]");
dstack_close_before_block(sm);
if (dstack_check(sm, INLINE_SPOILER)) {
@@ -2960,20 +2963,20 @@
append_block(sm, "[/spoiler]");
}
}}
goto _again;
f28:
-#line 548 "ext/dtext/dtext.rl"
+#line 556 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
g_debug("inline [expand]");
dstack_rewind(sm);
{( sm->p) = (((sm->p - 7)))-1;}
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
}}
goto _again;
f19:
-#line 555 "ext/dtext/dtext.rl"
+#line 563 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_close_before_block(sm);
if (dstack_check(sm, BLOCK_EXPAND)) {
append_block(sm, "</div></div>");
@@ -2983,11 +2986,11 @@
append_block(sm, "[/expand]");
}
}}
goto _again;
f30:
-#line 567 "ext/dtext/dtext.rl"
+#line 575 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_push(sm, &INLINE_NODTEXT);
{
size_t len = sm->stack->len;
@@ -3001,11 +3004,11 @@
}
{( ((int *)sm->stack->data))[( sm->top)++] = sm->cs; sm->cs = 304; goto _again;}}
}}
goto _again;
f24:
-#line 572 "ext/dtext/dtext.rl"
+#line 580 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
if (dstack_check(sm, BLOCK_TH)) {
dstack_pop(sm);
append_block(sm, "</th>");
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
@@ -3013,11 +3016,11 @@
append_block(sm, "[/th]");
}
}}
goto _again;
f23:
-#line 582 "ext/dtext/dtext.rl"
+#line 590 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
if (dstack_check(sm, BLOCK_TD)) {
dstack_pop(sm);
append_block(sm, "</td>");
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
@@ -3025,28 +3028,28 @@
append_block(sm, "[/td]");
}
}}
goto _again;
f73:
-#line 592 "ext/dtext/dtext.rl"
+#line 600 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
g_debug("inline 0");
g_debug(" return");
( sm->p)--;
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
}}
goto _again;
f72:
-#line 628 "ext/dtext/dtext.rl"
+#line 636 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
g_debug("inline char: %c", (*( sm->p)));
append_c_html_escaped(sm, (*( sm->p)));
}}
goto _again;
f99:
-#line 343 "ext/dtext/dtext.rl"
+#line 344 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
if (is_boundary_c((*( sm->p)))) {
sm->b = true;
sm->d = 2;
} else {
@@ -3064,27 +3067,27 @@
append_c_html_escaped(sm, (*( sm->p)));
}
}}
goto _again;
f89:
-#line 485 "ext/dtext/dtext.rl"
+#line 493 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
dstack_rewind(sm);
{( sm->p) = (( sm->a1 - 1))-1;}
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
}}
goto _again;
f88:
-#line 491 "ext/dtext/dtext.rl"
+#line 499 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
dstack_rewind(sm);
{( sm->p) = (( sm->a1 - 1))-1;}
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
}}
goto _again;
f98:
-#line 504 "ext/dtext/dtext.rl"
+#line 512 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
g_debug("inline [/quote]");
dstack_close_before_block(sm);
if (dstack_check(sm, BLOCK_LI)) {
@@ -3098,11 +3101,11 @@
append_block(sm, "[/quote]");
}
}}
goto _again;
f76:
-#line 600 "ext/dtext/dtext.rl"
+#line 608 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
g_debug("inline newline2");
g_debug(" return");
if (sm->list_mode) {
@@ -3112,11 +3115,11 @@
{( sm->p) = (( sm->ts))-1;}
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
}}
goto _again;
f75:
-#line 612 "ext/dtext/dtext.rl"
+#line 620 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
g_debug("inline newline");
if (sm->header_mode) {
sm->header_mode = false;
@@ -3126,46 +3129,46 @@
append(sm, true, "<br>");
}
}}
goto _again;
f78:
-#line 624 "ext/dtext/dtext.rl"
+#line 632 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
append_c(sm, ' ');
}}
goto _again;
f79:
-#line 628 "ext/dtext/dtext.rl"
+#line 636 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
g_debug("inline char: %c", (*( sm->p)));
append_c_html_escaped(sm, (*( sm->p)));
}}
goto _again;
f17:
-#line 173 "ext/dtext/dtext.rl"
+#line 174 "ext/dtext/dtext.rl"
{{( sm->p) = ((( sm->te)))-1;}{
append(sm, true, "<a href=\"/forum_topics/");
append_segment(sm, true, sm->a1, sm->a2 - 1);
append(sm, true, "\">");
append(sm, false, "topic #");
append_segment(sm, false, sm->a1, sm->a2 - 1);
append(sm, true, "</a>");
}}
goto _again;
f16:
-#line 240 "ext/dtext/dtext.rl"
+#line 241 "ext/dtext/dtext.rl"
{{( sm->p) = ((( sm->te)))-1;}{
append(sm, true, "<a href=\"http://www.pixiv.net/member_illust.php?mode=medium&illust_id=");
append_segment(sm, true, sm->a1, sm->a2 - 1);
append(sm, true, "\">");
append(sm, false, "pixiv #");
append_segment(sm, false, sm->a1, sm->a2 - 1);
append(sm, true, "</a>");
}}
goto _again;
f12:
-#line 612 "ext/dtext/dtext.rl"
+#line 620 "ext/dtext/dtext.rl"
{{( sm->p) = ((( sm->te)))-1;}{
g_debug("inline newline");
if (sm->header_mode) {
sm->header_mode = false;
@@ -3175,11 +3178,11 @@
append(sm, true, "<br>");
}
}}
goto _again;
f13:
-#line 628 "ext/dtext/dtext.rl"
+#line 636 "ext/dtext/dtext.rl"
{{( sm->p) = ((( sm->te)))-1;}{
g_debug("inline char: %c", (*( sm->p)));
append_c_html_escaped(sm, (*( sm->p)));
}}
goto _again;
@@ -3191,27 +3194,34 @@
append_segment_html_escaped(sm, sm->ts, sm->te - 1);
}
break;
case 19:
{{( sm->p) = ((( sm->te)))-1;}
- if (is_boundary_c((*( sm->p)))) {
- sm->b = true;
- sm->d = 2;
+ if (!sm->f_mentions || (sm->a1 > sm->pb && sm->a1 - 1 > sm->pb && sm->a1[-2] != ' ' && sm->a1[-2] != '\r' && sm->a1[-2] != '\n')) {
+ // handle emails
+ append_c(sm, '@');
+ append_segment_html_escaped(sm, sm->a1, sm->a2 - 1);
+
} else {
- sm->b = false;
- sm->d = 1;
- }
+ if (is_boundary_c((*( sm->p)))) {
+ sm->b = true;
+ sm->d = 2;
+ } else {
+ sm->b = false;
+ sm->d = 1;
+ }
- append(sm, true, "<a rel=\"nofollow\" href=\"/users?name=");
- append_segment_uri_escaped(sm, sm->a1, sm->a2 - sm->d);
- append(sm, true, "\">");
- append_c(sm, '@');
- append_segment_html_escaped(sm, sm->a1, sm->a2 - sm->d);
- append(sm, true, "</a>");
+ append(sm, true, "<a rel=\"nofollow\" href=\"/users?name=");
+ append_segment_uri_escaped(sm, sm->a1, sm->a2 - sm->d);
+ append(sm, true, "\">");
+ append_c(sm, '@');
+ append_segment_html_escaped(sm, sm->a1, sm->a2 - sm->d);
+ append(sm, true, "</a>");
- if (sm->b) {
- append_c_html_escaped(sm, (*( sm->p)));
+ if (sm->b) {
+ append_c_html_escaped(sm, (*( sm->p)));
+ }
}
}
break;
case 43:
{{( sm->p) = ((( sm->te)))-1;}
@@ -3241,47 +3251,47 @@
break;
}
}
goto _again;
f40:
-#line 635 "ext/dtext/dtext.rl"
+#line 643 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
if (dstack_check(sm, BLOCK_CODE)) {
dstack_rewind(sm);
} else {
append(sm, true, "[/code]");
}
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
}}
goto _again;
f101:
-#line 644 "ext/dtext/dtext.rl"
+#line 652 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
( sm->p)--;
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
}}
goto _again;
f100:
-#line 649 "ext/dtext/dtext.rl"
+#line 657 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
append_c_html_escaped(sm, (*( sm->p)));
}}
goto _again;
f102:
-#line 649 "ext/dtext/dtext.rl"
+#line 657 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
append_c_html_escaped(sm, (*( sm->p)));
}}
goto _again;
f39:
-#line 649 "ext/dtext/dtext.rl"
+#line 657 "ext/dtext/dtext.rl"
{{( sm->p) = ((( sm->te)))-1;}{
append_c_html_escaped(sm, (*( sm->p)));
}}
goto _again;
f42:
-#line 655 "ext/dtext/dtext.rl"
+#line 663 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
if (dstack_check(sm, BLOCK_NODTEXT)) {
dstack_pop(sm);
append_block(sm, "</p>");
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
@@ -3292,72 +3302,72 @@
append(sm, true, "[/nodtext]");
}
}}
goto _again;
f104:
-#line 668 "ext/dtext/dtext.rl"
+#line 676 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
( sm->p)--;
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
}}
goto _again;
f103:
-#line 673 "ext/dtext/dtext.rl"
+#line 681 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
append_c_html_escaped(sm, (*( sm->p)));
}}
goto _again;
f105:
-#line 673 "ext/dtext/dtext.rl"
+#line 681 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
append_c_html_escaped(sm, (*( sm->p)));
}}
goto _again;
f41:
-#line 673 "ext/dtext/dtext.rl"
+#line 681 "ext/dtext/dtext.rl"
{{( sm->p) = ((( sm->te)))-1;}{
append_c_html_escaped(sm, (*( sm->p)));
}}
goto _again;
f51:
-#line 679 "ext/dtext/dtext.rl"
+#line 687 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_push(sm, &BLOCK_THEAD);
append_block(sm, "<thead>");
}}
goto _again;
f46:
-#line 684 "ext/dtext/dtext.rl"
+#line 692 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
if (dstack_check(sm, BLOCK_THEAD)) {
dstack_pop(sm);
append_block(sm, "</thead>");
} else {
append(sm, true, "[/thead]");
}
}}
goto _again;
f48:
-#line 693 "ext/dtext/dtext.rl"
+#line 701 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_push(sm, &BLOCK_TBODY);
append_block(sm, "<tbody>");
}}
goto _again;
f45:
-#line 698 "ext/dtext/dtext.rl"
+#line 706 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
if (dstack_check(sm, BLOCK_TBODY)) {
dstack_pop(sm);
append_block(sm, "</tbody>");
} else {
append(sm, true, "[/tbody]");
}
}}
goto _again;
f50:
-#line 707 "ext/dtext/dtext.rl"
+#line 715 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_push(sm, &BLOCK_TH);
append_block(sm, "<th>");
{
size_t len = sm->stack->len;
@@ -3372,29 +3382,29 @@
}
{( ((int *)sm->stack->data))[( sm->top)++] = sm->cs; sm->cs = 265; goto _again;}}
}}
goto _again;
f52:
-#line 713 "ext/dtext/dtext.rl"
+#line 721 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_push(sm, &BLOCK_TR);
append_block(sm, "<tr>");
}}
goto _again;
f47:
-#line 718 "ext/dtext/dtext.rl"
+#line 726 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
if (dstack_check(sm, BLOCK_TR)) {
dstack_pop(sm);
append_block(sm, "</tr>");
} else {
append(sm, true, "[/tr]");
}
}}
goto _again;
f49:
-#line 727 "ext/dtext/dtext.rl"
+#line 735 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_push(sm, &BLOCK_TD);
append_block(sm, "<td>");
{
size_t len = sm->stack->len;
@@ -3409,11 +3419,11 @@
}
{( ((int *)sm->stack->data))[( sm->top)++] = sm->cs; sm->cs = 265; goto _again;}}
}}
goto _again;
f44:
-#line 733 "ext/dtext/dtext.rl"
+#line 741 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
if (dstack_check(sm, BLOCK_TABLE)) {
dstack_pop(sm);
append_block(sm, "</table>");
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
@@ -3421,54 +3431,54 @@
append(sm, true, "[/table]");
}
}}
goto _again;
f107:
-#line 743 "ext/dtext/dtext.rl"
+#line 751 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
( sm->p)--;
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
}}
goto _again;
f106:
-#line 748 "ext/dtext/dtext.rl"
+#line 756 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;}
goto _again;
f108:
-#line 748 "ext/dtext/dtext.rl"
+#line 756 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;}
goto _again;
f43:
-#line 748 "ext/dtext/dtext.rl"
+#line 756 "ext/dtext/dtext.rl"
{{( sm->p) = ((( sm->te)))-1;}}
goto _again;
f110:
-#line 791 "ext/dtext/dtext.rl"
+#line 799 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_close_list(sm);
{( sm->p) = (( sm->ts))-1;}
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
}}
goto _again;
f109:
-#line 799 "ext/dtext/dtext.rl"
+#line 807 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_rewind(sm);
( sm->p)--;
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
}}
goto _again;
f112:
-#line 799 "ext/dtext/dtext.rl"
+#line 807 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
dstack_rewind(sm);
( sm->p)--;
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
}}
goto _again;
f55:
-#line 799 "ext/dtext/dtext.rl"
+#line 807 "ext/dtext/dtext.rl"
{{( sm->p) = ((( sm->te)))-1;}{
dstack_rewind(sm);
( sm->p)--;
{ sm->cs = ( ((int *)sm->stack->data))[--( sm->top)];goto _again;}
}}
@@ -3488,22 +3498,22 @@
break;
}
}
goto _again;
f6:
-#line 930 "ext/dtext/dtext.rl"
+#line 939 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
g_debug("block [/spoiler]");
dstack_close_before_block(sm);
if (dstack_check(sm, BLOCK_SPOILER)) {
g_debug(" rewind");
dstack_rewind(sm);
}
}}
goto _again;
f8:
-#line 977 "ext/dtext/dtext.rl"
+#line 986 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_close_before_block(sm);
dstack_push(sm, &BLOCK_TABLE);
append_block(sm, "<table class=\"striped\">");
{
@@ -3519,11 +3529,11 @@
}
{( ((int *)sm->stack->data))[( sm->top)++] = sm->cs; sm->cs = 306; goto _again;}}
}}
goto _again;
f9:
-#line 984 "ext/dtext/dtext.rl"
+#line 993 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
dstack_push(sm, &BLOCK_TN);
append_block(sm, "<p class=\"tn\">");
{
size_t len = sm->stack->len;
@@ -3538,19 +3548,19 @@
}
{( ((int *)sm->stack->data))[( sm->top)++] = sm->cs; sm->cs = 265; goto _again;}}
}}
goto _again;
f59:
-#line 1000 "ext/dtext/dtext.rl"
+#line 1009 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
g_debug("block 0");
g_debug(" close dstack");
dstack_close(sm);
}}
goto _again;
f58:
-#line 1023 "ext/dtext/dtext.rl"
+#line 1032 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
g_debug("block char: %c", (*( sm->p)));
( sm->p)--;
if (g_queue_is_empty(sm->dstack) || dstack_check(sm, BLOCK_QUOTE) || dstack_check(sm, BLOCK_SPOILER) || dstack_check(sm, BLOCK_EXPAND)) {
@@ -3573,14 +3583,15 @@
}
{( ((int *)sm->stack->data))[( sm->top)++] = sm->cs; sm->cs = 265; goto _again;}}
}}
goto _again;
f64:
-#line 807 "ext/dtext/dtext.rl"
+#line 815 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
char header = *sm->a1;
GString * id_name = g_string_new_len(sm->b1, sm->b2 - sm->b1);
+ id_name = g_string_prepend(id_name, "dtext-");
if (sm->f_inline) {
header = '6';
}
@@ -3646,11 +3657,11 @@
}
{( ((int *)sm->stack->data))[( sm->top)++] = sm->cs; sm->cs = 265; goto _again;}}
}}
goto _again;
f65:
-#line 867 "ext/dtext/dtext.rl"
+#line 876 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
char header = *sm->a1;
if (sm->f_inline) {
header = '6';
@@ -3704,33 +3715,33 @@
}
{( ((int *)sm->stack->data))[( sm->top)++] = sm->cs; sm->cs = 265; goto _again;}}
}}
goto _again;
f70:
-#line 912 "ext/dtext/dtext.rl"
+#line 921 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
g_debug("block [quote]");
g_debug(" push quote");
g_debug(" print <blockquote>");
dstack_close_before_block(sm);
dstack_push(sm, &BLOCK_QUOTE);
append_block(sm, "<blockquote>");
}}
goto _again;
f71:
-#line 921 "ext/dtext/dtext.rl"
+#line 930 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
g_debug("block [spoiler]");
g_debug(" push spoiler");
g_debug(" print <div>");
dstack_close_before_block(sm);
dstack_push(sm, &BLOCK_SPOILER);
append_block(sm, "<div class=\"spoiler\">");
}}
goto _again;
f66:
-#line 939 "ext/dtext/dtext.rl"
+#line 948 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
g_debug("block [code]");
dstack_close_before_block(sm);
dstack_push(sm, &BLOCK_CODE);
append_block(sm, "<pre>");
@@ -3747,22 +3758,22 @@
}
{( ((int *)sm->stack->data))[( sm->top)++] = sm->cs; sm->cs = 302; goto _again;}}
}}
goto _again;
f68:
-#line 947 "ext/dtext/dtext.rl"
+#line 956 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
g_debug("block [expand]");
dstack_close_before_block(sm);
dstack_push(sm, &BLOCK_EXPAND);
append_block(sm, "<div class=\"expandable\"><div class=\"expandable-header\">");
append_block(sm, "<input type=\"button\" value=\"Show\" class=\"expandable-button\"/></div>");
append_block(sm, "<div class=\"expandable-content\">");
}}
goto _again;
f67:
-#line 956 "ext/dtext/dtext.rl"
+#line 965 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
g_debug("block [expand=]");
dstack_close_before_block(sm);
dstack_push(sm, &BLOCK_EXPAND);
append_block(sm, "<div class=\"expandable\"><div class=\"expandable-header\">");
@@ -3772,11 +3783,11 @@
append_block(sm, "<input type=\"button\" value=\"Show\" class=\"expandable-button\"/></div>");
append_block(sm, "<div class=\"expandable-content\">");
}}
goto _again;
f69:
-#line 968 "ext/dtext/dtext.rl"
+#line 977 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
g_debug("block [nodtext]");
dstack_close_before_block(sm);
dstack_push(sm, &BLOCK_NODTEXT);
dstack_push(sm, &BLOCK_P);
@@ -3794,11 +3805,11 @@
}
{( ((int *)sm->stack->data))[( sm->top)++] = sm->cs; sm->cs = 304; goto _again;}}
}}
goto _again;
f62:
-#line 1023 "ext/dtext/dtext.rl"
+#line 1032 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
g_debug("block char: %c", (*( sm->p)));
( sm->p)--;
if (g_queue_is_empty(sm->dstack) || dstack_check(sm, BLOCK_QUOTE) || dstack_check(sm, BLOCK_SPOILER) || dstack_check(sm, BLOCK_EXPAND)) {
@@ -3821,11 +3832,11 @@
}
{( ((int *)sm->stack->data))[( sm->top)++] = sm->cs; sm->cs = 265; goto _again;}}
}}
goto _again;
f2:
-#line 1023 "ext/dtext/dtext.rl"
+#line 1032 "ext/dtext/dtext.rl"
{{( sm->p) = ((( sm->te)))-1;}{
g_debug("block char: %c", (*( sm->p)));
( sm->p)--;
if (g_queue_is_empty(sm->dstack) || dstack_check(sm, BLOCK_QUOTE) || dstack_check(sm, BLOCK_SPOILER) || dstack_check(sm, BLOCK_EXPAND)) {
@@ -3873,173 +3884,180 @@
break;
}
}
goto _again;
f94:
-#line 101 "ext/dtext/dtext.rl"
+#line 102 "ext/dtext/dtext.rl"
{
sm->a2 = sm->p;
}
-#line 155 "ext/dtext/dtext.rl"
+#line 156 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
append(sm, true, "<a href=\"/posts/");
append_segment(sm, true, sm->a1, sm->a2 - 1);
append(sm, true, "\">");
append(sm, false, "post #");
append_segment(sm, false, sm->a1, sm->a2 - 1);
append(sm, true, "</a>");
}}
goto _again;
f87:
-#line 101 "ext/dtext/dtext.rl"
+#line 102 "ext/dtext/dtext.rl"
{
sm->a2 = sm->p;
}
-#line 164 "ext/dtext/dtext.rl"
+#line 165 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
append(sm, true, "<a href=\"/forum_posts/");
append_segment(sm, true, sm->a1, sm->a2 - 1);
append(sm, true, "\">");
append(sm, false, "forum #");
append_segment(sm, false, sm->a1, sm->a2 - 1);
append(sm, true, "</a>");
}}
goto _again;
f95:
-#line 101 "ext/dtext/dtext.rl"
+#line 102 "ext/dtext/dtext.rl"
{
sm->a2 = sm->p;
}
-#line 173 "ext/dtext/dtext.rl"
+#line 174 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
append(sm, true, "<a href=\"/forum_topics/");
append_segment(sm, true, sm->a1, sm->a2 - 1);
append(sm, true, "\">");
append(sm, false, "topic #");
append_segment(sm, false, sm->a1, sm->a2 - 1);
append(sm, true, "</a>");
}}
goto _again;
f86:
-#line 101 "ext/dtext/dtext.rl"
+#line 102 "ext/dtext/dtext.rl"
{
sm->a2 = sm->p;
}
-#line 195 "ext/dtext/dtext.rl"
+#line 196 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
append(sm, true, "<a href=\"/comments/");
append_segment(sm, true, sm->a1, sm->a2 - 1);
append(sm, true, "\">");
append(sm, false, "comment #");
append_segment(sm, false, sm->a1, sm->a2 - 1);
append(sm, true, "</a>");
}}
goto _again;
f93:
-#line 101 "ext/dtext/dtext.rl"
+#line 102 "ext/dtext/dtext.rl"
{
sm->a2 = sm->p;
}
-#line 204 "ext/dtext/dtext.rl"
+#line 205 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
append(sm, true, "<a href=\"/pools/");
append_segment(sm, true, sm->a1, sm->a2 - 1);
append(sm, true, "\">");
append(sm, false, "pool #");
append_segment(sm, false, sm->a1, sm->a2 - 1);
append(sm, true, "</a>");
}}
goto _again;
f97:
-#line 101 "ext/dtext/dtext.rl"
+#line 102 "ext/dtext/dtext.rl"
{
sm->a2 = sm->p;
}
-#line 213 "ext/dtext/dtext.rl"
+#line 214 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
append(sm, true, "<a href=\"/users/");
append_segment(sm, true, sm->a1, sm->a2 - 1);
append(sm, true, "\">");
append(sm, false, "user #");
append_segment(sm, false, sm->a1, sm->a2 - 1);
append(sm, true, "</a>");
}}
goto _again;
f85:
-#line 101 "ext/dtext/dtext.rl"
+#line 102 "ext/dtext/dtext.rl"
{
sm->a2 = sm->p;
}
-#line 222 "ext/dtext/dtext.rl"
+#line 223 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
append(sm, true, "<a href=\"/artists/");
append_segment(sm, true, sm->a1, sm->a2 - 1);
append(sm, true, "\">");
append(sm, false, "artist #");
append_segment(sm, false, sm->a1, sm->a2 - 1);
append(sm, true, "</a>");
}}
goto _again;
f90:
-#line 101 "ext/dtext/dtext.rl"
+#line 102 "ext/dtext/dtext.rl"
{
sm->a2 = sm->p;
}
-#line 231 "ext/dtext/dtext.rl"
+#line 232 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
append(sm, true, "<a href=\"https://github.com/r888888888/danbooru/issues/");
append_segment(sm, true, sm->a1, sm->a2 - 1);
append(sm, true, "\">");
append(sm, false, "issue #");
append_segment(sm, false, sm->a1, sm->a2 - 1);
append(sm, true, "</a>");
}}
goto _again;
f91:
-#line 101 "ext/dtext/dtext.rl"
+#line 102 "ext/dtext/dtext.rl"
{
sm->a2 = sm->p;
}
-#line 240 "ext/dtext/dtext.rl"
+#line 241 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
append(sm, true, "<a href=\"http://www.pixiv.net/member_illust.php?mode=medium&illust_id=");
append_segment(sm, true, sm->a1, sm->a2 - 1);
append(sm, true, "\">");
append(sm, false, "pixiv #");
append_segment(sm, false, sm->a1, sm->a2 - 1);
append(sm, true, "</a>");
}}
goto _again;
f81:
-#line 101 "ext/dtext/dtext.rl"
+#line 102 "ext/dtext/dtext.rl"
{
sm->a2 = sm->p;
}
-#line 368 "ext/dtext/dtext.rl"
+#line 369 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
- if (is_boundary_c((*( sm->p)))) {
- sm->b = true;
- sm->d = 2;
+ if (!sm->f_mentions || (sm->a1 > sm->pb && sm->a1 - 1 > sm->pb && sm->a1[-2] != ' ' && sm->a1[-2] != '\r' && sm->a1[-2] != '\n')) {
+ // handle emails
+ append_c(sm, '@');
+ append_segment_html_escaped(sm, sm->a1, sm->a2 - 1);
+
} else {
- sm->b = false;
- sm->d = 1;
- }
+ if (is_boundary_c((*( sm->p)))) {
+ sm->b = true;
+ sm->d = 2;
+ } else {
+ sm->b = false;
+ sm->d = 1;
+ }
- append(sm, true, "<a rel=\"nofollow\" href=\"/users?name=");
- append_segment_uri_escaped(sm, sm->a1, sm->a2 - sm->d);
- append(sm, true, "\">");
- append_c(sm, '@');
- append_segment_html_escaped(sm, sm->a1, sm->a2 - sm->d);
- append(sm, true, "</a>");
+ append(sm, true, "<a rel=\"nofollow\" href=\"/users?name=");
+ append_segment_uri_escaped(sm, sm->a1, sm->a2 - sm->d);
+ append(sm, true, "\">");
+ append_c(sm, '@');
+ append_segment_html_escaped(sm, sm->a1, sm->a2 - sm->d);
+ append(sm, true, "</a>");
- if (sm->b) {
- append_c_html_escaped(sm, (*( sm->p)));
+ if (sm->b) {
+ append_c_html_escaped(sm, (*( sm->p)));
+ }
}
}}
goto _again;
f84:
-#line 101 "ext/dtext/dtext.rl"
+#line 102 "ext/dtext/dtext.rl"
{
sm->a2 = sm->p;
}
#line 1 "NONE"
{ switch( ( sm->act) ) {
@@ -4048,27 +4066,34 @@
append_segment_html_escaped(sm, sm->ts, sm->te - 1);
}
break;
case 19:
{{( sm->p) = ((( sm->te)))-1;}
- if (is_boundary_c((*( sm->p)))) {
- sm->b = true;
- sm->d = 2;
+ if (!sm->f_mentions || (sm->a1 > sm->pb && sm->a1 - 1 > sm->pb && sm->a1[-2] != ' ' && sm->a1[-2] != '\r' && sm->a1[-2] != '\n')) {
+ // handle emails
+ append_c(sm, '@');
+ append_segment_html_escaped(sm, sm->a1, sm->a2 - 1);
+
} else {
- sm->b = false;
- sm->d = 1;
- }
+ if (is_boundary_c((*( sm->p)))) {
+ sm->b = true;
+ sm->d = 2;
+ } else {
+ sm->b = false;
+ sm->d = 1;
+ }
- append(sm, true, "<a rel=\"nofollow\" href=\"/users?name=");
- append_segment_uri_escaped(sm, sm->a1, sm->a2 - sm->d);
- append(sm, true, "\">");
- append_c(sm, '@');
- append_segment_html_escaped(sm, sm->a1, sm->a2 - sm->d);
- append(sm, true, "</a>");
+ append(sm, true, "<a rel=\"nofollow\" href=\"/users?name=");
+ append_segment_uri_escaped(sm, sm->a1, sm->a2 - sm->d);
+ append(sm, true, "\">");
+ append_c(sm, '@');
+ append_segment_html_escaped(sm, sm->a1, sm->a2 - sm->d);
+ append(sm, true, "</a>");
- if (sm->b) {
- append_c_html_escaped(sm, (*( sm->p)));
+ if (sm->b) {
+ append_c_html_escaped(sm, (*( sm->p)));
+ }
}
}
break;
case 43:
{{( sm->p) = ((( sm->te)))-1;}
@@ -4098,29 +4123,29 @@
break;
}
}
goto _again;
f14:
-#line 109 "ext/dtext/dtext.rl"
+#line 110 "ext/dtext/dtext.rl"
{
sm->b2 = sm->p;
}
-#line 335 "ext/dtext/dtext.rl"
+#line 336 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p)+1;{
append(sm, true, "<a href=\"");
append_segment_html_escaped(sm, sm->b1, sm->b2 - 1);
append(sm, true, "\">");
append_segment_html_escaped(sm, sm->a1, sm->a2 - 1);
append(sm, true, "</a>");
}}
goto _again;
f96:
-#line 109 "ext/dtext/dtext.rl"
+#line 110 "ext/dtext/dtext.rl"
{
sm->b2 = sm->p;
}
-#line 182 "ext/dtext/dtext.rl"
+#line 183 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
append(sm, true, "<a href=\"/forum_topics/");
append_segment(sm, true, sm->a1, sm->a2 - 1);
append(sm, true, "?page=");
append_segment(sm, true, sm->b1, sm->b2 - 1);
@@ -4131,15 +4156,15 @@
append_segment(sm, false, sm->b1, sm->b2 - 1);
append(sm, true, "</a>");
}}
goto _again;
f92:
-#line 109 "ext/dtext/dtext.rl"
+#line 110 "ext/dtext/dtext.rl"
{
sm->b2 = sm->p;
}
-#line 249 "ext/dtext/dtext.rl"
+#line 250 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
append(sm, true, "<a href=\"http://www.pixiv.net/member_illust.php?mode=manga_big&illust_id=");
append_segment(sm, true, sm->a1, sm->a2 - 1);
append(sm, true, "&page=");
append_segment(sm, true, sm->b1, sm->b2 - 1);
@@ -4150,15 +4175,15 @@
append_segment(sm, false, sm->b1, sm->b2 - 1);
append(sm, true, "</a>");
}}
goto _again;
f80:
-#line 109 "ext/dtext/dtext.rl"
+#line 110 "ext/dtext/dtext.rl"
{
sm->b2 = sm->p;
}
-#line 312 "ext/dtext/dtext.rl"
+#line 313 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
if (is_boundary_c((*( sm->p)))) {
sm->d = 2;
sm->b = true;
} else {
@@ -4167,11 +4192,11 @@
}
append(sm, true, "<a href=\"");
append_segment_html_escaped(sm, sm->b1, sm->b2 - sm->d);
append(sm, true, "\">");
- link_content_sm = parse_helper(sm->a1, sm->a2 - sm->a1, false, true);
+ link_content_sm = parse_helper(sm->a1, sm->a2 - sm->a1, false, true, false);
append(sm, true, link_content_sm->output->str);
free_machine(link_content_sm);
link_content_sm = NULL;
append(sm, true, "</a>");
@@ -4179,15 +4204,15 @@
append_c_html_escaped(sm, (*( sm->p)));
}
}}
goto _again;
f77:
-#line 109 "ext/dtext/dtext.rl"
+#line 110 "ext/dtext/dtext.rl"
{
sm->b2 = sm->p;
}
-#line 389 "ext/dtext/dtext.rl"
+#line 397 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
g_debug("inline list");
if (dstack_check(sm, BLOCK_LI)) {
g_debug(" rewind li");
@@ -4204,15 +4229,15 @@
{( sm->p) = (( sm->ts + 1))-1;}
sm->cs = 308;
}}
goto _again;
f113:
-#line 109 "ext/dtext/dtext.rl"
+#line 110 "ext/dtext/dtext.rl"
{
sm->b2 = sm->p;
}
-#line 752 "ext/dtext/dtext.rl"
+#line 760 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
int prev_nest = sm->list_nest;
append_closing_p_if(sm);
g_debug("list start");
sm->list_mode = true;
@@ -4259,15 +4284,15 @@
}
{( ((int *)sm->stack->data))[( sm->top)++] = sm->cs; sm->cs = 265; goto _again;}}
}}
goto _again;
f63:
-#line 109 "ext/dtext/dtext.rl"
+#line 110 "ext/dtext/dtext.rl"
{
sm->b2 = sm->p;
}
-#line 990 "ext/dtext/dtext.rl"
+#line 999 "ext/dtext/dtext.rl"
{( sm->te) = ( sm->p);( sm->p)--;{
g_debug("block list");
g_debug(" call list");
sm->list_nest = 0;
sm->list_mode = true;
@@ -4288,71 +4313,71 @@
}}
goto _again;
f15:
#line 1 "NONE"
{( sm->te) = ( sm->p)+1;}
-#line 97 "ext/dtext/dtext.rl"
+#line 98 "ext/dtext/dtext.rl"
{
sm->a1 = sm->p;
}
goto _again;
f83:
#line 1 "NONE"
{( sm->te) = ( sm->p)+1;}
-#line 364 "ext/dtext/dtext.rl"
+#line 365 "ext/dtext/dtext.rl"
{( sm->act) = 18;}
goto _again;
f82:
#line 1 "NONE"
{( sm->te) = ( sm->p)+1;}
-#line 368 "ext/dtext/dtext.rl"
+#line 369 "ext/dtext/dtext.rl"
{( sm->act) = 19;}
goto _again;
f11:
#line 1 "NONE"
{( sm->te) = ( sm->p)+1;}
-#line 600 "ext/dtext/dtext.rl"
+#line 608 "ext/dtext/dtext.rl"
{( sm->act) = 43;}
goto _again;
f74:
#line 1 "NONE"
{( sm->te) = ( sm->p)+1;}
-#line 612 "ext/dtext/dtext.rl"
+#line 620 "ext/dtext/dtext.rl"
{( sm->act) = 44;}
goto _again;
f54:
#line 1 "NONE"
{( sm->te) = ( sm->p)+1;}
-#line 791 "ext/dtext/dtext.rl"
+#line 799 "ext/dtext/dtext.rl"
{( sm->act) = 65;}
goto _again;
f111:
#line 1 "NONE"
{( sm->te) = ( sm->p)+1;}
-#line 797 "ext/dtext/dtext.rl"
+#line 805 "ext/dtext/dtext.rl"
{( sm->act) = 66;}
goto _again;
f1:
#line 1 "NONE"
{( sm->te) = ( sm->p)+1;}
-#line 1006 "ext/dtext/dtext.rl"
+#line 1015 "ext/dtext/dtext.rl"
{( sm->act) = 81;}
goto _again;
f60:
#line 1 "NONE"
{( sm->te) = ( sm->p)+1;}
-#line 1019 "ext/dtext/dtext.rl"
+#line 1028 "ext/dtext/dtext.rl"
{( sm->act) = 82;}
goto _again;
_again:
switch ( _dtext_to_state_actions[ sm->cs] ) {
case 57:
#line 1 "NONE"
{( sm->ts) = 0;}
break;
-#line 4354 "ext/dtext/dtext.c"
+#line 4379 "ext/dtext/dtext.c"
}
if ( ++( sm->p) != ( sm->pe) )
goto _resume;
_test_eof: {}
@@ -4670,11 +4695,11 @@
}
}
}
-#line 1369 "ext/dtext/dtext.rl"
+#line 1380 "ext/dtext/dtext.rl"
dstack_close(sm);
return sm;
}
@@ -4683,15 +4708,17 @@
VALUE input;
VALUE input0;
VALUE options;
VALUE opt_inline;
VALUE opt_strip;
+ VALUE opt_mentions;
VALUE ret;
rb_encoding * encoding = NULL;
StateMachine * sm = NULL;
bool f_strip = false;
bool f_inline = false;
+ bool f_mentions = true;
g_debug("start\n");
if (argc == 0) {
rb_raise(rb_eArgError, "wrong number of arguments (0 for 1)");
@@ -4717,13 +4744,18 @@
opt_inline = rb_hash_aref(options, ID2SYM(rb_intern("inline")));
if (RTEST(opt_inline)) {
f_inline = true;
}
+
+ opt_mentions = rb_hash_aref(options, ID2SYM(rb_intern("disable_mentions")));
+ if (RTEST(opt_mentions)) {
+ f_mentions = false;
+ }
}
}
- sm = parse_helper(RSTRING_PTR(input0), RSTRING_LEN(input0), f_strip, f_inline);
+ sm = parse_helper(RSTRING_PTR(input0), RSTRING_LEN(input0), f_strip, f_inline, f_mentions);
encoding = rb_enc_find("utf-8");
ret = rb_enc_str_new(sm->output->str, sm->output->len, encoding);
free_machine(sm);