Skip to content

Commit

Permalink
Merge branch 'main' into @Skalakid/web-parser-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Skalakid committed Jul 5, 2024
2 parents 8c85473 + 5d4e106 commit 401febe
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ public void applyMarkdownFormatting(SpannableStringBuilder ssb) {
int length = range.getInt("length");
int depth = range.optInt("depth", 1);
int end = start + length;
if (length == 0 || end > input.length()) {
continue;
}
applyRange(ssb, type, start, end, depth);
}
} catch (JSONException e) {
Expand Down
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1053,13 +1053,13 @@ PODS:
- React-jsi (= 0.73.4)
- React-logger (= 0.73.4)
- React-perflogger (= 0.73.4)
- RNLiveMarkdown (0.1.92):
- RNLiveMarkdown (0.1.96):
- glog
- hermes-engine
- RCT-Folly (= 2022.05.16.00)
- React-Core
- RNLiveMarkdown/common (= 0.1.92)
- RNLiveMarkdown/common (0.1.92):
- RNLiveMarkdown/common (= 0.1.96)
- RNLiveMarkdown/common (0.1.96):
- glog
- hermes-engine
- RCT-Folly (= 2022.05.16.00)
Expand Down Expand Up @@ -1278,7 +1278,7 @@ SPEC CHECKSUMS:
React-runtimescheduler: ed48e5faac6751e66ee1261c4bd01643b436f112
React-utils: 6e5ad394416482ae21831050928ae27348f83487
ReactCommon: 840a955d37b7f3358554d819446bffcf624b2522
RNLiveMarkdown: c04da6410e95af38ccb615b8de8bb4eefc9f6e2c
RNLiveMarkdown: ffa97e63f100bd32fad2f6f3b689031188761578
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70

Expand Down
4 changes: 4 additions & 0 deletions ios/RCTMarkdownUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ - (NSAttributedString *)parseMarkdown:(nullable NSAttributedString *)input withA
const auto &length = static_cast<int>(item.getProperty(rt, "length").asNumber());
const auto &depth = item.hasProperty(rt, "depth") ? static_cast<int>(item.getProperty(rt, "depth").asNumber()) : 1;

if (length == 0 || location + length > attributedString.length) {
continue;
}

NSRange range = NSMakeRange(location, length);

if (type == "bold" || type == "italic" || type == "code" || type == "pre" || type == "h1" || type == "emoji") {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@expensify/react-native-live-markdown",
"version": "0.1.96",
"version": "0.1.99",
"description": "Drop-in replacement for React Native's TextInput component with Markdown formatting.",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
2 changes: 1 addition & 1 deletion parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function parseTreeToTextAndRanges(tree: StackItem): [string, Range[]] {
} else if (node.tag.startsWith('<pre')) {
appendSyntax('```');
const content = node.children.join('').replaceAll('&#32;', ' ');
addChildrenWithStyle(`\n${content}`, 'pre');
addChildrenWithStyle(content, 'pre');
appendSyntax('```');
} else if (node.tag.startsWith('<a href="')) {
const rawHref = node.tag.match(/href="([^"]*)"/)![1]!; // always present
Expand Down
2 changes: 1 addition & 1 deletion parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"typescript": "^5.3.3"
},
"dependencies": {
"expensify-common": "2.0.23"
"expensify-common": "2.0.35"
}
}
33 changes: 16 additions & 17 deletions parser/react-native-live-markdown-parser.js

Large diffs are not rendered by default.

22 changes: 10 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2647,7 +2647,7 @@ __metadata:
"@types/underscore": ^1.11.15
esbuild: 0.19.4
esbuild-plugin-tsc: ^0.4.0
expensify-common: 2.0.23
expensify-common: 2.0.35
jest: ^29.7.0
typescript: ^5.3.3
languageName: unknown
Expand Down Expand Up @@ -9967,9 +9967,9 @@ __metadata:
languageName: node
linkType: hard

"expensify-common@npm:2.0.23":
version: 2.0.23
resolution: "expensify-common@npm:2.0.23"
"expensify-common@npm:2.0.35":
version: 2.0.35
resolution: "expensify-common@npm:2.0.35"
dependencies:
awesome-phonenumber: ^5.4.0
classnames: 2.5.0
Expand All @@ -9981,10 +9981,10 @@ __metadata:
prop-types: 15.8.1
react: 16.12.0
react-dom: 16.12.0
semver: ^7.6.0
semver: ^7.6.2
simply-deferred: "git+https://github.com/Expensify/simply-deferred.git#77a08a95754660c7bd6e0b6979fdf84e8e831bf5"
ua-parser-js: ^1.0.37
checksum: 5be467bc68cbd93bccde8803c25184d2d4a76fa000fb29e919bcb64661866601e0ee81d1731220422cfe705e6688b151a9da968da7bdd369a1d46ae48b33702f
checksum: eeceea5fc03849c95af12c04a29c5c97a89a61e4714cdfc401ea5f15e8a4284557c5b77e5cbb77c0f0905a6e9d608f3b4e079ba310f32188a0ff4d2ad356a5b5
languageName: node
linkType: hard

Expand Down Expand Up @@ -18087,14 +18087,12 @@ __metadata:
languageName: node
linkType: hard

"semver@npm:^7.6.0":
version: 7.6.0
resolution: "semver@npm:7.6.0"
dependencies:
lru-cache: ^6.0.0
"semver@npm:^7.6.2":
version: 7.6.2
resolution: "semver@npm:7.6.2"
bin:
semver: bin/semver.js
checksum: 7427f05b70786c696640edc29fdd4bc33b2acf3bbe1740b955029044f80575fc664e1a512e4113c3af21e767154a94b4aa214bf6cd6e42a1f6dba5914e0b208c
checksum: 40f6a95101e8d854357a644da1b8dd9d93ce786d5c6a77227bc69dbb17bea83d0d1d1d7c4cd5920a6df909f48e8bd8a5909869535007f90278289f2451d0292d
languageName: node
linkType: hard

Expand Down

0 comments on commit 401febe

Please sign in to comment.