react-native-enriched-markdown 0.4.0 → 0.4.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.
Files changed (45) hide show
  1. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java +1 -0
  2. package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerDelegate.java +1 -0
  3. package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +55 -0
  4. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +1 -1
  5. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +1 -1
  6. package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +1 -1
  7. package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +3 -3
  8. package/android/src/main/java/com/swmansion/enriched/markdown/parser/Parser.kt +1 -1
  9. package/android/src/main/java/com/swmansion/enriched/markdown/renderer/NodeRenderer.kt +1 -1
  10. package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/FeatureFlags.kt +1 -1
  11. package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/extensions/SpannableExtensions.kt +1 -1
  12. package/app.plugin.js +1 -0
  13. package/cpp/parser/MD4CParser.cpp +34 -7
  14. package/ios/EnrichedMarkdown.mm +85 -19
  15. package/ios/EnrichedMarkdownText.mm +74 -15
  16. package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/Props.h +55 -0
  17. package/ios/internals/EnrichedMarkdownShadowNode.mm +16 -2
  18. package/ios/internals/EnrichedMarkdownTextShadowNode.mm +16 -2
  19. package/ios/utils/StylePropsUtils.h +6 -3
  20. package/lib/module/plugin/withAndroidMath.js +23 -0
  21. package/lib/module/plugin/withAndroidMath.js.map +1 -0
  22. package/lib/module/plugin/withIosMath.js +26 -0
  23. package/lib/module/plugin/withIosMath.js.map +1 -0
  24. package/lib/module/plugin/withReactNativeEnrichedMarkdown.js +16 -0
  25. package/lib/module/plugin/withReactNativeEnrichedMarkdown.js.map +1 -0
  26. package/lib/typescript/src/plugin/withAndroidMath.d.ts +5 -0
  27. package/lib/typescript/src/plugin/withAndroidMath.d.ts.map +1 -0
  28. package/lib/typescript/src/plugin/withIosMath.d.ts +5 -0
  29. package/lib/typescript/src/plugin/withIosMath.d.ts.map +1 -0
  30. package/lib/typescript/src/plugin/withReactNativeEnrichedMarkdown.d.ts +6 -0
  31. package/lib/typescript/src/plugin/withReactNativeEnrichedMarkdown.d.ts.map +1 -0
  32. package/package.json +28 -13
  33. package/src/plugin/withAndroidMath.ts +26 -0
  34. package/src/plugin/withIosMath.ts +37 -0
  35. package/src/plugin/withReactNativeEnrichedMarkdown.ts +17 -0
  36. /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/ComponentDescriptors.cpp +0 -0
  37. /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/ComponentDescriptors.h +0 -0
  38. /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/EventEmitters.cpp +0 -0
  39. /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/EventEmitters.h +0 -0
  40. /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/Props.cpp +0 -0
  41. /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/RCTComponentViewHelpers.h +0 -0
  42. /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/ShadowNodes.cpp +0 -0
  43. /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/ShadowNodes.h +0 -0
  44. /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/States.cpp +0 -0
  45. /package/ios/generated/{EnrichedMarkdownTextSpec → ReactCodegen/EnrichedMarkdownTextSpec}/States.h +0 -0
@@ -63,7 +63,13 @@ Size EnrichedMarkdownShadowNode::measureContent(const LayoutContext &layoutConte
63
63
  auto cacheKey = buildMeasurementCacheKey(typedProps, maxWidth, fontScale, MarkdownFlavor::GitHub);
64
64
  CachedSize cached;
65
65
  if (MeasurementCache::shared().get(cacheKey, cached)) {
66
- return {cached.width, std::min(cached.height, (CGFloat)maxHeight)};
66
+ Float cachedWidth = std::max(cached.width, layoutConstraints.minimumSize.width);
67
+ cachedWidth = std::min(cachedWidth, layoutConstraints.maximumSize.width);
68
+ Float cachedHeight = std::max(cached.height, layoutConstraints.minimumSize.height);
69
+ if (std::isfinite(layoutConstraints.maximumSize.height)) {
70
+ cachedHeight = std::min(cachedHeight, layoutConstraints.maximumSize.height);
71
+ }
72
+ return {cachedWidth, cachedHeight};
67
73
  }
68
74
  }
