Remove [hr]() chapter content

This commit is contained in:
Rajarshee Chatterjee
2021-07-18 10:30:21 +05:30
parent 63de0a3794
commit 6c27993454
2 changed files with 8 additions and 8 deletions
+2 -2
View File
@@ -93,12 +93,12 @@ const TextToComponents = ({
theme,
}) => {
try {
regex = /(\[(?:\n|.)*?\]\(.*?\))/;
regex = /(\{(?:\n|.)*?\}\(.*?\))/;
let parseText = text.trim().split(regex);
return parseText.map((part, index) => {
if (part) {
let match = part.match(/\[((?:\n|.)*?)\]\((.*?)\)/);
let match = part.match(/\{((?:\n|.)*?)\}\((.*?)\)/);
if (match) {
tag = match[1];
+6 -6
View File
@@ -14,7 +14,7 @@ const htmlToText = (html, options = {}) => {
* <hr> -> [hr]()
*/
.replace(/<\s*hr[^>]*>/gi, "[hr]()")
.replace(/<\s*hr[^>]*>/gi, "{hr}()")
/**
* <li> -> \n
@@ -51,27 +51,27 @@ const htmlToText = (html, options = {}) => {
.replace(
/<\s*a[^>]*href=['"](http.*?)['"][^>]*>([\s\S]*?)<\/\s*a\s*>/gi,
"[Anchor: $2]($1)"
"{Anchor: $2}($1)"
)
/**
* <em>Text</em> -> _Text_
*/
.replace(/<em>(.*?)<\/em>/gi, "[em]($1)")
.replace(/<em>(.*?)<\/em>/gi, "{em}($1)")
/**
* <h1>Text</h1> -> [h1](Text)
*/
.replace(/<(h[1-6])>(.*?)<\/h[1-6]>/gi, "[$1]($2)")
.replace(/<strong>(.*?)<strong>/gi, "[strong]($1)")
.replace(/<(h[1-6])>(.*?)<\/h[1-6]>/gi, "{$1}($2)")
.replace(/<strong>(.*?)<strong>/gi, "{strong}($1)")
/**
* <img> -> [img](src)
*/
.replace(/<\s*img[^>]*src=['"](.*?)['"][^>]*>/gi, "[img]($1)")
.replace(/<\s*img[^>]*src=['"](.*?)['"][^>]*>/gi, "{img}($1)")
/**
* Remove remaining tags