Skip to content

Commit

Permalink
Fix: correctly adding newlines in Perplexity extracted content (#259)
Browse files Browse the repository at this point in the history
* fix: correctly targeting Perplexity newlines

* 3.8.1

* fix: correctly adding newline between list item and code block

* 3.8.2
  • Loading branch information
Hugo-COLLIN authored Feb 5, 2025
1 parent 3e2cf6b commit b8a5ee4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "save-my-chatbot",
"version": "3.8.0",
"version": "3.8.2",
"license": "RMD-C 1.1",
"author": "Hugo COLLIN",
"homepage": "https://save.hugocollin.com",
Expand Down
5 changes: 4 additions & 1 deletion public/files/updateNotes.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Update notes
# 3.8.0
# 3.8.2
🚀 Export your threads on Phind 2.0!
The Phind interface completely changed, so the extension needed a refresh!
Now it's back on tracks!

🧩 Fixing Perplexity export
Newline formatting problem solved!

# 3.7.6
🎯 Fix Perplexity sources list export
Some sources were not correctly exported. It's now fixed!
Expand Down
11 changes: 7 additions & 4 deletions src/features/scraper/rules/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import {turndownConverter} from "../../../core/services/format/formatMarkdown";
/*
--- Format pre-function ---
*/
export function getBlankReplacement(content: any, node: { nodeName: string; getAttribute: (arg0: string) => string; }) {
if (node.nodeName === 'SPAN' && node.getAttribute('class') === 'block mt-md') {
return '\n\n';
export function getBlankReplacement(content: any, node: HTMLElement) {
// if (node.nodeName === 'SPAN' && node.getAttribute('class') === 'block mt-md') {
if (node.nodeName === 'SPAN') {
if (node.classList.contains('block') && node.classList.contains('mt-md')) return '\n\n';
if (node.innerHTML === '') return '\n';
} else {
return '';
}
Expand Down Expand Up @@ -88,10 +90,11 @@ export function filter_PreserveLineBreaksInPre_Claude(node: { nodeName: string;
}

export function replacement_PreserveLineBreaksInPre_Perplexity(content: any, node: { querySelector: (arg0: string) => any; }) {
console.log("replacement_PreserveLineBreaksInPre_Perplexity", node)
const codeBlock = node.querySelector('code');
const codeContent = codeBlock.textContent.trim();
const codeLang = codeBlock.parentNode.parentNode.parentNode.querySelector("div").textContent.trim();
return ('\n```' + codeLang + '\n' + codeContent + '\n```');
return (turndownConverter.turndown("<br>") + '\n```' + codeLang + '\n' + codeContent + '\n```');
}

export function replacement_preserveLineBreaksInPre_Phind(content: any, node: { querySelector: (arg0: string) => any; }) {
Expand Down

0 comments on commit b8a5ee4

Please sign in to comment.