react-native-enriched-markdown 1.0.1 → 1.0.2

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.
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withAndroidCodeHighlight = void 0;
4
- const config_plugins_1 = require("@expo/config-plugins");
5
- const withAndroidCodeHighlight = (config, { enabled = true, languages } = {}) => {
6
- const hasLanguages = Array.isArray(languages) && languages.length > 0;
7
- // Always run the mod so switching back to defaults strips previously-injected
8
- // properties; an absent property already means enabled with the curated set.
9
- return (0, config_plugins_1.withGradleProperties)(config, (gradleConfig) => {
10
- const drop = new Set([
11
- 'enrichedMarkdown.enableCodeHighlight',
12
- 'enrichedMarkdown.codeHighlightLanguages',
13
- ]);
14
- gradleConfig.modResults = gradleConfig.modResults.filter((prop) => prop.type !== 'property' || !drop.has(prop.key));
15
- if (!enabled) {
16
- gradleConfig.modResults.push({
17
- type: 'property',
18
- key: 'enrichedMarkdown.enableCodeHighlight',
19
- value: 'false',
20
- });
21
- }
22
- if (hasLanguages) {
23
- gradleConfig.modResults.push({
24
- type: 'property',
25
- key: 'enrichedMarkdown.codeHighlightLanguages',
26
- value: languages.join(','),
27
- });
28
- }
29
- return gradleConfig;
30
- });
31
- };
32
- exports.withAndroidCodeHighlight = withAndroidCodeHighlight;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withAndroidMath = void 0;
4
- const config_plugins_1 = require("@expo/config-plugins");
5
- const withAndroidMath = (config, { enableMath = true }) => {
6
- if (enableMath) {
7
- return config;
8
- }
9
- return (0, config_plugins_1.withGradleProperties)(config, (gradleConfig) => {
10
- gradleConfig.modResults = gradleConfig.modResults.filter((prop) => prop.type !== 'property' || prop.key !== 'enrichedMarkdown.enableMath');
11
- gradleConfig.modResults.push({
12
- type: 'property',
13
- key: 'enrichedMarkdown.enableMath',
14
- value: 'false',
15
- });
16
- return gradleConfig;
17
- });
18
- };
19
- exports.withAndroidMath = withAndroidMath;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.withIosCodeHighlight = void 0;
7
- const config_plugins_1 = require("@expo/config-plugins");
8
- const fs_1 = __importDefault(require("fs"));
9
- const path_1 = __importDefault(require("path"));
10
- const ENABLE_KEY = 'ENRICHED_MARKDOWN_ENABLE_CODE_HIGHLIGHT';
11
- const LANGUAGES_KEY = 'ENRICHED_MARKDOWN_CODE_HIGHLIGHT_LANGUAGES';
12
- const withIosCodeHighlight = (config, { enabled = true, languages } = {}) => {
13
- const hasLanguages = Array.isArray(languages) && languages.length > 0;
14
- // Always run the mod so switching back to defaults strips previously-injected
15
- // ENV lines; an absent ENV var already means enabled with the curated set.
16
- return (0, config_plugins_1.withDangerousMod)(config, [
17
- 'ios',
18
- async (modConfig) => {
19
- const file = path_1.default.join(modConfig.modRequest.platformProjectRoot, 'Podfile');
20
- const contents = fs_1.default.readFileSync(file, 'utf8');
21
- const lines = contents
22
- .split('\n')
23
- .filter((line) => !line.includes(ENABLE_KEY) && !line.includes(LANGUAGES_KEY));
24
- const inject = [];
25
- if (!enabled) {
26
- inject.push(`ENV['${ENABLE_KEY}'] = '0'`);
27
- }
28
- if (hasLanguages) {
29
- inject.push(`ENV['${LANGUAGES_KEY}'] = '${languages.join(',')}'`);
30
- }
31
- lines.unshift(...inject);
32
- fs_1.default.writeFileSync(file, lines.join('\n'));
33
- return modConfig;
34
- },
35
- ]);
36
- };
37
- exports.withIosCodeHighlight = withIosCodeHighlight;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.withIosMath = void 0;
7
- const config_plugins_1 = require("@expo/config-plugins");
8
- const fs_1 = __importDefault(require("fs"));
9
- const path_1 = __importDefault(require("path"));
10
- const IOS_MATH_OPTION = "ENV['ENRICHED_MARKDOWN_ENABLE_MATH'] = '0'";
11
- const withIosMath = (config, { enableMath = true }) => {
12
- if (enableMath) {
13
- return config;
14
- }
15
- return (0, config_plugins_1.withDangerousMod)(config, [
16
- 'ios',
17
- async (modConfig) => {
18
- const file = path_1.default.join(modConfig.modRequest.platformProjectRoot, 'Podfile');
19
- const contents = fs_1.default.readFileSync(file, 'utf8');
20
- const lines = contents.split('\n');
21
- const filteredLines = lines.filter((line) => !line.includes('ENRICHED_MARKDOWN_ENABLE_MATH'));
22
- filteredLines.unshift(IOS_MATH_OPTION);
23
- fs_1.default.writeFileSync(file, filteredLines.join('\n'));
24
- return modConfig;
25
- },
26
- ]);
27
- };
28
- exports.withIosMath = withIosMath;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const withIosMath_1 = require("./withIosMath");
4
- const withAndroidMath_1 = require("./withAndroidMath");
5
- const withAndroidCodeHighlight_1 = require("./withAndroidCodeHighlight");
6
- const withIosCodeHighlight_1 = require("./withIosCodeHighlight");
7
- const withEnrichedMarkdown = (config, props) => {
8
- const enableMath = props?.enableMath !== false;
9
- config = (0, withAndroidMath_1.withAndroidMath)(config, { enableMath });
10
- config = (0, withIosMath_1.withIosMath)(config, { enableMath });
11
- const codeHighlight = props?.codeHighlight ?? {};
12
- config = (0, withAndroidCodeHighlight_1.withAndroidCodeHighlight)(config, codeHighlight);
13
- config = (0, withIosCodeHighlight_1.withIosCodeHighlight)(config, codeHighlight);
14
- return config;
15
- };
16
- exports.default = withEnrichedMarkdown;
@@ -1,38 +0,0 @@
1
- import { withGradleProperties, type ConfigPlugin } from '@expo/config-plugins';
2
-
3
- export type CodeHighlightOptions = { enabled?: boolean; languages?: string[] };
4
-
5
- export const withAndroidCodeHighlight: ConfigPlugin<CodeHighlightOptions> = (
6
- config,
7
- { enabled = true, languages } = {}
8
- ) => {
9
- const hasLanguages = Array.isArray(languages) && languages.length > 0;
10
- // Always run the mod so switching back to defaults strips previously-injected
11
- // properties; an absent property already means enabled with the curated set.
12
- return withGradleProperties(config, (gradleConfig) => {
13
- const drop = new Set([
14
- 'enrichedMarkdown.enableCodeHighlight',
15
- 'enrichedMarkdown.codeHighlightLanguages',
16
- ]);
17
- gradleConfig.modResults = gradleConfig.modResults.filter(
18
- (prop) => prop.type !== 'property' || !drop.has(prop.key)
19
- );
20
-
21
- if (!enabled) {
22
- gradleConfig.modResults.push({
23
- type: 'property',
24
- key: 'enrichedMarkdown.enableCodeHighlight',
25
- value: 'false',
26
- });
27
- }
28
- if (hasLanguages) {
29
- gradleConfig.modResults.push({
30
- type: 'property',
31
- key: 'enrichedMarkdown.codeHighlightLanguages',
32
- value: languages!.join(','),
33
- });
34
- }
35
-
36
- return gradleConfig;
37
- });
38
- };
@@ -1,24 +0,0 @@
1
- import { withGradleProperties, type ConfigPlugin } from '@expo/config-plugins';
2
-
3
- export const withAndroidMath: ConfigPlugin<{ enableMath?: boolean }> = (
4
- config,
5
- { enableMath = true }
6
- ) => {
7
- if (enableMath) {
8
- return config;
9
- }
10
- return withGradleProperties(config, (gradleConfig) => {
11
- gradleConfig.modResults = gradleConfig.modResults.filter(
12
- (prop) =>
13
- prop.type !== 'property' || prop.key !== 'enrichedMarkdown.enableMath'
14
- );
15
-
16
- gradleConfig.modResults.push({
17
- type: 'property',
18
- key: 'enrichedMarkdown.enableMath',
19
- value: 'false',
20
- });
21
-
22
- return gradleConfig;
23
- });
24
- };
@@ -1,45 +0,0 @@
1
- import { withDangerousMod, type ConfigPlugin } from '@expo/config-plugins';
2
- import fs from 'fs';
3
- import path from 'path';
4
-
5
- export type CodeHighlightOptions = { enabled?: boolean; languages?: string[] };
6
-
7
- const ENABLE_KEY = 'ENRICHED_MARKDOWN_ENABLE_CODE_HIGHLIGHT';
8
- const LANGUAGES_KEY = 'ENRICHED_MARKDOWN_CODE_HIGHLIGHT_LANGUAGES';
9
-
10
- export const withIosCodeHighlight: ConfigPlugin<CodeHighlightOptions> = (
11
- config,
12
- { enabled = true, languages } = {}
13
- ) => {
14
- const hasLanguages = Array.isArray(languages) && languages.length > 0;
15
- // Always run the mod so switching back to defaults strips previously-injected
16
- // ENV lines; an absent ENV var already means enabled with the curated set.
17
- return withDangerousMod(config, [
18
- 'ios',
19
- async (modConfig) => {
20
- const file = path.join(
21
- modConfig.modRequest.platformProjectRoot,
22
- 'Podfile'
23
- );
24
- const contents = fs.readFileSync(file, 'utf8');
25
- const lines = contents
26
- .split('\n')
27
- .filter(
28
- (line: string) =>
29
- !line.includes(ENABLE_KEY) && !line.includes(LANGUAGES_KEY)
30
- );
31
-
32
- const inject: string[] = [];
33
- if (!enabled) {
34
- inject.push(`ENV['${ENABLE_KEY}'] = '0'`);
35
- }
36
- if (hasLanguages) {
37
- inject.push(`ENV['${LANGUAGES_KEY}'] = '${languages!.join(',')}'`);
38
- }
39
- lines.unshift(...inject);
40
-
41
- fs.writeFileSync(file, lines.join('\n'));
42
- return modConfig;
43
- },
44
- ]);
45
- };
@@ -1,35 +0,0 @@
1
- import { withDangerousMod, type ConfigPlugin } from '@expo/config-plugins';
2
- import fs from 'fs';
3
- import path from 'path';
4
-
5
- const IOS_MATH_OPTION = "ENV['ENRICHED_MARKDOWN_ENABLE_MATH'] = '0'";
6
-
7
- export const withIosMath: ConfigPlugin<{ enableMath?: boolean }> = (
8
- config,
9
- { enableMath = true }
10
- ) => {
11
- if (enableMath) {
12
- return config;
13
- }
14
- return withDangerousMod(config, [
15
- 'ios',
16
- async (modConfig) => {
17
- const file = path.join(
18
- modConfig.modRequest.platformProjectRoot,
19
- 'Podfile'
20
- );
21
- const contents = fs.readFileSync(file, 'utf8');
22
-
23
- const lines = contents.split('\n');
24
- const filteredLines = lines.filter(
25
- (line: string) => !line.includes('ENRICHED_MARKDOWN_ENABLE_MATH')
26
- );
27
-
28
- filteredLines.unshift(IOS_MATH_OPTION);
29
-
30
- fs.writeFileSync(file, filteredLines.join('\n'));
31
-
32
- return modConfig;
33
- },
34
- ]);
35
- };
@@ -1,28 +0,0 @@
1
- import { type ConfigPlugin } from '@expo/config-plugins';
2
- import { withIosMath } from './withIosMath';
3
- import { withAndroidMath } from './withAndroidMath';
4
- import { withAndroidCodeHighlight } from './withAndroidCodeHighlight';
5
- import { withIosCodeHighlight } from './withIosCodeHighlight';
6
-
7
- type EnrichedMarkdownProps = {
8
- enableMath?: boolean;
9
- codeHighlight?: { enabled?: boolean; languages?: string[] };
10
- };
11
-
12
- const withEnrichedMarkdown: ConfigPlugin<EnrichedMarkdownProps | void> = (
13
- config,
14
- props
15
- ) => {
16
- const enableMath = props?.enableMath !== false;
17
-
18
- config = withAndroidMath(config, { enableMath });
19
- config = withIosMath(config, { enableMath });
20
-
21
- const codeHighlight = props?.codeHighlight ?? {};
22
- config = withAndroidCodeHighlight(config, codeHighlight);
23
- config = withIosCodeHighlight(config, codeHighlight);
24
-
25
- return config;
26
- };
27
-
28
- export default withEnrichedMarkdown;
@@ -1,16 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "moduleResolution": "node",
5
- "ignoreDeprecations": "6.0",
6
- "target": "ES2020",
7
- "outDir": "./build",
8
- "rootDir": "./src",
9
- "esModuleInterop": true,
10
- "strict": true,
11
- "skipLibCheck": true,
12
- "declaration": false,
13
- "types": ["node"]
14
- },
15
- "include": ["./src/**/*.ts"]
16
- }