gpt4 book ai didi

javascript - mark.js 不高亮单词?

转载 作者:行者123 更新时间:2023-11-30 11:52:55 27 4
gpt4 key购买 nike

我使用 mark.js 将网站的某些部分标记为正面(绿色)、负面(红色)和中性(粗体)。它分别突出显示主体三次,向其添加一个类,然后使用 css 对其进行样式设置。由于某种原因,代码没有标记我的单词列表中的某些单词。示例:http://imgur.com/a/hmGRC .应突出显示“锁”一词。这是另一个例子:http://imgur.com/a/PdQpy应标记“问题”一词。

var positive = [ "negotiable","leather","clean title","clean history",
"clean car history","clean vin","clean carfax","brand new",
"1 owner","one owner","original owner","sunroof","moonroof","Z71","texas edition",
"panoramic","panorama","convertable","nav","navigation","never been",
"OBO","or best offer",
"touch screen","touchscreen","voice","gps","camera","dvd",
"entertainment","tv","television","premium","plus","pkg","flex fuel","Moon Roofs","sun roofs","moonroofs","sunroofs",
"pack","package","turbo","alloy","chrome","aluminum","back up camera","backup camera","back up cam","backup cam",
"allwheel all-wheel awd?","camera","power drivers seat","Power Lift","sky slider","skyslider","skyview",
"power windows","hardtop","hard top","4wd","4x4","4 wheel","not had any problems","no problems",
"four wheel","awd","allwheel","all-wheel","power","powered","All wheel drive","leatherette","leatherett","leatheret",
"heated","heat","no accidents","no bumps","non smoker","Moon Roof","sun roof",
"non smoking","no smoking","non-smoker","non-smokers","NAVAGATION","LEATER",
"non-smoking","no dents","no scrapes","no issues","rust-free",
"no wreck","no accident" ];
var negative = [ "armada","quest","flex","aspen","veloster","5 series","defects","defect","Rebuild","ex-salvage","exsalvage","exsalvaged","salvage","salvaged",
"infiniti","monte carlo","avenger","impala","versa","mini","stains","stained","stain","local only","local buyers","locally only","sell local","sell locally",
"mitsubishi","sebring","tiburon","durango","e250","scratches","dings","ding","scratch","scratched","mark","marked","marks",
"e350","rx8","miata","fiat","smart","mazda6","pontiac","not working","won't work","doesn't work","dealers","body work","needs","needing",
"magnum","accent","rio","crossfire","pt cruiser","pacifica","minor","blemishes","blemish","blemished","rusted",
"rondo","chrysler 200","saab","rendezvous","lexus gs","sentra","supercharger","supercharged","super charge","super charged","super charger","tuner","chip","chipped",
"mx5","accord lx","grand marquis","solara","non-negotiable","rough country","no dealers","no dealer","if you are a dealer",
"not negotiable","custom rims","nitro","nos","injected","firm","cracked","crack","cracks","cracking","aftermarket","programmer",
"noticeable","collision","impact","rear-ended","rearended","damage","damaged","damaging","local only","locals only","only local","be local","local sale only","local buyer only","local buyers only",
"rear ended","blemish","barely","wrapped","flaw","loose","mod","incident","incidents","branded","title brand","New transmission",
"bump","hole","burn","rip","tear","puncture","flat","dent","problems","problem","issue","issues","Tune","tuning",
"accident","wreck","scratch","scrape","break","bust","broken","spill","spilt","splash","wet","scratching","fading","faded","fade",
"rebuilt","salvaged","deploy","lowball","low-ball","repair","faulty","chips","h3","h3x","does not","leveling kit",
"fix","fixed","rust","hail","leak","torn","bent","stain","replace","replaced","Lowering","program","programming","programmed",
"scuff","problem","bad","horrible","stink","stank","stunk","dents","worn","fender bender","bender",
"lift","lifted","lowered","new york","nyc","new jersey","Rock Krawler",
"miami","lauderdale","doesn't work","stopped working",
"isn't working","do not","slight","modified","tuned","chipped",
"chip","burst","modification","vibrate","cosmetic","wrecked" ];
var neutral = [ "transmission","tread","automatic","manual","2wd","rwd","fwd","small",
"4x2","2 wheel","two wheel","seat","diesel","kelly","paperwork","leveling","level","leveled",
"v8","v6","v10","v4","v5","custom","sound system","good","great","auto","trans","we","i","us","moving","our","I've","we've",
"rims","excellent","condition","amazing","roof","cruise","remote","warranty",
"push","bucket","amp","liftgate","lift gate","liter","kit","rim","seats","3rd","third row","tires",
"wheels","lift gate","vin","17 inch","18 inch","19 inch","carpet","stock","never",
"20 inch","21 inch","22 inch","23 inch","24 inch","17\"","18\"","xm","sirius","satellite",
"19\"","20\"","21\"","22\"","23\"","24\"","impact","crew","supercrew","replaced","replace","replacing",
"cab","supercab","crew cab","exhaust","locks","window","driver","tinted","tint",
"seat","door","running board","runningboard","extra","edition","mile","miles","milages","mileage",
"ex-l","lx","kbb","loaded","appointment","maintenance","dealership","bluetooth",
"dealer","sport","luxury","reasonable","asap","lease","finance","pay",
"lien","loan","bank","limited","driver","very fair","old","dog","pet",
"animal","elderly","trim","cloth","owners","smell","airbag",
"title in hand","in hand","hemi","engine","must sell","personal",
"negotiate","price","coupe","dual","towing","hatchback","wagon","wife","son","father","mother","daughter","college","student","elderly",
"bus","sedan","truck","suv","trade","garage","reduced","stereo",
"five-speed","six-speed","fivespeed","liter","cylinder","tint","row","Running Boards","runningboard","running board","interior","certified",
"adult","teenager","teenage","daughter","son","college","father",
"mother","grandfather","grandson","grandmother","granddaughter",
"death","family","emergency","moving","carfax","cheap","title",
"nada","blue book","smoke","pet","owner","upgrade","new","subs","I have","I may","I owned","I've had","I've owned",
"subwoofer","amplifier","after market","installed",
"condition","contact","via","call","cell","telephone","phone",
"evening","morning","anytime","reach","email","text","number",
"owned","had this","my","photo","evidence","proof","photograph",
"picture","more info","hybrid","electric","customer",
"best offer","current offer","top offer","declined","decline",
"reject","refuse","owe","cash","money","$","no" ];
var names = [ "honda", "toyota", "ford","XLT","Escape","Chevy","Silverado","1500","2500","Edge","lariat","lariet",
"LT","LTZ","Crew Cab","Extended Cab","Dodge","Ram","quad cab","2006","2007",
"2008","2009","2010","2011","2012","2013","2014","2015","2016","fx4",
"Rav4","Jeep","Compass","Commander","Liberty","Wrangler","Unlimited","Limited","ltd","Sahara","Rubicon","Patriot",
"Acura","MDX","technology","RDX","xl","xlt","f150","f250","f350","f-150","f-250","f-350" ];
var brands = [ "Acura", "Audi", "Buick", "Cadillac", "Chevrolet", "Chevy", "Chrysler", "Dodge", "Ford", "GMC",
"Honda", "Hummer", "Hyundai", "Jeep", "Kia", "Land Rover", "Landrover", "Lexus", "Lincoln",
"Mazda", "Mercedes-Benz", "Mercedes", "Mercury", "Nissan", "Scion", "Subaru", "Toyota",
"Volkswagen", "VW", "Volvo" ];


