react-native-jet-markdown 0.2.3-beta.0 → 0.2.3-beta.1

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.
@@ -278,8 +278,8 @@ void superscriptPass(Node* parent, AstArena& arena) {
278
278
  }
279
279
 
280
280
  void process(Node* node, AstArena& arena) {
281
- if (node->type == NodeType::Link || node->type == NodeType::CodeBlock ||
282
- node->type == NodeType::InlineCode || node->type == NodeType::Image) {
281
+ if (node->type == NodeType::CodeBlock || node->type == NodeType::InlineCode ||
282
+ node->type == NodeType::Image) {
283
283
  return;
284
284
  }
285
285
  if (!node->children.empty()) {
@@ -319,6 +319,11 @@ int onEnterSpan(MD_SPANTYPE type, void* detail, void* userdata) {
319
319
  auto* d = static_cast<MD_SPAN_A_DETAIL*>(detail);
320
320
  Node* node = state->push(NodeType::Link);
321
321
  node->url = attributeToString(d->href);
322
+ // md4c (patched) lets Reddit-style spaces through in destinations;
323
+ // encode them so the URL is openable as-is.
324
+ for (size_t i = 0; (i = node->url.find(' ', i)) != std::string::npos; i += 3) {
325
+ node->url.replace(i, 1, "%20");
326
+ }
322
327
  break;
323
328
  }
324
329
  case MD_SPAN_IMG: {
@@ -443,7 +448,8 @@ std::unique_ptr<MarkdownDocument> parseMarkdown(const std::string& markdown) {
443
448
 
444
449
  MD_PARSER parser = {};
445
450
  parser.abi_version = 0;
446
- parser.flags = MD_FLAG_TABLES | MD_FLAG_PERMISSIVEAUTOLINKS | MD_FLAG_NOHTML;
451
+ parser.flags = MD_FLAG_TABLES | MD_FLAG_PERMISSIVEAUTOLINKS | MD_FLAG_NOHTML |
452
+ MD_FLAG_PERMISSIVEATXHEADERS; // Reddit accepts "###Heading"
447
453
  parser.enter_block = onEnterBlock;
448
454
  parser.leave_block = onLeaveBlock;
449
455
  parser.enter_span = onEnterSpan;
package/cpp/md4c/md4c.c CHANGED
@@ -2055,9 +2055,22 @@ md_is_link_destination_B(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end,
2055
2055
  continue;
2056
2056
  }
2057
2057
 
2058
- if(ISWHITESPACE(off) || ISCNTRL(off))
2058
+ if(ISCNTRL(off))
2059
2059
  break;
2060
2060
 
2061
+ /* JETMARKDOWN PATCH: Reddit (snudown) allows spaces inside link
2062
+ * destinations. Whitespace ends the destination only when what
2063
+ * follows is a title opener, the closing ')' or the end. */
2064
+ if(ISWHITESPACE(off)) {
2065
+ OFF tmp = off;
2066
+ while(tmp < max_end && ISWHITESPACE(tmp))
2067
+ tmp++;
2068
+ if(tmp >= max_end || ISANYOF(tmp, _T("\"')")))
2069
+ break;
2070
+ off = tmp;
2071
+ continue;
2072
+ }
2073
+
2061
2074
  /* Link destination may include balanced pairs of unescaped '(' ')'.
2062
2075
  * Note we limit the maximal nesting level by 32 to protect us from
2063
2076
  * https://github.com/jgm/cmark/issues/214 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-jet-markdown",
3
- "version": "0.2.3-beta.0",
3
+ "version": "0.2.3-beta.1",
4
4
  "description": "High-performance native Markdown renderer for React Native",
5
5
  "keywords": [
6
6
  "react-native",