69
75
 
@@ -95,7 +101,15 @@ Size EnrichedMarkdownShadowNode::measureContent(const LayoutContext &layoutConte
95
101
  MeasurementCache::shared().set(cacheKey, {size.width, size.height});
96
102
  }
97
103
 
98
- return {size.width, MIN(size.height, maxHeight)};
104
+ Float clampedWidth = size.width;
105
+ Float clampedHeight = size.height;
106
+ clampedWidth = std::max(clampedWidth, layoutConstraints.minimumSize.width);
107
+ clampedWidth = std::min(clampedWidth, layoutConstraints.maximumSize.width);
108
+ clampedHeight = std::max(clampedHeight, layoutConstraints.minimumSize.height);
109
+ if (std::isfinite(layoutConstraints.maximumSize.height)) {
110
+ clampedHeight = std::min(clampedHeight, layoutConstraints.maximumSize.height);
111
+ }
112
+ return {clampedWidth, clampedHeight};
99
113
  }
100
114
 
101
115
  } // namespace facebook::react
@@ -66,7 +66,13 @@ Size EnrichedMarkdownTextShadowNode::measureContent(const LayoutContext &layoutC
66
66
  auto cacheKey = buildMeasurementCacheKey(typedProps, maxWidth, fontScale, MarkdownFlavor::CommonMark);
67
67
  CachedSize cached;
68
68
  if (MeasurementCache::shared().get(cacheKey, cached)) {
69
- return {cached.width, std::min(cached.height, (CGFloat)maxHeight)};
69
+ Float cachedWidth = std::max(cached.width, layoutConstraints.minimumSize.width);
70
+ cachedWidth = std::min(cachedWidth, layoutConstraints.maximumSize.width);
71
+ Float cachedHeight = std::max(cached.height, layoutConstraints.minimumSize.height);
72
+ if (std::isfinite(layoutConstraints.maximumSize.height)) {
73
+ cachedHeight = std::min(cachedHeight, layoutConstraints.maximumSize.height);
74
+ }
75
+ return {cachedWidth, cachedHeight};
70
76
  }
71
77
  }
72
78
 
@@ -98,7 +104,15 @@ Size EnrichedMarkdownTextShadowNode::measureContent(const LayoutContext &layoutC
98
104
  MeasurementCache::shared().set(cacheKey, {size.width, size.height});
99
105
  }
100
106
 
101
- return {size.width, MIN(size.height, maxHeight)};
107
+ Float clampedWidth = size.width;
108
+ Float clampedHeight = size.height;
109
+ clampedWidth = std::max(clampedWidth, layoutConstraints.minimumSize.width);
110
+ clampedWidth = std::min(clampedWidth, layoutConstraints.maximumSize.width);
111
+ clampedHeight = std::max(clampedHeight, layoutConstraints.minimumSize.height);
112
+ if (std::isfinite(layoutConstraints.maximumSize.height)) {
113
+ clampedHeight = std::min(clampedHeight, layoutConstraints.maximumSize.height);
114
+ }
115
+ return {clampedWidth, clampedHeight};
102
116
  }
103
117
 
104
118
  } // namespace facebook::react
@@ -497,9 +497,12 @@ BOOL applyMarkdownStyleToConfig(StyleConfig *config, const MarkdownStyle &newSty
497
497
  changed = YES;
498
498
  }
499
499
 
500
- if (newStyle.link.underline != oldStyle.link.underline) {
501
- [config setLinkUnderline:newStyle.link.underline];
502
- changed = YES;
500
+ {
501
+ BOOL newUnderline = newStyle.link.underline ? YES : NO;
502
+ if (newStyle.link.underline != oldStyle.link.underline || [config linkUnderline] != newUnderline) {
503
+ [config setLinkUnderline:newUnderline];
504
+ changed = YES;
505
+ }
503
506
  }
504
507
 
505
508
  // ── Strong ─────────────────────────────────────────────────────────────────
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ import configPlugins from '@expo/config-plugins';
4
+ const {
5
+ withGradleProperties
6
+ } = configPlugins;
7
+ export const withAndroidMath = (config, {
8
+ enableMath = true
9
+ }) => {
10
+ if (enableMath) {
11
+ return config;
12
+ }
13
+ return withGradleProperties(config, gradleConfig => {
14
+ gradleConfig.modResults = gradleConfig.modResults.filter(prop => prop.type !== 'property' || prop.key !== 'enrichedMarkdown.enableMath');
15
+ gradleConfig.modResults.push({
16
+ type: 'property',
17
+ key: 'enrichedMarkdown.enableMath',
18
+ value: 'false'
19
+ });
20
+ return gradleConfig;
21
+ });
22
+ };
23
+ //# sourceMappingURL=withAndroidMath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["configPlugins","withGradleProperties","withAndroidMath","config","enableMath","gradleConfig","modResults","filter","prop","type","key","push","value"],"sourceRoot":"../../../src","sources":["plugin/withAndroidMath.ts"],"mappings":";;AAAA,OAAOA,aAAa,MAA6B,sBAAsB;AAEvE,MAAM;EAAEC;AAAqB,CAAC,GAAGD,aAAa;AAE9C,OAAO,MAAME,eAAuD,GAAGA,CACrEC,MAAM,EACN;EAAEC,UAAU,GAAG;AAAK,CAAC,KAClB;EACH,IAAIA,UAAU,EAAE;IACd,OAAOD,MAAM;EACf;EACA,OAAOF,oBAAoB,CAACE,MAAM,EAAGE,YAAY,IAAK;IACpDA,YAAY,CAACC,UAAU,GAAGD,YAAY,CAACC,UAAU,CAACC,MAAM,CACrDC,IAAI,IACHA,IAAI,CAACC,IAAI,KAAK,UAAU,IAAID,IAAI,CAACE,GAAG,KAAK,6BAC7C,CAAC;IAEDL,YAAY,CAACC,UAAU,CAACK,IAAI,CAAC;MAC3BF,IAAI,EAAE,UAAU;MAChBC,GAAG,EAAE,6BAA6B;MAClCE,KAAK,EAAE;IACT,CAAC,CAAC;IAEF,OAAOP,YAAY;EACrB,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ import configPlugins from '@expo/config-plugins';
4
+ import fs from 'fs';
5
+ import path from 'path';
6
+ const {
7
+ withDangerousMod
8
+ } = configPlugins;
9
+ const IOS_MATH_OPTION = "ENV['ENRICHED_MARKDOWN_ENABLE_MATH'] = '0'";
10
+ export const withIosMath = (config, {
11
+ enableMath = true
12
+ }) => {
13
+ if (enableMath) {
14
+ return config;
15
+ }
16
+ return withDangerousMod(config, ['ios', async modConfig => {
17
+ const file = path.join(modConfig.modRequest.platformProjectRoot, 'Podfile');
18
+ const contents = fs.readFileSync(file, 'utf8');
19
+ const lines = contents.split('\n');
20
+ const filteredLines = lines.filter(line => !line.includes('ENRICHED_MARKDOWN_ENABLE_MATH'));
21
+ filteredLines.unshift(IOS_MATH_OPTION);
22
+ fs.writeFileSync(file, filteredLines.join('\n'));
23
+ return modConfig;
24
+ }]);
25
+ };
26
+ //# sourceMappingURL=withIosMath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["configPlugins","fs","path","withDangerousMod","IOS_MATH_OPTION","withIosMath","config","enableMath","modConfig","file","join","modRequest","platformProjectRoot","contents","readFileSync","lines","split","filteredLines","filter","line","includes","unshift","writeFileSync"],"sourceRoot":"../../../src","sources":["plugin/withIosMath.ts"],"mappings":";;AAAA,OAAOA,aAAa,MAA6B,sBAAsB;AACvE,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AAEvB,MAAM;EAAEC;AAAiB,CAAC,GAAGH,aAAa;AAE1C,MAAMI,eAAe,GAAG,4CAA4C;AAEpE,OAAO,MAAMC,WAAmD,GAAGA,CACjEC,MAAM,EACN;EAAEC,UAAU,GAAG;AAAK,CAAC,KAClB;EACH,IAAIA,UAAU,EAAE;IACd,OAAOD,MAAM;EACf;EACA,OAAOH,gBAAgB,CAACG,MAAM,EAAE,CAC9B,KAAK,EACL,MAAOE,SAAS,IAAK;IACnB,MAAMC,IAAI,GAAGP,IAAI,CAACQ,IAAI,CACpBF,SAAS,CAACG,UAAU,CAACC,mBAAmB,EACxC,SACF,CAAC;IACD,MAAMC,QAAQ,GAAGZ,EAAE,CAACa,YAAY,CAACL,IAAI,EAAE,MAAM,CAAC;IAE9C,MAAMM,KAAK,GAAGF,QAAQ,CAACG,KAAK,CAAC,IAAI,CAAC;IAClC,MAAMC,aAAa,GAAGF,KAAK,CAACG,MAAM,CAC/BC,IAAI,IAAK,CAACA,IAAI,CAACC,QAAQ,CAAC,+BAA+B,CAC1D,CAAC;IAEDH,aAAa,CAACI,OAAO,CAACjB,eAAe,CAAC;IAEtCH,EAAE,CAACqB,aAAa,CAACb,IAAI,EAAEQ,aAAa,CAACP,IAAI,CAAC,IAAI,CAAC,CAAC;IAEhD,OAAOF,SAAS;EAClB,CAAC,CACF,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ import { withIosMath } from "./withIosMath.js";
4
+ import { withAndroidMath } from "./withAndroidMath.js";
5
+ const withEnrichedMarkdown = (config, props) => {
6
+ const enableMath = props?.enableMath !== false;
7
+ config = withAndroidMath(config, {
8
+ enableMath
9
+ });
10
+ config = withIosMath(config, {
11
+ enableMath
12
+ });
13
+ return config;
14
+ };
15
+ export default withEnrichedMarkdown;
16
+ //# sourceMappingURL=withReactNativeEnrichedMarkdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withIosMath","withAndroidMath","withEnrichedMarkdown","config","props","enableMath"],"sourceRoot":"../../../src","sources":["plugin/withReactNativeEnrichedMarkdown.ts"],"mappings":";;AACA,SAASA,WAAW,QAAQ,kBAAe;AAC3C,SAASC,eAAe,QAAQ,sBAAmB;AAEnD,MAAMC,oBAAmE,GAAGA,CAC1EC,MAAM,EACNC,KAAK,KACF;EACH,MAAMC,UAAU,GAAGD,KAAK,EAAEC,UAAU,KAAK,KAAK;EAE9CF,MAAM,GAAGF,eAAe,CAACE,MAAM,EAAE;IAAEE;EAAW,CAAC,CAAC;EAChDF,MAAM,GAAGH,WAAW,CAACG,MAAM,EAAE;IAAEE;EAAW,CAAC,CAAC;EAE5C,OAAOF,MAAM;AACf,CAAC;AAED,eAAeD,oBAAoB","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ import { type ConfigPlugin } from '@expo/config-plugins';
2
+ export declare const withAndroidMath: ConfigPlugin<{
3
+ enableMath?: boolean;
4
+ }>;
5
+ //# sourceMappingURL=withAndroidMath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withAndroidMath.d.ts","sourceRoot":"","sources":["../../../../src/plugin/withAndroidMath.ts"],"names":[],"mappings":"AAAA,OAAsB,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIxE,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,CAqBlE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { type ConfigPlugin } from '@expo/config-plugins';
2
+ export declare const withIosMath: ConfigPlugin<{
3
+ enableMath?: boolean;
4
+ }>;
5
+ //# sourceMappingURL=withIosMath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withIosMath.d.ts","sourceRoot":"","sources":["../../../../src/plugin/withIosMath.ts"],"names":[],"mappings":"AAAA,OAAsB,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQxE,eAAO,MAAM,WAAW,EAAE,YAAY,CAAC;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,CA4B9D,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type ConfigPlugin } from '@expo/config-plugins';
2
+ declare const withEnrichedMarkdown: ConfigPlugin<{
3
+ enableMath?: boolean;
4
+ } | void>;
5
+ export default withEnrichedMarkdown;
6
+ //# sourceMappingURL=withReactNativeEnrichedMarkdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withReactNativeEnrichedMarkdown.d.ts","sourceRoot":"","sources":["../../../../src/plugin/withReactNativeEnrichedMarkdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIzD,QAAA,MAAM,oBAAoB,EAAE,YAAY,CAAC;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAUvE,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-enriched-markdown",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Markdown Text component for React Native",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -10,7 +10,8 @@
10
10
  "types": "./lib/typescript/src/index.d.ts",
11
11
  "default": "./lib/module/index.js"
12
12
  },