_ready = function() {
_formatBody();
};

_formatBody = function(n) {
var body = n && $(n).closest('body') || $('body');

var instance = new Mark(document.querySelector("#postingbody"));
instance.mark(positive, {
accuracy: "exactly",
separateWordSearch: false,
className: "positive"
});
var instance = new Mark(document.querySelector("#postingbody"));
instance.mark(negative, {
accuracy: "exactly",
separateWordSearch: false,
className: "negative"
});

var instance = new Mark(document.querySelector("#postingbody"));
instance.mark(neutral, {
accuracy: "exactly",
separateWordSearch: false,
className: "neutral"
});
$('.positive').css({'color': '#0f6f00', 'font-weight': 'bold', "background-color":"transparent"});
$('.negative').css({'color': '#bd0000', 'font-weight': 'bold', "background-color":"transparent"});
$('.neutral').css({'font-weight':'bold', "background-color":"transparent"});

body.find('.mapbox, .tsb, footer').remove();

_checkValue(body);
};

是的,“重复”并没有真正包含那个人所犯的任何错误

最佳答案

因为您没有提供任何 HTML 来引用。

这是一个工作示例,说明如何突出显示传递给实例的数组中的单词。

var brands =   [ "Acura", "Audi", "Buick", "Cadillac", "Chevrolet", "Chevy", "Chrysler", "Dodge", "Ford", "GMC",
"Honda", "Hummer", "Hyundai", "Jeep", "Kia", "Land Rover", "Landrover", "Lexus", "Lincoln",
"Mazda", "Mercedes-Benz", "Mercedes", "Mercury", "Nissan", "Scion", "Subaru", "Toyota",
"Volkswagen", "VW", "Volvo" ];

var instance = new Mark(document.querySelector("body"));

instance.mark(brands, {
accuracy: {
value: "exactly",
limiters: [".", ",", "!"]
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/7.0.0/mark.min.js"></script>
<body>
<div>Hyundai Jeep Samsung Mercedes-Benz Nike Apple Nissan Scion!</div>
</body>

关于javascript - mark.js 不高亮单词?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38947828/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com