fix: code block render error with text link inside, keep classes from readability
close #1058
This commit is contained in:
parent
9a83a29b66
commit
40042ea340
|
|
@ -44,6 +44,9 @@ export async function readability(url: string) {
|
|||
|
||||
const reader = new Readability(document, {
|
||||
debug: isDev,
|
||||
// keep classes to set the right code language
|
||||
// https://github.com/RSSNext/Follow/issues/1058
|
||||
keepClasses: true,
|
||||
})
|
||||
return reader.parse()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,10 @@ export const parseHtml = (
|
|||
|
||||
const tree = pipeline.parse(content)
|
||||
|
||||
rehypeUrlToAnchor(tree)
|
||||
// NOTE: disable for now, it introduces some issues
|
||||
// 1. It may convert parts beyond the actual link into links
|
||||
// 2. It cannot correctly handle the situation in the code block
|
||||
// rehypeUrlToAnchor(tree)
|
||||
|
||||
// console.log("tree", tree)
|
||||
|
||||
|
|
@ -317,7 +320,7 @@ const Style: Components["style"] = ({ node, ...props }) => {
|
|||
return null
|
||||
}
|
||||
|
||||
function rehypeUrlToAnchor(tree: Node) {
|
||||
function _rehypeUrlToAnchor(tree: Node) {
|
||||
// https://chatgpt.com/share/37e0ceec-5c9e-4086-b9d6-5afc1af13bb0
|
||||
visit(tree, "text", (node: Text, index, parent: Node) => {
|
||||
const urlRegex = /https?:\/\/\S+/g
|
||||
|
|
|
|||
Loading…
Reference in New Issue