13
- "./package.json": "./package.json"
13
+ "./package.json": "./package.json",
14
+ "./app.plugin.js": "./app.plugin.js"
14
15
  },
15
16
  "files": [
16
17
  "src",
@@ -29,7 +30,8 @@
29
30
  "!**/__tests__",
30
31
  "!**/__fixtures__",
31
32
  "!**/__mocks__",
32
- "!**/.*"
33
+ "!**/.*",
34
+ "app.plugin.js"
33
35
  ],
34
36
  "scripts": {
35
37
  "example": "yarn workspace react-native-enriched-markdown-example",
@@ -74,13 +76,13 @@
74
76
  "@eslint/compat": "^1.3.2",
75
77
  "@eslint/eslintrc": "^3.3.1",
76
78
  "@eslint/js": "^9.35.0",
77
- "@evilmartians/lefthook": "^1.12.3",
79
+ "@expo/config-plugins": "^55.0.6",
78
80
  "@react-native-community/cli": "20.0.1",
79
- "@react-native/babel-preset": "0.81.1",
80
- "@react-native/eslint-config": "^0.81.1",
81
+ "@react-native/babel-preset": "0.84.1",
82
+ "@react-native/eslint-config": "0.84.1",
81
83
  "@release-it/conventional-changelog": "^10.0.1",
82
84
  "@types/jest": "^29.5.14",
83
- "@types/react": "^19.1.0",
85
+ "@types/react": "^19.2.0",
84
86
  "clang-format": "^1.8.0",
85
87
  "commitlint": "^19.8.1",
86
88
  "del-cli": "^6.0.0",
@@ -88,22 +90,29 @@
88
90
  "eslint-config-prettier": "^10.1.8",
89
91
  "eslint-plugin-prettier": "^5.5.4",
90
92
  "jest": "^29.7.0",
93
+ "lefthook": "^2.0.3",
91
94
  "prettier": "^3.6.2",
92
- "react": "19.1.0",
93
- "react-native": "0.81.1",
94
- "react-native-builder-bob": "^0.40.13",
95
+ "react": "19.2.3",
96
+ "react-native": "0.84.1",
97
+ "react-native-builder-bob": "^0.40.18",
95
98
  "release-it": "^19.0.4",
96
99
  "turbo": "^2.5.6",
97
100
  "typescript": "^5.9.2"
98
101
  },
99
102
  "peerDependencies": {
103
+ "@expo/config-plugins": ">=50.0.0",
100
104
  "react": "*",
101
105
  "react-native": "*"
102
106
  },
107
+ "peerDependenciesMeta": {
108
+ "@expo/config-plugins": {
109
+ "optional": true
110
+ }
111
+ },
103
112
  "workspaces": [
104
113
  "example"
105
114
  ],
106
- "packageManager": "yarn@3.6.1",
115
+ "packageManager": "yarn@4.11.0",
107
116
  "jest": {
108
117
  "preset": "react-native",
109
118
  "modulePathIgnorePatterns": [
@@ -185,8 +194,14 @@
185
194
  "includesGeneratedCode": true
186
195
  },
187
196
  "create-react-native-library": {
188
- "languages": "kotlin-objc",
189
197
  "type": "fabric-view",
190
- "version": "0.54.6"
198
+ "languages": "kotlin-objc",
199
+ "tools": [
200
+ "eslint",
201
+ "jest",
202
+ "lefthook",
203
+ "release-it"
204
+ ],
205
+ "version": "0.57.2"
191
206
  }
192
207
  }
@@ -0,0 +1,26 @@
1
+ import configPlugins, { type ConfigPlugin } from '@expo/config-plugins';
2
+
3
+ const { withGradleProperties } = configPlugins;
4
+
5
+ export const withAndroidMath: ConfigPlugin<{ enableMath?: boolean }> = (
6
+ config,
7
+ { enableMath = true }
8
+ ) => {
9
+ if (enableMath) {
10
+ return config;
11
+ }
12
+ return withGradleProperties(config, (gradleConfig) => {
13
+ gradleConfig.modResults = gradleConfig.modResults.filter(
14
+ (prop) =>
15
+ prop.type !== 'property' || prop.key !== 'enrichedMarkdown.enableMath'
16
+ );
17
+
18
+ gradleConfig.modResults.push({
19
+ type: 'property',
20
+ key: 'enrichedMarkdown.enableMath',
21
+ value: 'false',
22
+ });
23
+
24
+ return gradleConfig;
25
+ });
26
+ };
@@ -0,0 +1,37 @@
1
+ import configPlugins, { type ConfigPlugin } from '@expo/config-plugins';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+
5
+ const { withDangerousMod } = configPlugins;
6
+
7
+ const IOS_MATH_OPTION = "ENV['ENRICHED_MARKDOWN_ENABLE_MATH'] = '0'";
8
+
9
+ export const withIosMath: ConfigPlugin<{ enableMath?: boolean }> = (
10
+ config,
11
+ { enableMath = true }
12
+ ) => {
13
+ if (enableMath) {
14
+ return config;
15
+ }
16
+ return withDangerousMod(config, [
17
+ 'ios',
18
+ async (modConfig) => {
19
+ const file = path.join(
20
+ modConfig.modRequest.platformProjectRoot,
21
+ 'Podfile'
22
+ );
23
+ const contents = fs.readFileSync(file, 'utf8');
24
+
25
+ const lines = contents.split('\n');
26
+ const filteredLines = lines.filter(
27
+ (line) => !line.includes('ENRICHED_MARKDOWN_ENABLE_MATH')
28
+ );
29
+
30
+ filteredLines.unshift(IOS_MATH_OPTION);
31
+
32
+ fs.writeFileSync(file, filteredLines.join('\n'));
33
+
34
+ return modConfig;
35
+ },
36
+ ]);
37
+ };
@@ -0,0 +1,17 @@
1
+ import { type ConfigPlugin } from '@expo/config-plugins';
2
+ import { withIosMath } from './withIosMath';
3
+ import { withAndroidMath } from './withAndroidMath';
4
+
5
+ const withEnrichedMarkdown: ConfigPlugin<{ enableMath?: boolean } | void> = (
6
+ config,
7
+ props
8
+ ) => {
9
+ const enableMath = props?.enableMath !== false;
10
+
11
+ config = withAndroidMath(config, { enableMath });
12
+ config = withIosMath(config, { enableMath });
13
+
14
+ return config;
15
+ };
16
+
17
+ export default withEnrichedMarkdown;