dtext_rb 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,6 +3,7 @@
3
3
  #define PRETTY_PRINT 0
4
4
 
5
5
  #include <ruby.h>
6
+ #include <ruby/encoding.h>
6
7
  #include <stdio.h>
7
8
  #include <stdint.h>
8
9
  #include <stdbool.h>
@@ -388,6 +389,9 @@ inline := |*
388
389
  } else if (dstack_check(sm, BLOCK_P)) {
389
390
  g_debug(" rewind p");
390
391
  dstack_rewind(sm);
392
+ } else if (sm->header_mode) {
393
+ g_debug(" rewind header");
394
+ dstack_rewind(sm);
391
395
  }
392
396
 
393
397
  g_debug(" next list");
@@ -587,7 +591,6 @@ inline := |*
587
591
 
588
592
  if (sm->list_mode) {
589
593
  dstack_close_list(sm);
590
- sm->list_mode = false;
591
594
  }
592
595
 
593
596
  fexec sm->ts;
@@ -884,7 +887,7 @@ main := |*
884
887
  dstack_push(sm, &BLOCK_EXPAND);
885
888
  append_block(sm, "<div class=\"expandable\"><div class=\"expandable-header\">");
886
889
  append(sm, true, "<span>");
887
- append_segment_html_escaped(sm, sm->a1, sm->a2 - 2);
890
+ append_segment_html_escaped(sm, sm->a1, sm->a2 - 1);
888
891
  append(sm, true, "</span>");
889
892
  append_block(sm, "<input type=\"button\" value=\"Show\" class=\"expandable-button\"/></div>");
890
893
  append_block(sm, "<div class=\"expandable-content\">");
@@ -934,6 +937,8 @@ main := |*
934
937
  if (sm->header_mode) {
935
938
  sm->header_mode = false;
936
939
  dstack_rewind(sm);
940
+ } else if (sm->list_mode) {
941
+ dstack_close_list(sm);
937
942
  } else {
938
943
  dstack_close_before_block(sm);
939
944
  }
@@ -1211,6 +1216,9 @@ static void dstack_close_list(StateMachine * sm) {
1211
1216
  while (dstack_check(sm, BLOCK_LI) || dstack_check(sm, BLOCK_UL)) {
1212
1217
  dstack_rewind(sm);
1213
1218
  }
1219
+
1220
+ sm->list_mode = false;
1221
+ sm->list_nest = 0;
1214
1222
  }
1215
1223
 
1216
1224
  static inline bool is_boundary_c(char c) {
@@ -1280,6 +1288,7 @@ static VALUE parse(int argc, VALUE * argv, VALUE self) {
1280
1288
  VALUE opt_inline;
1281
1289
  VALUE opt_strip;
1282
1290
  VALUE ret;
1291
+ rb_encoding * encoding = NULL;
1283
1292
  StateMachine * sm = NULL;
1284
1293
 
1285
1294
  g_debug("start\n");
@@ -1315,7 +1324,8 @@ static VALUE parse(int argc, VALUE * argv, VALUE self) {
1315
1324
 
1316
1325
  dstack_close(sm);
1317
1326
 
1318
- ret = rb_str_new(sm->output->str, sm->output->len);
1327
+ encoding = rb_enc_find("utf-8");
1328
+ ret = rb_enc_str_new(sm->output->str, sm->output->len, encoding);
1319
1329
 
1320
1330
  free_machine(sm);
1321
1331
 
@@ -75,6 +75,7 @@ class DTextTest < Minitest::Test
75
75
 
76
76
  def test_headers
77
77
  assert_parse("<h1>header</h1>", "h1. header")
78
+ assert_parse("<ul><li>a</li></ul><h1>header</h1><ul><li>list</li></ul>", "* a\n\nh1. header\n* list")
78
79
  end
79
80
 
80
81
  def test_quote_blocks
@@ -1,4 +1,4 @@
1
- Dir["/dev_exclusions/dtext_bench/wiki_pages/*.txt"].sort.slice(20, 10).each do |file|
1
+ Dir["/dev_exclusions/dtext_bench/wiki_pages/*.txt"].sort.slice(30, 10).each do |file|
2
2
  input = File.read(file)
3
3
  o1 = DTextRagel.parse(input.dup).gsub(/\s+<\/p>/, "</p>")
4
4
  o2 = DTextRuby.parse(input.dup).gsub(/\r/, "").gsub(/\s+<\/p>/, "</p>")
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.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - r888888888
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-25 00:00:00.000000000 Z
11
+ date: 2016-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest