dtext_rb 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ext/dtext/dtext.rl CHANGED
@@ -497,43 +497,6 @@ inline := |*
497
497
  }
498
498
  };
499
499
 
500
- # these are block level elements that should kick us out of the inline
501
- # scanner
502
- header => {
503
- dstack_rewind(sm);
504
- fexec sm->a1 - 1;
505
- fret;
506
- };
507
-
508
- header_with_id => {
509
- dstack_rewind(sm);
510
- fexec sm->a1 - 1;
511
- fret;
512
- };
513
-
514
- '[quote]'i => {
515
- g_debug("inline [quote]");
516
- dstack_close_before_block(sm);
517
- fexec sm->ts;
518
- fret;
519
- };
520
-
521
- '[/quote]'i space* => {
522
- g_debug("inline [/quote]");
523
- dstack_close_before_block(sm);
524
-
525
- if (dstack_check(sm, BLOCK_LI)) {
526
- dstack_close_list(sm);
527
- }
528
-
529
- if (dstack_check(sm, BLOCK_QUOTE)) {
530
- dstack_rewind(sm);
531
- fret;
532
- } else {
533
- append_block(sm, "[/quote]");
534
- }
535
- };
536
-
537
500
  spoilers_open => {
538
501
  g_debug("inline [spoiler]");
539
502
  g_debug(" push <span>");
@@ -562,6 +525,38 @@ inline := |*
562
525
  }
563
526
  };
564
527
 
528
+ '[nodtext]'i => {
529
+ dstack_push(sm, &INLINE_NODTEXT);
530
+ g_debug("push inline nodtext");
531
+ fcall nodtext;
532
+ };
533
+
534
+ # these are block level elements that should kick us out of the inline
535
+ # scanner
536
+
537
+ '[quote]'i => {
538
+ g_debug("inline [quote]");
539
+ dstack_close_before_block(sm);
540
+ fexec sm->ts;
541
+ fret;
542
+ };
543
+
544
+ '[/quote]'i space* => {
545
+ g_debug("inline [/quote]");
546
+ dstack_close_before_block(sm);
547
+
548
+ if (dstack_check(sm, BLOCK_LI)) {
549
+ dstack_close_list(sm);
550
+ }
551
+
552
+ if (dstack_check(sm, BLOCK_QUOTE)) {
553
+ dstack_rewind(sm);
554
+ fret;
555
+ } else {
556
+ append_block(sm, "[/quote]");
557
+ }
558
+ };
559
+
565
560
  '[expand]'i => {
566
561
  g_debug("inline [expand]");
567
562
  dstack_rewind(sm);
@@ -581,11 +576,6 @@ inline := |*
581
576
  }
582
577
  };
583
578
 
584
- '[nodtext]'i => {
585
- dstack_push(sm, &INLINE_NODTEXT);
586
- fcall nodtext;
587
- };
588
-
589
579
  '[/th]'i => {
590
580
  if (dstack_check(sm, BLOCK_TH)) {
591
581
  dstack_pop(sm);
@@ -670,14 +660,18 @@ code := |*
670
660
 
671
661
  nodtext := |*
672
662
  '[/nodtext]'i => {
673
- if (dstack_check(sm, BLOCK_NODTEXT)) {
663
+ if (dstack_check2(sm, BLOCK_NODTEXT)) {
664
+ g_debug("block dstack check");
665
+ dstack_pop(sm);
674
666
  dstack_pop(sm);
675
667
  append_block(sm, "</p>");
676
668
  fret;
677
669
  } else if (dstack_check(sm, INLINE_NODTEXT)) {
670
+ g_debug("inline dstack check");
678
671
  dstack_pop(sm);
679
672
  fret;
680
673
  } else {
674
+ g_debug("else dstack check");
681
675
  append(sm, true, "[/nodtext]");
682
676
  }
683
677
  };
@@ -988,6 +982,8 @@ main := |*
988
982
  dstack_close_before_block(sm);
989
983
  dstack_push(sm, &BLOCK_NODTEXT);
990
984
  dstack_push(sm, &BLOCK_P);
985
+ g_debug("push block nodtext");
986
+ g_debug("push block p");
991
987
  append_block(sm, "<p>");
992
988
  fcall nodtext;
993
989
  };
data/test/dtext_test.rb CHANGED
@@ -97,6 +97,10 @@ class DTextTest < Minitest::Test
97
97
  assert_parse("<ul><li>a</li></ul><h1>header</h1><ul><li>list</li></ul>", "* a\n\nh1. header\n* list")
98
98
  end
99
99
 
100
+ def test_inline_headers
101
+ assert_parse("<p>blah h1. blah</p>", "blah h1. blah")
102
+ end
103
+
100
104
  def test_headers_with_ids
101
105
  assert_parse("<h1 id=\"dtext-blah-blah\">header</h1>", "h1#blah-blah. header")
102
106
  end
@@ -281,4 +285,10 @@ class DTextTest < Minitest::Test
281
285
  assert_parse('<p><a href="/posts?tags=approver:葉月">7893</a></p>', '"7893":[/posts?tags=approver:葉月]')
282
286
  assert_parse('<p><a href="http://danbooru.donmai.us/posts?tags=approver:葉月">http://danbooru.donmai.us/posts?tags=approver:葉月</a></p>', 'http://danbooru.donmai.us/posts?tags=approver:葉月')
283
287
  end
288
+
289
+ def test_nodtext
290
+ assert_parse('<p>[b]not bold[/b]</p><p> <strong>bold</strong></p>', "[nodtext][b]not bold[/b][/nodtext] [b]bold[/b]")
291
+ assert_parse('<p>[b]not bold[/b]</p><p><strong>hello</strong></p>', "[nodtext][b]not bold[/b][/nodtext]\n\n[b]hello[/b]")
292
+ assert_parse('<p> [b]not bold[/b]</p>', " [nodtext][b]not bold[/b][/nodtext]")
293
+ end
284
294
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtext_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - r888888888
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-13 00:00:00.000000000 Z
11
+ date: 2017-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest