fix: Better markdown conversion for Hypermind questions

This commit is contained in:
NunoSempere 2021-08-11 23:06:46 +02:00
parent 1fd3b29def
commit 3c0a01db95
3 changed files with 8 additions and 4 deletions

View File

@ -133,7 +133,7 @@ async function hypermind_inner(cookie) {
let descriptionprocessed2 = descriptionprocessed1.replaceAll("![image] ()", "")
let descriptionprocessed3 = descriptionprocessed2.replaceAll(" Forecasting Schedule ", "")
let descriptionprocessed4 = descriptionprocessed3.replaceAll("\n", "")
let descriptionprocessed5 = descriptionprocessed4.replaceAll("Context: ", "")
let descriptionprocessed5 = descriptionprocessed4.replaceAll("Context:", "")
let description = descriptionprocessed5 || toMarkdown(result.props.details)
return ({
"title": result.props.title,

View File

@ -35,4 +35,4 @@ export async function rebuildAlgoliaDatabaseTheEasyWay(){
}
}
export const rebuildAlgoliaDatabase = rebuildAlgoliaDatabaseTheHardWay
export const rebuildAlgoliaDatabase = rebuildAlgoliaDatabaseTheEasyWay//rebuildAlgoliaDatabaseTheHardWay

View File

@ -2,6 +2,8 @@
import textVersion from "textversionjs"
/* Definitions */
String.prototype.replaceAll = function replaceAll(search, replace) { return this.split(search).join(replace); }
var styleConfig = {
linkProcess: function(href, linkText){
let newHref = href ? href.replace(/\(/g, "%28").replace(/\)/g, "%29") : ""
@ -15,7 +17,9 @@ var styleConfig = {
/* Body */
export default function toMarkdown(htmlText){
return textVersion(htmlText, styleConfig);
let html2 = htmlText.replaceAll(`='`, `="`).replaceAll(`'>`, `">`)
return textVersion(html2, styleConfig);
}
// toMarkdown()
// toMarkdown()
// console.log(toMarkdown("Context:Many intellectual endeavors require mathematical problem solving, but this skill remains beyond the capabilities of computers. To help advance the art, the <a target=_new href='https://github.com/hendrycks/math/'>MATH</a> dataset offers..."))