markly 0.18.1 → 0.19.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ef6552d303ea4620a87168fb130a802de075b747bcc737986b86083e46825bc
4
- data.tar.gz: 1f9ac70b49a3170929bf56cfae562214b86fc59d58d3a07d42c14f74fbcd47c0
3
+ metadata.gz: e8acce4b2ae6c9e79d70bb21548ece0ec72bf0ef3e7cd77aaae270cc408daa2c
4
+ data.tar.gz: d48929fd7d802c68ad1ef18bb186f3f3b349d147be7b9c64dddb853f361eedac
5
5
  SHA512:
6
- metadata.gz: 7f3f69c8c4844f3c28621c6e301d4785c342d9660d305fc8f0452764e72784257f0a76ec608e5c0375171cf18455a46f0a6729e898eb805645ba8bea7c8f1ac3
7
- data.tar.gz: 6c4c3505f5e0b47c927dd405d20e44b4c10043e6e2657b6ec12cbd7f02f8efaa56723f885bfa3daa33052e32e6d1e24a238d1fb7dec49e227ac9802ca54ec76f
6
+ metadata.gz: e7f9545009613d2e140762a337babf3ddcac13520b585d8fa07ec4ab6c90a7248a4be8df2998afbdb9a4428c315bc969426f05d521219aba671dca05371f1e1c
7
+ data.tar.gz: 460d177e3361f7416b7d20ab48e900f9635c83c48c132bf489a025a50bfd532c678e0b9e7467d1e7441ef362030e0c96bd5f13a8e1c0d39f9746cd096934c4e8
checksums.yaml.gz.sig CHANGED
Binary file
data/ext/markly/blocks.c CHANGED
@@ -91,8 +91,8 @@ static CMARK_INLINE bool S_ends_on_current_line(cmark_parser *parser, cmark_node
91
91
  // similar to fenced code blocks.
92
92
  // Types 6-7 end at a blank line, so their last content line is
93
93
  // the previous line and they should NOT match here.
94
- (S_type(b) == CMARK_NODE_HTML_BLOCK && b->as.html_block_type >= 1 &&
95
- b->as.html_block_type <= 5) ||
94
+ (S_type(b) == CMARK_NODE_HTML_BLOCK && b->as.html_block.type >= 1 &&
95
+ b->as.html_block.type <= 5) ||
96
96
  // Single-line blocks: finalized on same line they started
97
97
  b->start_line == parser->line_number;
98
98
  }
