Remove [hr]() chapter content
This commit is contained in:
@@ -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];
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user