I am using slate-react editor for my wysiwyg data entry component that will be displayed on Telegram.
Text input is then formatted as per Telegram's requirement as this example shows:
Slate Object
[
{
"type": "paragraph",
"children": [
{
"text": "Dry grains to moisture content of below 12 percent and dress with crop "
},
{
"text": "protection ",
"bold": true
},
{
"text": "products such as Actellic 2%. Seeds meant for planting should not be stored for more than six "
},
{
"text": "months",
"underline": true
},
{
"text": ". For more "
},
{
"text": "information",
"underline": true
},
{
"text": ", please contact your "
},
{
"text": "local ",
"italic": true
},
{
"text": "Extension Agent."
}
]
}
]
I then format the string to Telegram specs as follows:
Dry grains to moisture content of below 12 percent and dress with crop **protection **products such as Actellic 2%. Seeds meant for planting should not be stored for more than six months. For more information, please contact your _local _Extension Agent.
I would now like to reverse engineer the process so that I can generate the object above if given such a string so that I'm able to display it on the editor. I would like help in formulating the function that would achieve the intended result.
For those who may need such information in future, I got pointer from comments thanks to @Phil, I was able to search through the net for markdown tokenizers. Prismjs works like a charm.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.