Skip to content

Commit

Permalink
Merge pull request #42 from contentstack/revert-41-development
Browse files Browse the repository at this point in the history
Revert "Feat: Json to Markdown Serializer."
  • Loading branch information
Ashwini-Rathod committed Jun 7, 2024
2 parents b6203ba + 8843f54 commit 50da78a
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 1,009 deletions.
42 changes: 1 addition & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. [Read more](https://www.contentstack.com/docs/).

The JSON RTE Serializer package assists in converting the content within your JSON Rich Text Editor field between JSON and HTML formats. This means you can easily change your data from JSON format to HTML format for display purposes, and vice versa, for data storage or processing.
If you need to convert JSON to Markdown format, we offer the Markdown Serializer function. This function is specifically designed to transform your JSON data into Markdown, making it easier to handle text formatting for platforms that use Markdown.
The JSON RTE Serializer package helps you convert the data inside your JSON Rich Text Editor field from JSON to HTML format and vice versa.

# Installation

Expand Down Expand Up @@ -103,45 +102,6 @@ The resulting JSON-formatted data will look as follows:
}
```

### JSON to Markdown Conversion Code

You can use the following JSON RTE Serializer code to convert your JSON RTE field data into Markdown format.

```javascript
import { jsonToMarkdown } from "@contentstack/json-rte-serializer";

const markdownValue = jsonToHtml({
type: "doc",
attrs: {},
uid: "547a479c68824767ce1d9725852f042b",
children: [
{
uid: "767a479c6882471d9725852f042b67ce",
type: "p",
attrs: {},
children: [
{ text: "This is Markdown-formatted content which has some " },
{ text: "BOLD", bold: true },
{ text: " text and some "},
{ text: "Italic", italic: true },
{ text: " text."}
]
},
],
});

console.log(markdownValue);
```

### Result of Conversion

The resulting Markdown data will look as follows:

```MARKDOWN

This is Markdown-formatted content which has some **BOLD** text and some *Italic* text.
```

## Custom Conversion

For customized conversion scenarios, you can customize your JSON RTE Serializer code to allow the support for additional tags or element types in the JSON Rich Text Editor field. Pass an `options` field (optional) within the `jsonToHtml` or `htmlToJson` method to manipulate the working of the JSON RTE Serializer package as per your requirements.
Expand Down
65 changes: 4 additions & 61 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
},
"dependencies": {
"array-flat-polyfill": "^1.0.1",
"lodash": "^4.17.21",
"lodash.clonedeep": "^4.5.0",
"lodash.flatten": "^4.4.0",
"lodash.isempty": "^4.4.0",
Expand All @@ -58,7 +57,6 @@
"lodash.isplainobject": "^4.0.6",
"lodash.isundefined": "^3.0.1",
"lodash.kebabcase": "^4.1.1",
"slate": "^0.103.0",
"uuid": "^8.3.2"
},
"files": [
Expand Down
3 changes: 1 addition & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import "array-flat-polyfill"
import { fromRedactor } from "./fromRedactor"
import { toRedactor } from "./toRedactor"
import {jsonToMarkdownSerializer} from './jsonToMarkdown'
export * from "./types"
export { fromRedactor as htmlToJson, toRedactor as jsonToHtml, jsonToMarkdownSerializer as jsonToMarkdown }
export { fromRedactor as htmlToJson, toRedactor as jsonToHtml }
Loading

0 comments on commit 50da78a

Please sign in to comment.