Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): stop striking through ~$ prices and ~/ paths, match web behavior #18156

Closedahalekelly(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/18156/headopened View on GitHub

Showing 2 changed files with 30 additions and 3 deletions.

x
0 of 2 viewed, 2 left
30 additions and 3 deletionspatches/react-native-nitro-markdown@0.5.8.patchModified
View file
@@ -1,7 +1,34 @@
diff --git a/cpp/md4c/md4c.c b/cpp/md4c/md4c.c
--- a/cpp/md4c/md4c.c
+++ b/cpp/md4c/md4c.c
-@@ -3908,10 +3908,10 @@
+@@ -3308,10 +3308,22 @@ md_collect_marks(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, int table_m
+ if(tmp - off <= 2) {
+ unsigned flags = MD_MARK_POTENTIAL_OPENER | MD_MARK_POTENTIAL_CLOSER;
+
+- if(off > line->beg && !ISUNICODEWHITESPACEBEFORE(off) && !ISUNICODEPUNCTBEFORE(off))
+- flags &= ~MD_MARK_POTENTIAL_OPENER;
+- if(tmp < line->end && !ISUNICODEWHITESPACE(tmp) && !ISUNICODEPUNCT(tmp))
+- flags &= ~MD_MARK_POTENTIAL_CLOSER;
++ if(ch == _T('~')) {
++ /* Flank tildes like emphasis delimiters, as micromark
++ * (remark-gfm) does, so mobile strikes what web strikes. */
++ int left_level = (off == line->beg || ISUNICODEWHITESPACEBEFORE(off)) ? 0 : (ISUNICODEPUNCTBEFORE(off) ? 1 : 2);
++ int right_level = (tmp == line->end || ISUNICODEWHITESPACE(tmp)) ? 0 : (ISUNICODEPUNCT(tmp) ? 1 : 2);
++
++ if(left_level == 0 || left_level < right_level)
++ flags &= ~MD_MARK_POTENTIAL_CLOSER;
++ if(right_level == 0 || right_level < left_level)
++ flags &= ~MD_MARK_POTENTIAL_OPENER;
++ } else {
++ if(off > line->beg && !ISUNICODEWHITESPACEBEFORE(off) && !ISUNICODEPUNCTBEFORE(off))
++ flags &= ~MD_MARK_POTENTIAL_OPENER;
++ if(tmp < line->end && !ISUNICODEWHITESPACE(tmp) && !ISUNICODEPUNCT(tmp))
++ flags &= ~MD_MARK_POTENTIAL_CLOSER;
++ }
+ if(flags != 0)
+ ADD_MARK(ch, off, tmp, flags);