@@ -1037,7 +1037,7 @@ static bool parse_code_block_prefix(cmark_parser *parser, cmark_chunk *input,
1037
1037
  static bool parse_html_block_prefix(cmark_parser *parser,
1038
1038
  cmark_node *container) {
1039
1039
  bool res = false;
1040
- int html_block_type = container->as.html_block_type;
1040
+ int html_block_type = container->as.html_block.type;
1041
1041
 
1042
1042
  assert(html_block_type >= 1 && html_block_type <= 7);
1043
1043
  switch (html_block_type) {
@@ -1051,7 +1051,32 @@ static bool parse_html_block_prefix(cmark_parser *parser,
1051
1051
  break;
1052
1052
  case 6:
1053
1053
  case 7:
1054
- res = !parser->blank;
1054
+ if (!(parser->options & CMARK_OPT_HTML_BLOCK_BLANK_LINES)) {
1055
+ res = !parser->blank;
1056
+ } else if (parser->blank) {
1057
+ // Tentatively retain blank lines. The next nonblank line determines
1058
+ // whether the HTML block continues:
1059
+ res = true;
1060
+ } else if (S_last_line_blank(container)) {
1061
+ // Establish the content indentation lazily so a blank line may follow
1062
+ // the opening tag. A non-indented line still terminates the block:
1063
+ if (container->as.html_block.indent == 0 && parser->indent > 0) {
1064
+ container->as.html_block.indent = parser->indent;
1065
+ }
1066
+
1067
+ res = container->as.html_block.indent > 0 &&
1068
+ parser->indent >= container->as.html_block.indent;
1069
+ } else {
1070
+ // Record the shallowest positive content indentation before a blank
1071
+ // line. Deeper nested HTML may then continue without changing it:
1072
+ if (parser->indent > 0 &&
1073
+ (container->as.html_block.indent == 0 ||
1074
+ parser->indent < container->as.html_block.indent)) {
1075
+ container->as.html_block.indent = parser->indent;
1076
+ }
1077
+
1078
+ res = true;
1079
+ }
1055
1080
  break;
1056
1081
  }
1057
1082
 
@@ -1224,7 +1249,7 @@ static void open_new_blocks(cmark_parser *parser, cmark_node **container,
1224
1249
  input, parser->first_nonspace))))) {
1225
1250
  *container = add_child(parser, *container, CMARK_NODE_HTML_BLOCK,
1226
1251
  parser->first_nonspace + 1);
1227
- (*container)->as.html_block_type = matched;
1252
+ (*container)->as.html_block.type = matched;
1228
1253
  // note, we don't adjust parser->offset because the tag is part of the
1229
1254
  // text
1230
1255
  } else if (!indented && cont_type == CMARK_NODE_PARAGRAPH &&
@@ -1421,7 +1446,7 @@ static void add_text_to_container(cmark_parser *parser, cmark_node *container,
1421
1446
  add_line(container, input, parser);
1422
1447
 
1423
1448
  int matches_end_condition;
1424
- switch (container->as.html_block_type) {
1449
+ switch (container->as.html_block.type) {
1425
1450
  case 1:
1426
1451
  // </script>, </style>, </pre>
1427
1452
  matches_end_condition =
@@ -798,6 +798,12 @@ char *cmark_render_latex_with_mem(cmark_node *root, int options, int width, cmar
798
798
  */
799
799
  #define CMARK_OPT_INLINE_CODE_INFO (1 << 19)
800
800
 
801
+ /** Allow indented content in type 6 and 7 HTML blocks to continue across
802
+ * blank lines. The indentation established by the HTML content must be
803
+ * preserved after each blank line.
804
+ */
805
+ #define CMARK_OPT_HTML_BLOCK_BLANK_LINES (1 << 20)
806
+
801
807
  /**
802
808
  * ## Version information
803
809
  */
data/ext/markly/node.h CHANGED
@@ -33,6 +33,11 @@ typedef struct {
33
33
  int8_t fenced;
34
34
  } cmark_code;
35
35
 
36
+ typedef struct {
37
+ int type;
38
+ int indent;
39
+ } cmark_html_block;
40
+
36
41
  typedef struct {
37
42
  int level;
38
43
  bool setext;
@@ -104,7 +109,7 @@ struct cmark_node {
104
109
  cmark_heading heading;
105
110
  cmark_link link;
106
111
  cmark_custom custom;
107
- int html_block_type;
112
+ cmark_html_block html_block;
108
113
  int cell_index; // For keeping track of TABLE_CELL table alignments
109
114
  void *opaque;
110
115
  } as;
data/lib/markly/flags.rb CHANGED
@@ -25,10 +25,13 @@ module Markly
25
25
  FRONT_MATTER = 1 << 18
26
26
  # Parse language prefixes on inline code spans, e.g. ruby:`Object.new`.
27
27
  INLINE_CODE_INFO = 1 << 19
28
+ # Allow consistently indented HTML content to continue across blank lines.
29
+ HTML_BLOCK_BLANK_LINES = 1 << 20
28
30
 
29
31
  PARSE_FLAGS = {
30
32
  front_matter: FRONT_MATTER,
31
33
  inline_code_info: INLINE_CODE_INFO,
34
+ html_block_blank_lines: HTML_BLOCK_BLANK_LINES,
32
35
  validate_utf8: VALIDATE_UTF8,
33
36
  smart_quotes: SMART,
34
37
  liberal_html_tags: LIBERAL_HTML_TAG,
@@ -9,5 +9,5 @@
9
9
  # @namespace
10
10
  module Markly
11
11
  # @constant [String] The version of the Markly gem.
12
- VERSION = "0.18.1"
12
+ VERSION = "0.19.0"
13
13
  end
data/readme.md CHANGED
@@ -26,6 +26,10 @@ Please see the [project documentation](https://socketry.github.io/markly/) for m
26
26
 
27
27
  Please see the [project releases](https://socketry.github.io/markly/releases/index) for all releases.
28
28
 
29
+ ### v0.19.0
30
+
31
+ - Add `Markly::HTML_BLOCK_BLANK_LINES` for keeping consistently indented HTML content together across blank lines.
32
+
29
33
  ### v0.18.0
30
34
 
31
35
  - Preserve complete node and extension metadata when duplicating node trees.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.19.0
4
+
5
+ - Add `Markly::HTML_BLOCK_BLANK_LINES` for keeping consistently indented HTML content together across blank lines.
6
+
3
7
  ## v0.18.0
4
8
 
5
9
  - Preserve complete node and extension metadata when duplicating node trees.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.1
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
metadata.gz.sig CHANGED
@@ -1,4 +1,4 @@
1
- Z6mDo}�v�3Ⱥ&���w��Y|h�@3��g�`���ɬ
2
- �姑�:��$�OU
3
- �F>
4
- ���L�U\�i<�c�?;3����L8�e?B������K���GO��*YgE=�M�O��i4� �II��q�EJz�#d�(Ex.� 鑟HZׇ~�^����O�"8�,}���jY�'���B�M��{z���]��\s��ɴ`�ۣo؛$�ۦ2n͐| SAhr&d���C�ÿ;G!��"�a߅���p����)�J`���e�#n����V�%�Ҕ�'��|�/+1w���� s�#��YY</a�0�H.E�8 u��4��džع;�&:�\�_4b��u�U� ��2�ۅ�Ck��p�֯1�:���
1
+ �����֨K���tA�����j���ۚ�����sL'�R���&�%�_�]_f���I�|� y�g�Ǚ��� �MN2!�Q��/R~�J��,FV�HJn߉%�j�����^��k�*��h(9.򟇬-dw�r�9E�=���n�����+��ǎ������9Fr�� %��1�Iv
2
+ [/˔H��� =��j#�~<�����
3
+ S8��,_����y��g~��Q�
4
+ ��8�JAgK7|ʠ���ݹ���