Minor fixes
This commit is contained in:
@@ -72,8 +72,8 @@ const Link = ({
|
||||
textStyle,
|
||||
{
|
||||
alignSelf: "flex-start",
|
||||
fontStyle: "italic",
|
||||
color: theme.colorAccent,
|
||||
textDecorationLine: "underline",
|
||||
},
|
||||
]}
|
||||
selectable={textSelectable}
|
||||
@@ -93,12 +93,12 @@ const TextToComponents = ({
|
||||
theme,
|
||||
}) => {
|
||||
try {
|
||||
regex = /(\[.*?\]\(.*?\))/;
|
||||
regex = /(\[(?:\n|.)*?\]\(.*?\))/;
|
||||
|
||||
let parseText = text.trim().split(regex);
|
||||
return parseText.map((part, index) => {
|
||||
if (part) {
|
||||
let match = part.match(/\[(.*?)\]\((.*?)\)/);
|
||||
let match = part.match(/\[((?:\n|.)*?)\]\((.*?)\)/);
|
||||
|
||||
if (match) {
|
||||
tag = match[1];
|
||||
|
||||
@@ -155,16 +155,12 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
if (isWordPress) {
|
||||
isWordPress =
|
||||
isWordPress.toLowerCase().includes("wordpress") ||
|
||||
isWordPress
|
||||
.toLowerCase()
|
||||
.includes("Site Kit by Google 1.36.0") ||
|
||||
isWordPress.includes("Site Kit by Google") ||
|
||||
$(".powered-by").text().toLowerCase().includes("wordpress") ||
|
||||
$(".entry-content").html() ||
|
||||
$("section.content").html()
|
||||
? true
|
||||
: false;
|
||||
|
||||
// console.log(isWordPress);
|
||||
}
|
||||
|
||||
let isRainOfSnow = result.url.toLowerCase().includes("rainofsnow");
|
||||
@@ -191,26 +187,30 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
/**
|
||||
* Remove wordpress bloat tags
|
||||
*/
|
||||
$(".c-ads").remove();
|
||||
$("#madara-comments").remove();
|
||||
$(".sharedaddy").remove();
|
||||
|
||||
chapterText = $(".entry-content").html();
|
||||
const bloatClasses = [
|
||||
".c-ads",
|
||||
"#madara-comments",
|
||||
"#comments",
|
||||
".sharedaddy",
|
||||
".wp-dark-mode-switcher",
|
||||
".wp-next-post-navi",
|
||||
".wp-block-buttons",
|
||||
".wp-block-columns",
|
||||
".post-cats",
|
||||
".sidebar",
|
||||
".author-avatar",
|
||||
];
|
||||
|
||||
if (!chapterText) {
|
||||
chapterText = $(".single_post").html();
|
||||
}
|
||||
if (!chapterText) {
|
||||
chapterText = $("article.post").html();
|
||||
}
|
||||
bloatClasses.map((tag) => $(tag).remove());
|
||||
|
||||
if (!chapterText) {
|
||||
chapterText = $(".content").html() || $("#content").html();
|
||||
}
|
||||
|
||||
/**
|
||||
* Format anchor tags properly Eg. [title](https://www.example.com)
|
||||
*/
|
||||
chapterText =
|
||||
$(".entry-content").html() ||
|
||||
$(".single_post").html() ||
|
||||
$(".post-entry").html() ||
|
||||
$("article.post").html() ||
|
||||
$(".content").html() ||
|
||||
$("#content").html();
|
||||
} else if (isWebNovel) {
|
||||
chapterText = $(".cha-words").html();
|
||||
|
||||
@@ -229,7 +229,16 @@ const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
}
|
||||
|
||||
if (chapterText) {
|
||||
/**
|
||||
* Remove patreon/discord links
|
||||
*/
|
||||
chapterText = chapterText.replace(
|
||||
/<\s*a[^>]*href=['"](https:\/\/(?:www.|patreon|discord).*?)['"][^>]*>([\s\S]*?)<\/\s*a\s*>/gi,
|
||||
""
|
||||
);
|
||||
|
||||
chapterText = htmlToText(chapterText);
|
||||
console.log(chapterText);
|
||||
} else {
|
||||
if (!chapterText) {
|
||||
chapterText =
|
||||
|
||||
@@ -50,7 +50,7 @@ const htmlToText = (html, options = {}) => {
|
||||
*/
|
||||
|
||||
.replace(
|
||||
/<\s*a[^>]*href=['"](.*?)['"][^>]*>([\s\S]*?)<\/\s*a\s*>/gi,
|
||||
/<\s*a[^>]*href=['"](http.*?)['"][^>]*>([\s\S]*?)<\/\s*a\s*>/gi,
|
||||
"[Anchor: $2]($1)"
|
||||
)
|
||||
|
||||
@@ -79,12 +79,6 @@ const htmlToText = (html, options = {}) => {
|
||||
|
||||
.replace(/(<([^>]+)>)/gi, "")
|
||||
|
||||
/**
|
||||
* Make sure there are never more than two consecutive linebreaks.
|
||||
*/
|
||||
|
||||
.replace(/\n{2,}/g, "\n\n")
|
||||
|
||||
/**
|
||||
* Remove tabs.
|
||||
*/
|
||||
@@ -103,6 +97,12 @@ const htmlToText = (html, options = {}) => {
|
||||
|
||||
.replace(/ {2,}/g, " ")
|
||||
|
||||
/**
|
||||
* Make sure there are never more than two consecutive linebreaks.
|
||||
*/
|
||||
|
||||
.replace(/\n{2,}/g, "\n\n")
|
||||
|
||||
/**
|
||||
* Decode HTML entities.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user