How to use replace method in redwood

Best JavaScript code snippet using redwood

G.replace.test.js

Source:G.replace.test.js Github

copy

Full Screen

...31`;32test('$.replace: simple code', () => {33 expect(() => {34 const G = $(CODE);35 G.replace('$_$.a()','$_$.b()')36 }).not.toThrow();37})38test('$.replace: simple code', () => {39 const G = $(CODE);40 G.replace('$_$.a()','$_$.b()');41 const code = G.generate();42 expect(code).toBe(COMPARE_CODE);43})44test('$.replace: this[0] is null', () => {45 expect(()=>{46 const G = $('var a = 1;');47 G[0] = null48 G.replace();49 }).not.toThrow();50})51test('$.replace: null', () => {52 expect(() => {53 const G = $(CODE);54 G.replace('$_$.a()',null)55 }).not.toThrow();56})57test('$.replace: no $_$', () => {58 expect(() => {59 const G = $(CODE);60 G.replace('$_$.a()','m.b()');61 }).not.toThrow();62})63test('$.replace: not find', () => {64 expect(() => {65 const G = $(CODE);66 G.replace('$_$.c()','m.b()');67 }).not.toThrow();68})69// TODO70// test('$.replace: replace head String should be ok', () => {71// const code = `'aaaa';`;72// const output = $(code).replace(`'aaaa'`, `'bbbb'`).generate();73// expect(output).toBe(`"bbbb"`);74// })75test('$.replace: simple1 js code result should be ok', () => {76 const G = $(jc1);77 const result = G.replace('const c = add();', 'const b = add();');78 const code = result.generate();79 expect(code.indexOf('const c = add()') < 0 && code.indexOf('const b = add()') > -1).toBeTruthy();80})81test('$.replace: simple2 js code result should be ok', () => {82 const G = $(jc2);83 const result = G.replace('this.updater.digest(loc);', 'this.updater.set(loc);');84 const code = result.generate();85 expect(code.indexOf('this.updater.digest(loc)') < 0 && code.indexOf('this.updater.set(loc)') > -1).toBeTruthy();86})87test('$.replace: simple2 js code, replace with multiple $_$ show throw error', () => {88 expect(() => {89 // 是否允许多个$_$ 出现?90 const G = $(jc2);91 const result = G.replace('$_$.updater.digest($_$);', '$_$.setData($_$);');92 const code = result.generate();93 }).not.toThrow();94})95test('$.replace: simple3 js code result should be ok', () =>{96 const code = $(jc3)97 .replace(`await $_$()`, `98 try {99 await $_$()100 } catch(e) {101 handleError()102 }`)103 .replace(`my.alert({104 title: $_$1,105 content: $_$2,106 success: $_$3107 })`, `this.alert($_$1, $_$2, $_$3)`)108 .generate();109 const result = code.indexOf('handleError()') > -1 && code.indexOf('this.alert(') > -1110 expect(result).toBeTruthy();111})112test('$.replace: simple3 js code with $$$ result should be ok', () =>{113 const code = $(jc3)114 .replace(`115 Page({116 onShow($_$1) {117 $$$1118 },119 $$$2120 })121 `, 122 `123 View.extend({124 init() {125 this.onInit();126 this.didMount();127 },128 render($_$1) {129 var a = 1130 $$$1131 },132 $$$2133 })134 `)135 .generate();136 const result = code.indexOf('View.extend(') > -1;137 expect(result).toBeTruthy();138})139test('$.replace: simple tryout js code replace width array should be ok', () =>{140 const code = $(jTryout)141 .replace([142 'var $_$ = Tryout.TRYOUT_SID_391',143 'let $_$ = Tryout.TRYOUT_SID_391',144 'const $_$ = Tryout.TRYOUT_SID_391'145 ], 'let $_$ = true;')146 .generate();147 const result = code.indexOf('let t1 = true') > -1 && code.indexOf('let t2 = true') > -1 && code.indexOf('let t3 = true') > -1148 expect(result).toBeTruthy();149})150test('$.replace: simple tryout js code result should be ok', () => {151 const code = $(jTryout)152 .replace(`Tryout.TRYOUT_SID_391 ? $_$1 : $_$2`, '$_$1')153 .generate();154 const result = code.indexOf('const t4 = 1') > -1155 expect(result).toBeTruthy();156})157test('$.replace: simple tryout js code result should be ok', () => {158 const code = $(jTryout)159 .replace(`!Tryout.TRYOUT_SID_391 ? $_$1 : $_$2`, '$_$2')160 .generate();161 const result = code.indexOf(`const t7 = "2"`) > -1 && code.indexOf(`const t8 = "2"`) > -1162 expect(result).toBeTruthy();163})164test('$.replace: simple js code result should be ok', () => {165 const CODE = `alert({166 type: 'error',167 content: '请填写必填项',168 done: () => {}169 })`;170 const code = $(CODE)171 .replace(`alert({ type: $_$1, done: $_$3, content: $_$2})`,172 `alert( $_$1, $_$2, $_$3 )`)173 .generate();174 const result = code.indexOf(`alert( 'error', '请填写必填项', () => {} )`) > -1 ;175 expect(result).toBeTruthy();176})177test('$.replace: replace use $$$ result should be ok', () => {178 const CODE = `alert({179 type: 'error',180 content: '请填写必填项',181 done: () => {}182 })`;183 const code = $(CODE)184 .replace(`alert($$$)`, `alert(this, $$$)`)185 .generate();186 const result = code.indexOf(`alert(this,`) > -1 ;187 expect(result).toBeTruthy();188})189test('$.replace: replace use $$$ result should be ok', () => {190 const CODE = `const code = Page({191 onShow() { },192 data: { }193 })`;194 const code = $(CODE)195 .replace(`Page({196 onShow() {197 $$$1 198 },199 $$$2200 })`, `Page({201 render() {202 $$$1203 },204 $$$2205 })`)206 .generate();207 const result = code.indexOf(`render()`) > -1 && code.indexOf(`onShow()`) < 0;208 expect(result).toBeTruthy();209})210test('$.replace: simple tryout js code if condition result should be ok', () => {211 const code = $(jTryout)212 .replace(`if(Tryout.TRYOUT_SID_391){$_$}`, '$_$')213 .generate();214 const result = code.indexOf(`if (Tryout.TRYOUT_SID_391)`) < 0215 expect(result).toBeTruthy();216})217test('$.replace: replace use callback function result should be ok', () => {218 const map = { input: 'textarea' } // 在map中有映射的才进行修改219 const code = $(`220 const componentList = [{221 index: 1,222 component: 'input'223 }, {224 index: 2,225 component: 'radio'226 }, {227 index: 3,228 component: 'checkbox'229 }]`)230 .replace('component: $_$', (match => {231 if (map[match[0][0].value]) {232 return `component: '${map[match[0][0].value]}'`233 } else {234 return 'component: $_$'235 }236 }))237 .generate();238 const result = code.indexOf(`component: 'input'`) < 0 && code.indexOf(`component: 'textarea'`) > -1;239 expect(result).toBeTruthy();240})241test('$.replace: use replace to insert code result should be ok', () => {242 const code = $(`243 Page({244 onShow() { },245 data: { }246 })`)247 .replace(`Page({248 $$$2249 })`, `Page({250 init() { 251 this.data = {} 252 },253 $$$2254 })`)255 .generate();256 const result = code.indexOf(`init()`) > -1;257 expect(result).toBeTruthy();258})259test('$.replace: replace import result should be ok', () => {260 const code = $(jc2)261 .replace(`import $_$ from 'moment';`, `import $_$ from 'gogocode';`)262 .generate();263 const result = code.indexOf(`'gogocode'`) > -1;264 expect(result).toBeTruthy();265})266test('$.replace: replace import result should be ok', () => {267 const code = $(jc2)268 .replace(`import { useContext, $$$ } from '@as/mdw-hk'`, `import { useFContext, $$$ } from '@as/mdw-hk'`)269 .generate();270 const result = code.indexOf(`{ useFContext, rest }`) > -1;271 expect(result).toBeTruthy();272})273test('$.replace: replace with multiple $_$', () => {274 const code = `this.$emit('input', e.target.value)`275 const compareCode = $(code)276 .replace(`$_$1.$emit('input',$$$1)`, `$_$1.$emit('update:modelValue', $$$1)`)277 .generate();278 expect(compareCode).toBe(`this.$emit('update:modelValue', e.target.value)`);279})280test('$.replace: replace with $_$ and $$$', () => {281 const code = `this.$emit('input', e.target.value)`282 const compareCode = $(code)283 .replace(`$_$1.$emit('input',$$$)`, `$_$1.$emit('update:modelValue',$$$)`)284 .generate();285 expect(compareCode).toBe(`this.$emit('update:modelValue',e.target.value)`);286})287test('$.replace: react js result should be ok', () => {288 let code = $(jReact.code)289 .replace(`import { $$$ } from "@alifd/next"`, `import { $$$ } from "antd"`)290 .replace(`<h2>转译前</h2>`, `<h2>转译后</h2>`)291 .replace(292 `<Button type="normal" $$$></Button>`,293 `<Button type="default" $$$></Button>`294 )295 .replace(296 `<Button size="medium" $$$></Button>`,297 `<Button size="middle" $$$></Button>`298 )299 .replace(`<Button text $$$></Button>`, `<Button type="link" $$$></Button>`)300 .replace(`<Button warning $$$></Button>`, `<Button danger $$$></Button>`)301 .generate();302 303 304 expect(code).toBe(jReact.compareCode);305})306test('$.replace: replace attr result should be ok', () => {307 let code = $(jc4)308 .replace(309 '{ text: $_$1, value: $_$2, $$$ }',310 '{ name: $_$1, id: $_$2, $$$ }'311 )312 .generate();313 const result = code.indexOf('text:') < 0 && code.indexOf('name:') > -1 &&314 code.indexOf('value:') < 0 && code.indexOf('id:') > -1 && 315 code.indexOf('tips:') > -1316 expect(result).toBeTruthy();317})318test('$.replace: replace like remove result should be ok', () => {319 let code = $(jc1)320 .replace(321 `const XXMonitor = require($_$);`,322 ''323 )324 .generate();325 const result = code.indexOf(`const XXMonitor = require('../monitor');`) < 0 326 expect(result).toBeTruthy();327})328// test('$.replace: simple tryout js code if condition with $$$ result should be ok', () => {329// // 貌似这种情况不太可能支持330// const code = $(jTryout)331// .replace(`if(Tryout.TRYOUT_SID_391 $$$){$_$}`, 'if($$$){$_$}')332// .root()333// .generate();334// const result = code.indexOf(`if (Tryout.TRYOUT_SID_391`) < 0335// expect(result).toBeTruthy();336// })337// test('$.replace: simple tryout js code if condition with $$$ result should be ok', () => {338// // 貌似这种情况不太可能支持339// const code = $(jTryout)340// .replace(`if(!Tryout.TRYOUT_SID_391 $$$){$_$}`, 'if(false $$$){$_$}')341// .root()342// .generate();343// const result = code.indexOf(`if (!Tryout.TRYOUT_SID_391`) < 0344// expect(result).toBeTruthy();345// })346test('$.replace: replace with $_$', () => {347 const G = $(jc2);348 const result = G.replace(`import $_$ from 'moment';`, `import $_$ from 'new_moment';`);349 const code = result.generate();350 expect(code.indexOf(`import moment from 'moment';`) < 0 &&351 code.indexOf(`import moment from 'new_moment';`) > -1).toBeTruthy();352})353test('$.replace: simple1 html code', () => {354 expect(() => {355 const G = $(hc1, config.html);356 G.replace('<span>test</span>','<span>replace</span>');357 }).not.toThrow();358})359test('$.replace: simple1 html code, replacer is empty should throw error', () => {360 expect(() => {361 const G = $(hc1, config.html);362 G.replace('<span>test</span>');363 }).not.toThrow();364})365test('$.replace: simple1 html code, replacer is ast node should not throw error', () => {366 expect(() => {367 const G = $(hc1, config.html);368 G.replace('<span>test</span>',$('<div>test</div>', config.html).node);369 }).not.toThrow();370})371test('$.replace: simple1 html code, replacer is ast node result should be ok', () => {372 const G = $(hc1, config.html);373 const replacer = $('<div>test</div>', config.html).node;374 const code = G.replace('<span>test</span>', replacer).generate();375 expect(code.indexOf('<span>test</span>') < 0).toBeTruthy();376})377test('$.replace: simple1 html code result should be ok', () => {378 const G = $(hc1, config.html);379 G.replace('<span>test</span>','<span>replace</span>');380 const code = G.generate();381 expect(code.indexOf('<span>test</span>') < 0 && code.indexOf('<span>replace</span>') > -1).toBeTruthy();382})383test('$.replace: simple1 html code use $_$ result should be ok', () => {384 const G = $(hc1, config.html);385 G.replace('<span>$_$</span>','<i>$_$</i>');386 const code = G.generate();387 expect(code.indexOf('<i>test</i>') > -1).toBeTruthy();388})389// test('$.replace: replace html tag result should be ok', () => {390// const G = $(hc1, config.html);391// const code = G.replace('<form $$$1>$$$2</form>','<mx-form $$$1>$$$2</mx-form>').generate();392// expect(code.indexOf('<form') < 0 && code.indexOf('<mx-form') > -1).toBeTruthy();393// })394// TODO395// test('$.replace: simple1 html code use $_$ result should be ok', () => {396// const G = $(hc1, config.html);397// const code = G.replace('<form id=$_$1 $$$>$_$2</form>','<div formId=$_$1 $$$>$_$2</div>').root().generate();398// expect(code.indexOf(`<div formId="myform" class="mt10" style="margin-top:10px;"`) > -1).toBeTruthy();399// })400test('$.replace: jsx tag replace should be ok', () => {401 const G = $(`<a v="1"></a>`);402 const res = G.replace('<$_$1 $$$1>$$$2</$_$1>', '<$_$1 $$$1>$$$2 ssssss</$_$1>').generate()403 expect(res.indexOf('ssssss') > -1).toBeTruthy();404})405test('$.replace: class replace should be ok', () => {406 const res = $(`import { MM } from "@mm"407 import { loaders } from 'p.js'408 export class Sc extends MMG {409 constructor(options) {410 super(options);411 }412 413 onInited() {414 415 }416 /**417 * 初始化加载器418 */419 initLoader() {420 421 const textureLoader = new loaders.Loader();422 423 textureLoader.load();424 }425 }426 `).replace(`initLoader(){$$$}`, `abc() {427 $$$428 }`).generate()429 expect(res.indexOf('abc') > -1).toBeTruthy();430})431test('$.replace: class replace should be ok', () => {432 const res = $('<div></div>', {parseOptions: { html: true}}).replace(`<div $$$1>$$$2</div>`, 433 `<div mx-view="xxx" $$$1> $$$2</div>`).generate()434 expect(res.indexOf('xxx') > -1).toBeTruthy();435})436test('$.replace: class replace should be ok', () => {437 // const res = $(`438 // getApp().globalData.eventEmmit.emit("openTasks",{} );439 // `, {parseOptions: { html: true}}).replace(`<div $$$1>$$$2</div>`, 440 // `<div mx-view="xxx" $$$1> $$$2</div>`).generate()441 // expect(res.indexOf('xxx') > -1).toBeTruthy();442})443test('$.replace: class replace should be ok', () => {444 const res = $(`445 const a = {446 aaa: 1,447 bbb: 2,448 }449 `).replace('aaa: 1', '')450 .generate()451 expect(res.indexOf(',') == -1).toBeTruthy();452})453test('$.replace: class replace should be ok', () => {454 const res = $(`455 import a from 'a';456 console.log('get A');457 var b = console.log();458 console.log.bind();459 var c = console.log;460 console.log = func;461 `)462 .replace(`var $_$ = console.log()`, `var $_$ = void 0`)463 .replace(`var $_$ = console.log`, `var $_$ = function(){};`)464 .find(`console.log()`)465 .remove()466 .generate();467 expect(res.match(/;/g).length == 4).toBeTruthy();468})469test('$.replace: class replace should be ok', () => {470 const res = $(`471 import a from 'a';console.log('get A');var b = console.log();console.log.bind();var c = console.log;console.log = func;472 `)473 .replace(`var $_$ = console.log()`, `var $_$ = void 0;`)474 .replace(`var $_$ = console.log`, `var $_$ = function(){};`)475 .find(`console.log()`)476 .remove()477 .generate();478 expect(res.indexOf(`import a from 'a';var b = void 0;console.log.bind();var c = function(){};console.log = func;`) > -1).toBeTruthy();479})480test('$.replace: class replace should be ok', () => {481 const res = $(`482 import * as ctx from '@ali/midway-hooks';483 import { useContext } from '@ali/midway-hooks';484 import ctx2 from '@ali/midway-hooks'485 import a, { b, c } from '@ali/midway-hooks'486 `)487 .replace(`import $_$ from "@ali/midway-hooks"`, `import $_$ from "@al/hooks"`)488 .replace(`import * as $_$ from "@ali/midway-hooks"`, `import * as $_$ from "@al/hooks"`)489 .replace(`import { $$$ } from "@ali/midway-hooks"`, `import { $$$ } from "@al/hooks"`)490 .generate();491 // TODO492 expect(res.match(/\@al\/hooks/g).length == 4).toBeTruthy();493})494test('$.replace: class replace should be ok', () => {495 const res = $(`496 import * as ctx from '@ali/midway-hooks';497 import { useContext } from '@ali/midway-hooks';498 import ctx2 from '@ali/midway-hooks'499 `)500 .replace(`import $_$ from "@ali/midway-hooks"`, `import $_$ from "@al/hooks"`)501 .replace(`import * as $_$ from "@ali/midway-hooks"`, `import * as $_$ from "@al/hooks"`)502 .replace(`import { $$$ } from "@ali/midway-hooks"`, `import { $$$ } from "@al/hooks"`)503 .generate();504 expect(res.match(/\@al\/hooks/g).length == 3).toBeTruthy();505})506test('$.replace: class replace should be ok', () => {507 const res = $(`508 import * as ctx from '@ali/midway-hooks';509 import { useContext } from '@ali/midway-hooks';510 import ctx2 from '@ali/midway-hooks'511 `)512 .replace(`import $_$ from "@ali/midway-hooks"`, `import $_$ from "@al/hooks"`)513 .replace(`import * as $_$ from "@ali/midway-hooks"`, `import * as $_$ from "@al/hooks"`)514 .generate();515 expect(res.match(/\@al\/hooks/g).length == 2).toBeTruthy();516})517test('$.replace: class replace should be ok', () => {518 const res = $(`519 import * as ctx from '@ali/midway-hooks';520 import { useContext } from '@ali/midway-hooks';521 import ctx2 from '@ali/midway-hooks'522 `)523 .replace(`import $_$ from "@ali/midway-hooks"`, `import $_$ from "@al/hooks"`)524 .generate();525 expect(res.match(/\@al\/hooks/g).length == 1).toBeTruthy();526})527test('$.replace: class replace should be ok', () => {528 const res = $(`const a = b?.s?.c?.e`)529 .replace(`$_$1?.$_$2`, `$_$1 ? $_$1.$_$2 : null`)530 .generate();531 expect(res.indexOf('const a = b?.s?.c ? b?.s?.c.e : null') > -1).toBeTruthy();532})533test('$.replace: class replace should be ok', () => {534 const res = $(`535 "use strict";536 module.exports = app => {537 const mongoose = app.mongoose;538 const BrandSchema = new Schema({539 name: { type: String }540 });541 542 const Brand = mongoose.model('Brand');543 544 return Brand;545 };546 `)547 .replace(`module.exports = () => $_$`, `$_$`)548 .replace(`return $_$`, `module.exports = $_$`)549 .before(`const app = require('mongoose')`)550 .generate();551 expect(res.indexOf('module.exports = Brand') > -1 && res.indexOf('module.exports = app') == -1).toBeTruthy();552})553test('$.replace: replace arguments should not throw error', () => {554 const code = `555 this.$emit("input", date, {556 type: "CUSTOM",557 value: date558 });559 `;560 expect(() => {561 const res = $(code)562 .replace(`$_$1.$emit('input',$$$)`, `$_$1.$emit('update:modelValue',$$$)`)563 }).not.toThrow();564})565test('$.replace: replace arguments should not throw error', () => {566 const code = `(v) => Boolean(v.text)`;567 const res = $(code)568 .replace('() => import($_$)', 'Vue.defineAsyncComponent(() => import($_$))').generate()569 expect(res.match(/Boolean\(v\.text\)/)).toBeTruthy();570})571test('$.replace: replace arguments should not throw error', () => {572 const code = `573 Vue.directive('a', 'b', {574 bind(a) {575 }576 })`;577 expect(() => {578 $(code)579 .replace(580 `581 Vue.directive($$$1, {582 bind($_$2) {583 $$$2584 },585 $$$3586 },587 )`,588 `589 Vue.directive($$$1, {590 beforeMount($_$2) {591 $$$2592 },593 $$$3594 },595 )596 `597 )598 }).not.toThrow();599})600test('$.replace: replace arguments should not throw error', () => {601 const code = `Vue.set(state.items, item.id, item)`;602 const res = $(code)603 .replace(`Vue.set($_$1,$_$2,$_$3)`, `$_$1[$_$2] = $_$3`).generate()604 expect(res == 'state.items[item.id] = item;').toBeTruthy();605})606test('$.replace: replace object', () => {607 const code = `608 VueRouter.createRouter({609 routes,610 history: VueRouter.createWebHistory(),611 base: '/root'612 })`;613 const res = $(code)614 .replace(`{history: VueRouter.createWebHistory(), base: $_$,$$$}`,615 `{history: VueRouter.createWebHistory($_$),$$$}`)616 .root()617 .generate()618 expect(res.indexOf('({history') > -1).toBeTruthy();619})620test('$.replace: html tag replace should be ok', () => {621 const G = $(`<a v="1"></a>`, { parseOptons: { language: 'html' }});622 const res = G.replace('<$_$1 $$$1>$$$2</$_$1>', '<$_$1 $$$1>$$$2 ssssss</$_$1>').generate()623 expect(res.indexOf('ssssss') > -1).toBeTruthy();624})625test('$.replace: html attr replace should be ok', () => {626 const G = $(`<a v="1"></a>`, { parseOptons: { language: 'html' }});627 const res = G.replace('<$_$1 v="$_$2" $$$1>$$$2</$_$1>', '<$_$1 v="$_$2" v2="$_$2" $$$1>$$$2 ssssss</$_$1>').generate()628 expect(res.indexOf("v2='1'") > -1).toBeTruthy();629})630test('$.replace: this replace should be ok', () => {631 let res = $(`632 this.ddd = 2633 sss.ddd = 3634 xxx.ddd = 4635 `)636 .replace('this.$_$', 'ggg.$_$')637 .generate();638 expect(res.match(/ggg/g).length == 1).toBeTruthy();639})640test('$.replace: scope replace should be ok', () => {641 const res = $(`642 var n = {};643 n.n = square(10);644 function ajax(){645 console.log(n)646 const {a, n} = obj;647 console.log("没想到吧,我又来了", n)648 $.ajax({649 url:"",650 success:function(n){651 console.log(n)652 }653 })654 }655 function test(n) {656 n = 5657 }658 function test2() {659 n = 5660 }661 function square(n) {662 return n * n;663 }664 `)665 .find('n')666 .each(n => {667 if (n[0].nodePath.scope.lookup('n') && n[0].nodePath.scope.lookup('n').isGlobal && n[0].nodePath.name !== 'property') {668 n.replaceBy('x')669 }670 })671 .root()672 .generate()673 expect(res.match(/x/g).length == 5).toBeTruthy();674})675test('$.replace: this replace should be ok', () => {676 let res = $(`677 var isTrue = !0;678 var isFalse = !1;679 `)680 .replace('!0', 'true')681 .generate();682 expect(res.match(/true/g).length == 1).toBeTruthy();683})684test('$.replace: this replace should be ok', () => {685 let res = $(`686 export default {687 init() {688 let strMap = {689 borrowCDBMoney: ['押金', '$元'],690 gratisTime: ['免费时间', '$'],691 borrowPay: ['起步收费', '$'],692 hourPay: ['超时收费', '$'],693 buyLinePay: ['充电线', '$元/条'],694 presentLineType: ['购线券', '$'],695 dayMaxPay: ['每日上限', '$元'],696 chargeType: ['收费模式', '$']697 }698 },699 }700 `)701 .replace(`export default {$$$}`, `export default {$$$,emits:['remark']}`).generate()702 expect(res.match(/remark/g).length == 1).toBeTruthy();703})704test('$.replace: this replace should be ok', () => {705 let res = $(`706 <td class="abc"><td>707 `, { parseOptions: { language: 'html' } })708 .replace('<td class="abc"><td>', '<tag>xxx</tag>')709 .generate()710 expect(res.match(/tag/g).length == 2).toBeTruthy();711})712test('$.replace: this replace should be ok', () => {713 let res = $(`714 enum TYPE {715 A = 1,716 B = 2,717 C = 3718 }`)719 .replace('enum TYPE { $$$ }', 'enum TYPE { $$$, D = 4 }')720 .generate()721 expect(res.match('D = 4')).toBeTruthy()722})723test('parse html data-id', () => {724 let res = $(`725 <div>726 <block class="zpzp" data-id="zpid">我是内容</block>727 <block class="zp" data-id="zpid">我也是内容</block>728 <block class="zp" data-id="zpid">打酱油的来了</block>729 </div>730 `, { parseOptions: { language: 'html' } })731 .replace(732 '<$_$1 class="$_$2" $$$1>$$$2</$_$1>',733 '<$_$1 $$$1>$$$2</$_$1>'734 )735 .replace(736 '<$_$1 data-id="$_$2" $$$1>$$$2</$_$1>',737 '<$_$1 $$$1>$$$2</$_$1>'738 )739 .generate()740 console.log(res)741 expect(!res.match('data-id')).toBeTruthy()742})743test('parse html replace comments', () => {744 let res = $(`745 <div class="a">1</div>746 <div class="a">2</div>747 <!-- <view>TEST</view> -->748 `, { parseOptions: { language: 'html' } })749 .replace('<view></view>', '<div>也替换了嘛?算正常不?</div>')750 .generate()751 expect(!!res.match('view')).toBeTruthy()...

Full Screen

Full Screen

vkbeautify.js

Source:vkbeautify.js Github

copy

Full Screen

...75 this.step = '\t'; // 4 spaces76 this.shift = createShiftArr(this.step);77};78vkbeautify.prototype.xml = function(text,step) {79 var ar = text.replace(/>\s{0,}</g,"><")80 .replace(/</g,"~::~<")81 .replace(/\s*xmlns\:/g,"~::~xmlns:")82 .replace(/\s*xmlns\=/g,"~::~xmlns=")83 .split('~::~'),84 len = ar.length,85 inComment = false,86 deep = 0,87 str = '',88 ix = 0,89 shift = step ? createShiftArr(step) : this.shift;90 for(ix=0;ix<len;ix++) {91 // start comment or <![CDATA[...]]> or <!DOCTYPE //92 if(ar[ix].search(/<!/) > -1) { 93 str += shift[deep]+ar[ix];94 inComment = true; 95 // end comment or <![CDATA[...]]> //96 if(ar[ix].search(/-->/) > -1 || ar[ix].search(/\]>/) > -1 || ar[ix].search(/!DOCTYPE/) > -1 ) { 97 inComment = false; 98 }99 } else 100 // end comment or <![CDATA[...]]> //101 if(ar[ix].search(/-->/) > -1 || ar[ix].search(/\]>/) > -1) { 102 str += ar[ix];103 inComment = false; 104 } else 105 // <elm></elm> //106 if( /^<\w/.exec(ar[ix-1]) && /^<\/\w/.exec(ar[ix]) &&107 /^<[\w:\-\.\,]+/.exec(ar[ix-1]) == /^<\/[\w:\-\.\,]+/.exec(ar[ix])[0].replace('/','')) { 108 str += ar[ix];109 if(!inComment) deep--;110 } else111 // <elm> //112 if(ar[ix].search(/<\w/) > -1 && ar[ix].search(/<\//) == -1 && ar[ix].search(/\/>/) == -1 ) {113 str = !inComment ? str += shift[deep++]+ar[ix] : str += ar[ix];114 } else 115 // <elm>...</elm> //116 if(ar[ix].search(/<\w/) > -1 && ar[ix].search(/<\//) > -1) {117 str = !inComment ? str += shift[deep]+ar[ix] : str += ar[ix];118 } else 119 // </elm> //120 if(ar[ix].search(/<\//) > -1) { 121 str = !inComment ? str += shift[--deep]+ar[ix] : str += ar[ix];122 } else 123 // <elm/> //124 if(ar[ix].search(/\/>/) > -1 ) { 125 str = !inComment ? str += shift[deep]+ar[ix] : str += ar[ix];126 } else 127 // <? xml ... ?> //128 if(ar[ix].search(/<\?/) > -1) { 129 str += shift[deep]+ar[ix];130 } else 131 // xmlns //132 if( ar[ix].search(/xmlns\:/) > -1 || ar[ix].search(/xmlns\=/) > -1) { 133 str += shift[deep]+ar[ix];134 } 135 136 else {137 str += ar[ix];138 }139 }140 141 return (str[0] == '\n') ? str.slice(1) : str;142}143vkbeautify.prototype.json = function(text,step) {144 var step = step ? step : this.step;145 146 if (typeof JSON === 'undefined' ) return text; 147 148 if ( typeof text === "string" ) return JSON.stringify(JSON.parse(text), null, step);149 if ( typeof text === "object" ) return JSON.stringify(text, null, step);150 151 return text; // text is not string nor object152}153vkbeautify.prototype.css = function(text, step) {154 var ar = text.replace(/\s{1,}/g,' ')155 .replace(/\{/g,"{~::~")156 .replace(/\}/g,"~::~}~::~")157 .replace(/\;/g,";~::~")158 .replace(/\/\*/g,"~::~/*")159 .replace(/\*\//g,"*/~::~")160 .replace(/~::~\s{0,}~::~/g,"~::~")161 .split('~::~'),162 len = ar.length,163 deep = 0,164 str = '',165 ix = 0,166 shift = step ? createShiftArr(step) : this.shift;167 168 for(ix=0;ix<len;ix++) {169 if( /\{/.exec(ar[ix])) { 170 str += shift[deep++]+ar[ix];171 } else 172 if( /\}/.exec(ar[ix])) { 173 str += shift[--deep]+ar[ix];174 } else175 if( /\*\\/.exec(ar[ix])) { 176 str += shift[deep]+ar[ix];177 }178 else {179 str += shift[deep]+ar[ix];180 }181 }182 return str.replace(/^\n{1,}/,'');183}184//----------------------------------------------------------------------------185function isSubquery(str, parenthesisLevel) {186 return parenthesisLevel - (str.replace(/\(/g,'').length - str.replace(/\)/g,'').length )187}188function split_sql(str, tab) {189 return str.replace(/\s{1,}/g," ")190 .replace(/ AND /ig,"~::~"+tab+tab+"AND ")191 .replace(/ BETWEEN /ig,"~::~"+tab+"BETWEEN ")192 .replace(/ CASE /ig,"~::~"+tab+"CASE ")193 .replace(/ ELSE /ig,"~::~"+tab+"ELSE ")194 .replace(/ END /ig,"~::~"+tab+"END ")195 .replace(/ FROM /ig,"~::~FROM ")196 .replace(/ GROUP\s{1,}BY/ig,"~::~GROUP BY ")197 .replace(/ HAVING /ig,"~::~HAVING ")198 //.replace(/ SET /ig," SET~::~")199 .replace(/ IN /ig," IN ")200 201 .replace(/ JOIN /ig,"~::~JOIN ")202 .replace(/ CROSS~::~{1,}JOIN /ig,"~::~CROSS JOIN ")203 .replace(/ INNER~::~{1,}JOIN /ig,"~::~INNER JOIN ")204 .replace(/ LEFT~::~{1,}JOIN /ig,"~::~LEFT JOIN ")205 .replace(/ RIGHT~::~{1,}JOIN /ig,"~::~RIGHT JOIN ")206 207 .replace(/ ON /ig,"~::~"+tab+"ON ")208 .replace(/ OR /ig,"~::~"+tab+tab+"OR ")209 .replace(/ ORDER\s{1,}BY/ig,"~::~ORDER BY ")210 .replace(/ OVER /ig,"~::~"+tab+"OVER ")211 .replace(/\(\s{0,}SELECT /ig,"~::~(SELECT ")212 .replace(/\)\s{0,}SELECT /ig,")~::~SELECT ")213 214 .replace(/ THEN /ig," THEN~::~"+tab+"")215 .replace(/ UNION\s*/ig,"~::~UNION~::~")216 .replace(/~::~UNION~::~ALL /ig,"~::~UNION ALL~::~")217 .replace(/ USING /ig,"~::~USING ")218 .replace(/ WHEN /ig,"~::~"+tab+"WHEN ")219 .replace(/ WHERE /ig,"~::~WHERE ")220 .replace(/ WITH /ig,"~::~WITH ")221 222 //.replace(/\,\s{0,}\(/ig,",~::~( ")223 //.replace(/\,/ig,",~::~"+tab+tab+"")224 .replace(/ ALL /ig," ALL ")225 .replace(/ AS /ig," AS ")226 .replace(/ ASC /ig," ASC ") 227 .replace(/ DESC /ig," DESC ") 228 .replace(/ DISTINCT /ig," DISTINCT ")229 .replace(/ EXISTS /ig," EXISTS ")230 .replace(/ NOT /ig," NOT ")231 .replace(/ NULL /ig," NULL ")232 .replace(/ LIKE /ig," LIKE ")233 .replace(/\s{0,}SELECT /ig,"SELECT ")234 .replace(/\s{0,}UPDATE /ig,"UPDATE ")235 .replace(/ SET /ig," SET ")236 237 .replace(/~::~{1,}/g,"~::~")238 .split('~::~');239}240vkbeautify.prototype.sql = function(text,step) {241 var ar_by_quote = text.replace(/\s{1,}/g," ")242 .replace(/\'/ig,"~::~\'")243 .split('~::~'),244 len = ar_by_quote.length,245 ar = [],246 deep = 0,247 tab = this.step,//+this.step,248 inComment = true,249 inQuote = false,250 parenthesisLevel = 0,251 str = '',252 ix = 0,253 shift = step ? createShiftArr(step) : this.shift;;254 for(ix=0;ix<len;ix++) {255 if(ix%2) {256 ar = ar.concat(ar_by_quote[ix]);257 } else {258 ar = ar.concat(split_sql(ar_by_quote[ix], tab) );259 }260 }261 262 len = ar.length;263 for(ix=0;ix<len;ix++) {264 265 parenthesisLevel = isSubquery(ar[ix], parenthesisLevel);266 267 if( /\s{0,}\s{0,}SELECT\s{0,}/.exec(ar[ix])) { 268 ar[ix] = ar[ix].replace(/\,/g,",\n"+tab+tab+"")269 } 270 271 if( /\s{0,}\s{0,}SET\s{0,}/.exec(ar[ix])) { 272 ar[ix] = ar[ix].replace(/\,/g,",\n"+tab+tab+"")273 } 274 275 if( /\s{0,}\(\s{0,}SELECT\s{0,}/.exec(ar[ix])) { 276 deep++;277 str += shift[deep]+ar[ix];278 } else 279 if( /\'/.exec(ar[ix]) ) { 280 if(parenthesisLevel<1 && deep) {281 deep--;282 }283 str += ar[ix];284 }285 else { 286 str += shift[deep]+ar[ix];287 if(parenthesisLevel<1 && deep) {288 deep--;289 }290 } 291 var junk = 0;292 }293 str = str.replace(/^\n{1,}/,'').replace(/\n{1,}/g,"\n");294 return str;295}296vkbeautify.prototype.xmlmin = function(text, preserveComments) {297 var str = preserveComments ? text298 : text.replace(/\<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>/g,"")299 .replace(/[ \r\n\t]{1,}xmlns/g, ' xmlns');300 return str.replace(/>\s{0,}</g,"><"); 301}302vkbeautify.prototype.jsonmin = function(text) {303 if (typeof JSON === 'undefined' ) return text; 304 305 return JSON.stringify(JSON.parse(text), null, 0); 306 307}308vkbeautify.prototype.cssmin = function(text, preserveComments) {309 310 var str = preserveComments ? text311 : text.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\//g,"") ;312 return str.replace(/\s{1,}/g,' ')313 .replace(/\{\s{1,}/g,"{")314 .replace(/\}\s{1,}/g,"}")315 .replace(/\;\s{1,}/g,";")316 .replace(/\/\*\s{1,}/g,"/*")317 .replace(/\*\/\s{1,}/g,"*/");318}319vkbeautify.prototype.sqlmin = function(text) {320 return text.replace(/\s{1,}/g," ").replace(/\s{1,}\(/,"(").replace(/\s{1,}\)/,")");321}322window.vkbeautify = new vkbeautify();...

Full Screen

Full Screen

showdown.js

Source:showdown.js Github

copy

Full Screen

...12this.makeHtml=function(_5){13_1=new Array();14_2=new Array();15_3=new Array();16_5=_5.replace(/~/g,"~T");17_5=_5.replace(/\$/g,"~D");18_5=_5.replace(/\r\n/g,"\n");19_5=_5.replace(/\r/g,"\n");20_5="\n\n"+_5+"\n\n";21_5=_6(_5);22_5=_5.replace(/^[ \t]+$/mg,"");23_5=_7(_5);24_5=_8(_5);25_5=_9(_5);26_5=_a(_5);27_5=_5.replace(/~D/g,"$$");28_5=_5.replace(/~T/g,"~");29return _5;30};31var _8=function(_b){32var _b=_b.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,function(_c,m1,m2,m3,m4){33m1=m1.toLowerCase();34_1[m1]=_11(m2);35if(m3){36return m3+m4;37}else{38if(m4){39_2[m1]=m4.replace(/"/g,"&quot;");40}41}42return "";43});44return _b;45};46var _7=function(_12){47_12=_12.replace(/\n/g,"\n\n");48var _13="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del";49var _14="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math";50_12=_12.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,_15);51_12=_12.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,_15);52_12=_12.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,_15);53_12=_12.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,_15);54_12=_12.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,_15);55_12=_12.replace(/\n\n/g,"\n");56return _12;57};58var _15=function(_16,m1){59var _18=m1;60_18=_18.replace(/\n\n/g,"\n");61_18=_18.replace(/^\n/,"");62_18=_18.replace(/\n+$/g,"");63_18="\n\n~K"+(_3.push(_18)-1)+"K\n\n";64return _18;65};66var _9=function(_19){67_19=_1a(_19);68var key=_1c("<hr />");69_19=_19.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,key);70_19=_19.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,key);71_19=_19.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key);72_19=_1d(_19);73_19=_1e(_19);74_19=_1f(_19);75_19=_7(_19);76_19=_20(_19);77return _19;78};79var _21=function(_22){80_22=_23(_22);81_22=_24(_22);82_22=_25(_22);83_22=_26(_22);84_22=_27(_22);85_22=_28(_22);86_22=_11(_22);87_22=_29(_22);88_22=_22.replace(/ +\n/g," <br />\n");89return _22;90};91var _24=function(_2a){92var _2b=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;93_2a=_2a.replace(_2b,function(_2c){94var tag=_2c.replace(/(.)<\/?code>(?=.)/g,"$1`");95tag=_2e(tag,"\\`*_");96return tag;97});98return _2a;99};100var _27=function(_2f){101_2f=_2f.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,_30);102_2f=_2f.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,_30);103_2f=_2f.replace(/(\[([^\[\]]+)\])()()()()()/g,_30);104return _2f;105};106var _30=function(_31,m1,m2,m3,m4,m5,m6,m7){107if(m7==undefined){108m7="";109}110var _39=m1;111var _3a=m2;112var _3b=m3.toLowerCase();113var url=m4;114var _3d=m7;115if(url==""){116if(_3b==""){117_3b=_3a.toLowerCase().replace(/ ?\n/g," ");118}119url="#"+_3b;120if(_1[_3b]!=undefined){121url=_1[_3b];122if(_2[_3b]!=undefined){123_3d=_2[_3b];124}125}else{126if(_39.search(/\(\s*\)$/m)>-1){127url="";128}else{129return _39;130}131}132}133url=_2e(url,"*_");134var _3e="<a href=\""+url+"\"";135if(_3d!=""){136_3d=_3d.replace(/"/g,"&quot;");137_3d=_2e(_3d,"*_");138_3e+=" title=\""+_3d+"\"";139}140_3e+=">"+_3a+"</a>";141return _3e;142};143var _26=function(_3f){144_3f=_3f.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,_40);145_3f=_3f.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,_40);146return _3f;147};148var _40=function(_41,m1,m2,m3,m4,m5,m6,m7){149var _49=m1;150var _4a=m2;151var _4b=m3.toLowerCase();152var url=m4;153var _4d=m7;154if(!_4d){155_4d="";156}157if(url==""){158if(_4b==""){159_4b=_4a.toLowerCase().replace(/ ?\n/g," ");160}161url="#"+_4b;162if(_1[_4b]!=undefined){163url=_1[_4b];164if(_2[_4b]!=undefined){165_4d=_2[_4b];166}167}else{168return _49;169}170}171_4a=_4a.replace(/"/g,"&quot;");172url=_2e(url,"*_");173var _4e="<img src=\""+url+"\" alt=\""+_4a+"\"";174_4d=_4d.replace(/"/g,"&quot;");175_4d=_2e(_4d,"*_");176_4e+=" title=\""+_4d+"\"";177_4e+=" />";178return _4e;179};180var _1a=function(_4f){181_4f=_4f.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,function(_50,m1){182return _1c("<h1>"+_21(m1)+"</h1>");183});184_4f=_4f.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(_52,m1){185return _1c("<h2>"+_21(m1)+"</h2>");186});187_4f=_4f.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(_54,m1,m2){188var _57=m1.length;189return _1c("<h"+_57+">"+_21(m2)+"</h"+_57+">");190});191return _4f;192};193var _58;194var _1d=function(_59){195_59+="~0";196var _5a=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;197if(_4){198_59=_59.replace(_5a,function(_5b,m1,m2){199var _5e=m1;200var _5f=(m2.search(/[*+-]/g)>-1)?"ul":"ol";201_5e=_5e.replace(/\n{2,}/g,"\n\n\n");202var _60=_58(_5e);203_60=_60.replace(/\s+$/,"");204_60="<"+_5f+">"+_60+"</"+_5f+">\n";205return _60;206});207}else{208_5a=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;209_59=_59.replace(_5a,function(_61,m1,m2,m3){210var _65=m1;211var _66=m2;212var _67=(m3.search(/[*+-]/g)>-1)?"ul":"ol";213var _66=_66.replace(/\n{2,}/g,"\n\n\n");214var _68=_58(_66);215_68=_65+"<"+_67+">\n"+_68+"</"+_67+">\n";216return _68;217});218}219_59=_59.replace(/~0/,"");220return _59;221};222_58=function(_69){223_4++;224_69=_69.replace(/\n{2,}$/,"\n");225_69+="~0";226_69=_69.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,function(_6a,m1,m2,m3,m4){227var _6f=m4;228var _70=m1;229var _71=m2;230if(_70||(_6f.search(/\n{2,}/)>-1)){231_6f=_9(_72(_6f));232}else{233_6f=_1d(_72(_6f));234_6f=_6f.replace(/\n$/,"");235_6f=_21(_6f);236}237return "<li>"+_6f+"</li>\n";238});239_69=_69.replace(/~0/g,"");240_4--;241return _69;242};243var _1e=function(_73){244_73+="~0";245_73=_73.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(_74,m1,m2){246var _77=m1;247var _78=m2;248_77=_79(_72(_77));249_77=_6(_77);250_77=_77.replace(/^\n+/g,"");251_77=_77.replace(/\n+$/g,"");252_77="<pre><code>"+_77+"\n</code></pre>";253return _1c(_77)+_78;254});255_73=_73.replace(/~0/,"");256return _73;257};258var _1c=function(_7a){259_7a=_7a.replace(/(^\n+|\n+$)/g,"");260return "\n\n~K"+(_3.push(_7a)-1)+"K\n\n";261};262var _23=function(_7b){263_7b=_7b.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(_7c,m1,m2,m3,m4){264var c=m3;265c=c.replace(/^([ \t]*)/g,"");266c=c.replace(/[ \t]*$/g,"");267c=_79(c);268return m1+"<code>"+c+"</code>";269});270return _7b;271};272var _79=function(_82){273_82=_82.replace(/&/g,"&amp;");274_82=_82.replace(/</g,"&lt;");275_82=_82.replace(/>/g,"&gt;");276_82=_2e(_82,"*_{}[]\\",false);277return _82;278};279var _29=function(_83){280_83=_83.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"<strong>$2</strong>");281_83=_83.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"<em>$2</em>");282return _83;283};284var _1f=function(_84){285_84=_84.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(_85,m1){286var bq=m1;287bq=bq.replace(/^[ \t]*>[ \t]?/gm,"~0");288bq=bq.replace(/~0/g,"");289bq=bq.replace(/^[ \t]+$/gm,"");290bq=_9(bq);291bq=bq.replace(/(^|\n)/g,"$1 ");292bq=bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,function(_88,m1){293var pre=m1;294pre=pre.replace(/^ /mg,"~0");295pre=pre.replace(/~0/g,"");296return pre;297});298return _1c("<blockquote>\n"+bq+"\n</blockquote>");299});300return _84;301};302var _20=function(_8b){303_8b=_8b.replace(/^\n+/g,"");304_8b=_8b.replace(/\n+$/g,"");305var _8c=_8b.split(/\n{2,}/g);306var _8d=new Array();307var end=_8c.length;308for(var i=0;i<end;i++){309var str=_8c[i];310if(str.search(/~K(\d+)K/g)>=0){311_8d.push(str);312}else{313if(str.search(/\S/)>=0){314str=_21(str);315str=str.replace(/^([ \t]*)/g,"<p>");316str+="</p>";317_8d.push(str);318}319}320}321end=_8d.length;322for(var i=0;i<end;i++){323while(_8d[i].search(/~K(\d+)K/)>=0){324var _91=_3[RegExp.$1];325_91=_91.replace(/\$/g,"$$$$");326_8d[i]=_8d[i].replace(/~K\d+K/,_91);327}328}329return _8d.join("\n\n");330};331var _11=function(_92){332_92=_92.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&amp;");333_92=_92.replace(/<(?![a-z\/?\$!])/gi,"&lt;");334return _92;335};336var _25=function(_93){337_93=_93.replace(/\\(\\)/g,_94);338_93=_93.replace(/\\([`*_{}\[\]()>#+-.!])/g,_94);339return _93;340};341var _28=function(_95){342_95=_95.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,"<a href=\"$1\">$1</a>");343_95=_95.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(_96,m1){344return _98(_a(m1));345});346return _95;347};348var _98=function(_99){349function char2hex(ch){350var _9b="0123456789ABCDEF";351var dec=ch.charCodeAt(0);352return (_9b.charAt(dec>>4)+_9b.charAt(dec&15));353}354var _9d=[function(ch){355return "&#"+ch.charCodeAt(0)+";";356},function(ch){357return "&#x"+char2hex(ch)+";";358},function(ch){359return ch;360}];361_99="mailto:"+_99;362_99=_99.replace(/./g,function(ch){363if(ch=="@"){364ch=_9d[Math.floor(Math.random()*2)](ch);365}else{366if(ch!=":"){367var r=Math.random();368ch=(r>0.9?_9d[2](ch):r>0.45?_9d[1](ch):_9d[0](ch));369}370}371return ch;372});373_99="<a href=\""+_99+"\">"+_99+"</a>";374_99=_99.replace(/">.+:/g,"\">");375return _99;376};377var _a=function(_a3){378_a3=_a3.replace(/~E(\d+)E/g,function(_a4,m1){379var _a6=parseInt(m1);380return String.fromCharCode(_a6);381});382return _a3;383};384var _72=function(_a7){385_a7=_a7.replace(/^(\t|[ ]{1,4})/gm,"~0");386_a7=_a7.replace(/~0/g,"");387return _a7;388};389var _6=function(_a8){390_a8=_a8.replace(/\t(?=\t)/g," ");391_a8=_a8.replace(/\t/g,"~A~B");392_a8=_a8.replace(/~B(.+?)~A/g,function(_a9,m1,m2){393var _ac=m1;394var _ad=4-_ac.length%4;395for(var i=0;i<_ad;i++){396_ac+=" ";397}398return _ac;399});400_a8=_a8.replace(/~A/g," ");401_a8=_a8.replace(/~B/g,"");402return _a8;403};404var _2e=function(_af,_b0,_b1){405var _b2="(["+_b0.replace(/([\[\]\\])/g,"\\$1")+"])";406if(_b1){407_b2="\\\\"+_b2;408}409var _b3=new RegExp(_b2,"g");410_af=_af.replace(_b3,_94);411return _af;412};413var _94=function(_b4,m1){414var _b6=m1.charCodeAt(0);415return "~E"+_b6+"E";416};417};...

Full Screen

Full Screen

wxDiscode.js

Source:wxDiscode.js Github

copy

Full Screen

1// HTML 支持的数学符号2function strNumDiscode(str){3 str = str.replace(/&forall;/g, '∀');4 str = str.replace(/&part;/g, '∂');5 str = str.replace(/&exists;/g, '∃');6 str = str.replace(/&empty;/g, '∅');7 str = str.replace(/&nabla;/g, '∇');8 str = str.replace(/&isin;/g, '∈');9 str = str.replace(/&notin;/g, '∉');10 str = str.replace(/&ni;/g, '∋');11 str = str.replace(/&prod;/g, '∏');12 str = str.replace(/&sum;/g, '∑');13 str = str.replace(/&minus;/g, '−');14 str = str.replace(/&lowast;/g, '∗');15 str = str.replace(/&radic;/g, '√');16 str = str.replace(/&prop;/g, '∝');17 str = str.replace(/&infin;/g, '∞');18 str = str.replace(/&ang;/g, '∠');19 str = str.replace(/&and;/g, '∧');20 str = str.replace(/&or;/g, '∨');21 str = str.replace(/&cap;/g, '∩');22 str = str.replace(/&cap;/g, '∪');23 str = str.replace(/&int;/g, '∫');24 str = str.replace(/&there4;/g, '∴');25 str = str.replace(/&sim;/g, '∼');26 str = str.replace(/&cong;/g, '≅');27 str = str.replace(/&asymp;/g, '≈');28 str = str.replace(/&ne;/g, '≠');29 str = str.replace(/&le;/g, '≤');30 str = str.replace(/&ge;/g, '≥');31 str = str.replace(/&sub;/g, '⊂');32 str = str.replace(/&sup;/g, '⊃');33 str = str.replace(/&nsub;/g, '⊄');34 str = str.replace(/&sube;/g, '⊆');35 str = str.replace(/&supe;/g, '⊇');36 str = str.replace(/&oplus;/g, '⊕');37 str = str.replace(/&otimes;/g, '⊗');38 str = str.replace(/&perp;/g, '⊥');39 str = str.replace(/&sdot;/g, '⋅');40 return str;41}42//HTML 支持的希腊字母43function strGreeceDiscode(str){44 str = str.replace(/&Alpha;/g, 'Α');45 str = str.replace(/&Beta;/g, 'Β');46 str = str.replace(/&Gamma;/g, 'Γ');47 str = str.replace(/&Delta;/g, 'Δ');48 str = str.replace(/&Epsilon;/g, 'Ε');49 str = str.replace(/&Zeta;/g, 'Ζ');50 str = str.replace(/&Eta;/g, 'Η');51 str = str.replace(/&Theta;/g, 'Θ');52 str = str.replace(/&Iota;/g, 'Ι');53 str = str.replace(/&Kappa;/g, 'Κ');54 str = str.replace(/&Lambda;/g, 'Λ');55 str = str.replace(/&Mu;/g, 'Μ');56 str = str.replace(/&Nu;/g, 'Ν');57 str = str.replace(/&Xi;/g, 'Ν');58 str = str.replace(/&Omicron;/g, 'Ο');59 str = str.replace(/&Pi;/g, 'Π');60 str = str.replace(/&Rho;/g, 'Ρ');61 str = str.replace(/&Sigma;/g, 'Σ');62 str = str.replace(/&Tau;/g, 'Τ');63 str = str.replace(/&Upsilon;/g, 'Υ');64 str = str.replace(/&Phi;/g, 'Φ');65 str = str.replace(/&Chi;/g, 'Χ');66 str = str.replace(/&Psi;/g, 'Ψ');67 str = str.replace(/&Omega;/g, 'Ω');68 str = str.replace(/&alpha;/g, 'α');69 str = str.replace(/&beta;/g, 'β');70 str = str.replace(/&gamma;/g, 'γ');71 str = str.replace(/&delta;/g, 'δ');72 str = str.replace(/&epsilon;/g, 'ε');73 str = str.replace(/&zeta;/g, 'ζ');74 str = str.replace(/&eta;/g, 'η');75 str = str.replace(/&theta;/g, 'θ');76 str = str.replace(/&iota;/g, 'ι');77 str = str.replace(/&kappa;/g, 'κ');78 str = str.replace(/&lambda;/g, 'λ');79 str = str.replace(/&mu;/g, 'μ');80 str = str.replace(/&nu;/g, 'ν');81 str = str.replace(/&xi;/g, 'ξ');82 str = str.replace(/&omicron;/g, 'ο');83 str = str.replace(/&pi;/g, 'π');84 str = str.replace(/&rho;/g, 'ρ');85 str = str.replace(/&sigmaf;/g, 'ς');86 str = str.replace(/&sigma;/g, 'σ');87 str = str.replace(/&tau;/g, 'τ');88 str = str.replace(/&upsilon;/g, 'υ');89 str = str.replace(/&phi;/g, 'φ');90 str = str.replace(/&chi;/g, 'χ');91 str = str.replace(/&psi;/g, 'ψ');92 str = str.replace(/&omega;/g, 'ω');93 str = str.replace(/&thetasym;/g, 'ϑ');94 str = str.replace(/&upsih;/g, 'ϒ');95 str = str.replace(/&piv;/g, 'ϖ');96 str = str.replace(/&middot;/g, '·');97 return str;98}99// 100function strcharacterDiscode(str){101 // 加入常用解析102 str = str.replace(/&nbsp;/g, ' ');103 str = str.replace(/&quot;/g, "'");104 str = str.replace(/&amp;/g, '&');105 // str = str.replace(/&lt;/g, '‹');106 // str = str.replace(/&gt;/g, '›');107 str = str.replace(/&lt;/g, '<');108 str = str.replace(/&gt;/g, '>');109 return str;110}111// HTML 支持的其他实体112function strOtherDiscode(str){113 str = str.replace(/&OElig;/g, 'Œ');114 str = str.replace(/&oelig;/g, 'œ');115 str = str.replace(/&Scaron;/g, 'Š');116 str = str.replace(/&scaron;/g, 'š');117 str = str.replace(/&Yuml;/g, 'Ÿ');118 str = str.replace(/&fnof;/g, 'ƒ');119 str = str.replace(/&circ;/g, 'ˆ');120 str = str.replace(/&tilde;/g, '˜');121 str = str.replace(/&ensp;/g, '');122 str = str.replace(/&emsp;/g, '');123 str = str.replace(/&thinsp;/g, '');124 str = str.replace(/&zwnj;/g, '');125 str = str.replace(/&zwj;/g, '');126 str = str.replace(/&lrm;/g, '');127 str = str.replace(/&rlm;/g, '');128 str = str.replace(/&ndash;/g, '–');129 str = str.replace(/&mdash;/g, '—');130 str = str.replace(/&lsquo;/g, '‘');131 str = str.replace(/&rsquo;/g, '’');132 str = str.replace(/&sbquo;/g, '‚');133 str = str.replace(/&ldquo;/g, '“');134 str = str.replace(/&rdquo;/g, '”');135 str = str.replace(/&bdquo;/g, '„');136 str = str.replace(/&dagger;/g, '†');137 str = str.replace(/&Dagger;/g, '‡');138 str = str.replace(/&bull;/g, '•');139 str = str.replace(/&hellip;/g, '…');140 str = str.replace(/&permil;/g, '‰');141 str = str.replace(/&prime;/g, '′');142 str = str.replace(/&Prime;/g, '″');143 str = str.replace(/&lsaquo;/g, '‹');144 str = str.replace(/&rsaquo;/g, '›');145 str = str.replace(/&oline;/g, '‾');146 str = str.replace(/&euro;/g, '€');147 str = str.replace(/&trade;/g, '™');148 str = str.replace(/&larr;/g, '←');149 str = str.replace(/&uarr;/g, '↑');150 str = str.replace(/&rarr;/g, '→');151 str = str.replace(/&darr;/g, '↓');152 str = str.replace(/&harr;/g, '↔');153 str = str.replace(/&crarr;/g, '↵');154 str = str.replace(/&lceil;/g, '⌈');155 str = str.replace(/&rceil;/g, '⌉');156 str = str.replace(/&lfloor;/g, '⌊');157 str = str.replace(/&rfloor;/g, '⌋');158 str = str.replace(/&loz;/g, '◊');159 str = str.replace(/&spades;/g, '♠');160 str = str.replace(/&clubs;/g, '♣');161 str = str.replace(/&hearts;/g, '♥');162 str = str.replace(/&diams;/g, '♦');163 return str;164}165function strMoreDiscode(str){166 str = str.replace(/\r\n/g,""); 167 str = str.replace(/\n/g,"");168 str = str.replace(/code/g,"wxxxcode-style");169 return str;170}171function strDiscode(str){172 str = strNumDiscode(str);173 str = strGreeceDiscode(str);174 str = strcharacterDiscode(str);175 str = strOtherDiscode(str);176 str = strMoreDiscode(str);177 return str;178}179function urlToHttpUrl(url,rep){180 181 var patt1 = new RegExp("^//");182 var result = patt1.test(url);...

Full Screen

Full Screen

juno_okyo.js

Source:juno_okyo.js Github

copy

Full Screen

...86 this.loading = true;87 let headlines = (this.key2 !== '') ? this.headlines2 : this.headlines;88 let template = headlines[this.getRandomInt(0, headlines.length)];89 // Render template90 template = template.replace('__REPLACE__', this.key1);91 if (this.key2 !== '')92 template = template.replace('__REPLACE__', this.key2);93 this.result = template;94 setTimeout(() => {95 this.loading = false;96 }, 300);97 },98 getRandomInt(min, max) {99 min = Math.ceil(min);100 max = Math.floor(max);101 return Math.floor(Math.random() * (max - min + 1)) + min;102 }103 }104 });...

Full Screen

Full Screen

say.js

Source:say.js Github

copy

Full Screen

...17'https://i.gifer.com/fxac.gif',18'https://media.giphy.com/media/l0HlAw20GtU0mbUeQ/giphy.gif',19'https://i.gifer.com/ASV.gif'20];21let toplamüye = message.guild.members.cache.size.toString().replace('0', '0️⃣').replace('1', '1️⃣').replace('2', '2️⃣').replace('3', '3️⃣').replace('4', '4️⃣').replace('5', '5️⃣').replace('6', '6️⃣').replace('7', '7️⃣').replace('8', '8️⃣').replace('9', '9️⃣');22let aktifüye = message.guild.members.cache.filter(a => a.presence.status !== 'offline').size.toString().replace('0', '0️⃣').replace('1', '1️⃣').replace('2', '2️⃣').replace('3', '3️⃣').replace('4', '4️⃣').replace('5', '5️⃣').replace('6', '6️⃣').replace('7', '7️⃣').replace('8', '8️⃣').replace('9', '9️⃣');23let sesaktif = message.guild.members.cache.filter(a => a.voice.channel).size.toString().replace('0', '0️⃣').replace('1', '1️⃣').replace('2', '2️⃣').replace('3', '3️⃣').replace('4', '4️⃣').replace('5', '5️⃣').replace('6', '6️⃣').replace('7', '7️⃣').replace('8', '8️⃣').replace('9', '9️⃣');24let boost = message.guild.premiumSubscriptionCount.toString().replace('0', '0️⃣').replace('1', '1️⃣').replace('2', '2️⃣').replace('3', '3️⃣').replace('4', '4️⃣').replace('5', '5️⃣').replace('6', '6️⃣').replace('7', '7️⃣').replace('8', '8️⃣').replace('9', '9️⃣');25let kadınüyesayısı = message.guild.members.cache.filter(a => a.roles.cache.has(datass)).size.toString().replace('0', '0️⃣').replace('1', '1️⃣').replace('2', '2️⃣').replace('3', '3️⃣').replace('4', '4️⃣').replace('5', '5️⃣').replace('6', '6️⃣').replace('7', '7️⃣').replace('8', '8️⃣').replace('9', '9️⃣');26let erkeknüyesayısı = message.guild.members.cache.filter(a => a.roles.cache.has(datas)).size.toString().replace('0', '0️⃣').replace('1', '1️⃣').replace('2', '2️⃣').replace('3', '3️⃣').replace('4', '4️⃣').replace('5', '5️⃣').replace('6', '6️⃣').replace('7', '7️⃣').replace('8', '8️⃣').replace('9', '9️⃣');27let tag;28if(!data.fetch(`tag.${message.guild.id}`)) {29tag = '0️⃣';30} else {31tag = message.guild.members.cache.filter(a => a.user.username.includes(data.fetch(`tag.${message.guild.id}`))).size.toString().replace('0', '0️⃣').replace('1', '1️⃣').replace('2', '2️⃣').replace('3', '3️⃣').replace('4', '4️⃣').replace('5', '5️⃣').replace('6', '6️⃣').replace('7', '7️⃣').replace('8', '8️⃣').replace('9', '9️⃣');32}33message.channel.send(new Discord.MessageEmbed()34.setAuthor(`Sunucu durumunu istedi: ${message.author.tag}`, message.author.avatarURL() ? message.author.avatarURL({dynamic: true}) : 'https://cdn.glitch.com/8e70d198-9ddc-40aa-b0c6-ccb4573f14a4%2F6499d2f1c46b106eed1e25892568aa55.png')35.setThumbnail(images.random())36.setDescription(`\`\`\`[${client.ayarlar.prefix}tag] ile taglı sayını ayarlayabilirsin.\`\`\`37**Toplam Üye** ${toplamüye}38**Aktif Üye** ${aktifüye}39**Seslide ki Üye Sayısı** ${sesaktif}40**Taglı Üye Sayısı** ${tag}41**Boost Sayısı** ${boost}42**Kadın Üye Sayısı** ${kadınüyesayısı}43**Erkek Üye Sayısı** ${erkeknüyesayısı}`));44};45exports.conf = {...

Full Screen

Full Screen

wp-seo-replacevar-plugin.js

Source:wp-seo-replacevar-plugin.js Github

copy

Full Screen

...47 * @returns {string}48 */49 YoastReplaceVarPlugin.prototype.titleReplace = function( data ) {50 var title = this._app.rawData.title;51 data = data.replace( /%%title%%/g, title );52 return data;53 };54 /**55 * Replaces %%term_title%% with the title of the term56 * @param {String} data the data to replace the term_title var57 * @returns {String} the data with the replaced variables58 */59 YoastReplaceVarPlugin.prototype.termtitleReplace = function( data ) {60 var term_title = this._app.rawData.name;61 data = data.replace( /%%term_title%%/g, term_title);62 return data;63 };64 /**65 * Replaces %%parent_title%% with the selected value from selectbox (if available on page).66 *67 * @param {String} data68 * @returns {String}69 */70 YoastReplaceVarPlugin.prototype.parentReplace = function( data ) {71 var parentId = document.getElementById( 'parent_id' );72 if ( parentId !== null && typeof parentId.options !== 'undefined' && parentId.options[ parentId.selectedIndex ].text !== wpseoReplaceVarsL10n.no_parent_text ) {73 data = data.replace( /%%parent_title%%/, parentId.options[ parentId.selectedIndex ].text );74 }75 return data;76 };77 /**78 * Replaces separators in the string.79 *80 * @param {String} data81 * @returns {String}82 */83 YoastReplaceVarPlugin.prototype.replaceSeparators = function( data ) {84 return data.replace( /%%sep%%(\s+%%sep%%)*/g, this.replaceVars.sep );85 };86 /**87 * replaces the excerpts strings with strings for the excerpts, if not empty.88 *89 * @param {String} data90 * @returns {String}91 */92 YoastReplaceVarPlugin.prototype.excerptReplace = function( data ) {93 if ( typeof this._app.rawData.excerpt !== 'undefined' ) {94 data = data.replace( /%%excerpt_only%%/g, this._app.rawData.excerpt );95 data = data.replace( /%%excerpt%%/g, this._app.rawData.excerpt );96 }97 return data;98 };99 YoastReplaceVarPlugin.prototype.primaryCategoryReplace = function( data ) {100 var primary_category = ( typeof this._app.rawData.primaryCategory !== 'undefined' ) ? this._app.rawData.primaryCategory : '';101 return data.replace( /%%primary_category%%/g, primary_category );102 };103 /**104 * replaces default variables with the values stored in the wpseoMetaboxL10n object.105 *106 * @param {String} textString107 * @return {String}108 */109 YoastReplaceVarPlugin.prototype.defaultReplace = function( textString ) {110 var focusKeyword = this._app.rawData.keyword;111 return textString.replace( /%%sitedesc%%/g, this.replaceVars.sitedesc )112 .replace( /%%sitename%%/g, this.replaceVars.sitename )113 .replace( /%%term_title%%/g, this.replaceVars.term_title )114 .replace( /%%term_description%%/g, this.replaceVars.term_description )115 .replace( /%%category_description%%/g, this.replaceVars.category_description )116 .replace( /%%tag_description%%/g, this.replaceVars.tag_description )117 .replace( /%%searchphrase%%/g, this.replaceVars.searchphrase )118 .replace( /%%date%%/g, this.replaceVars.date )119 .replace( /%%id%%/g, this.replaceVars.id )120 .replace( /%%page%%/g, this.replaceVars.page )121 .replace( /%%currenttime%%/g, this.replaceVars.currenttime )122 .replace( /%%currentdate%%/g, this.replaceVars.currentdate )123 .replace( /%%currentday%%/g, this.replaceVars.currentday )124 .replace( /%%currentmonth%%/g, this.replaceVars.currentmonth )125 .replace( /%%currentyear%%/g, this.replaceVars.currentyear )126 .replace( /%%focuskw%%/g, focusKeyword );127 };128 window.YoastReplaceVarPlugin = YoastReplaceVarPlugin;...

Full Screen

Full Screen

wp-seo-replacevar-plugin-310.js

Source:wp-seo-replacevar-plugin-310.js Github

copy

Full Screen

...44 * @returns {string}45 */46 YoastReplaceVarPlugin.prototype.titleReplace = function( data ) {47 var title = YoastSEO.app.rawData.title;48 data = data.replace( /%%title%%/g, title );49 return data;50 };51 /**52 * Replaces %%term_title%% with the title of the term53 * @param {String} data the data to replace the term_title var54 * @returns {String} the data with the replaced variables55 */56 YoastReplaceVarPlugin.prototype.termtitleReplace = function( data ) {57 var term_title = YoastSEO.app.rawData.name;58 data = data.replace( /%%term_title%%/g, term_title);59 return data;60 };61 /**62 * Replaces %%parent_title%% with the selected value from selectbox (if available on page).63 *64 * @param {String} data65 * @returns {String}66 */67 YoastReplaceVarPlugin.prototype.parentReplace = function( data ) {68 var parentId = document.getElementById( 'parent_id' );69 if ( parentId !== null && typeof parentId.options !== 'undefined' && parentId.options[ parentId.selectedIndex ].text !== wpseoReplaceVarsL10n.no_parent_text ) {70 data = data.replace( /%%parent_title%%/, parentId.options[ parentId.selectedIndex ].text );71 }72 return data;73 };74 /**75 * Replaces separators in the string.76 *77 * @param {String} data78 * @returns {String}79 */80 YoastReplaceVarPlugin.prototype.replaceSeparators = function( data ) {81 return data.replace( /%%sep%%(\s+%%sep%%)*/g, this.replaceVars.sep );82 };83 /**84 * replaces the excerpts strings with strings for the excerpts, if not empty.85 *86 * @param {String} data87 * @returns {String}88 */89 YoastReplaceVarPlugin.prototype.excerptReplace = function( data ) {90 if ( typeof YoastSEO.app.rawData.excerpt !== 'undefined' ) {91 data = data.replace( /%%excerpt_only%%/g, YoastSEO.app.rawData.excerpt );92 data = data.replace( /%%excerpt%%/g, YoastSEO.app.rawData.excerpt );93 }94 return data;95 };96 /**97 * replaces default variables with the values stored in the wpseoMetaboxL10n object.98 *99 * @param {String} textString100 * @return {String}101 */102 YoastReplaceVarPlugin.prototype.defaultReplace = function( textString ) {103 var focusKeyword = YoastSEO.app.rawData.keyword;104 return textString.replace( /%%sitedesc%%/g, this.replaceVars.sitedesc )105 .replace( /%%sitename%%/g, this.replaceVars.sitename )106 .replace( /%%term_title%%/g, this.replaceVars.term_title )107 .replace( /%%term_description%%/g, this.replaceVars.term_description )108 .replace( /%%category_description%%/g, this.replaceVars.category_description )109 .replace( /%%tag_description%%/g, this.replaceVars.tag_description )110 .replace( /%%searchphrase%%/g, this.replaceVars.searchphrase )111 .replace( /%%date%%/g, this.replaceVars.date )112 .replace( /%%id%%/g, this.replaceVars.id )113 .replace( /%%page%%/g, this.replaceVars.page )114 .replace( /%%currenttime%%/g, this.replaceVars.currenttime )115 .replace( /%%currentdate%%/g, this.replaceVars.currentdate )116 .replace( /%%currentday%%/g, this.replaceVars.currentday )117 .replace( /%%currentmonth%%/g, this.replaceVars.currentmonth )118 .replace( /%%currentyear%%/g, this.replaceVars.currentyear )119 .replace( /%%focuskw%%/g, focusKeyword );120 };121 window.YoastReplaceVarPlugin = YoastReplaceVarPlugin;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { replace } = require('@redwoodjs/internal')2const output = replace(input, 'dog', 'monkey')3console.log(output)4const { replace } = require('@redwoodjs/internal')5const output = replace(input, 'dog', 'monkey')6console.log(output)7const { replace } = require('@redwoodjs/internal')8const output = replace(input, 'dog', 'monkey')9console.log(output)10const { replace } = require('@redwoodjs/internal')11const output = replace(input, 'dog', 'monkey')12console.log(output)13const { replace } = require('@redwoodjs/internal')14const output = replace(input, 'dog', 'monkey')15console.log(output)16const { replace } = require('@redwoodjs/internal')17const output = replace(input, 'dog', 'monkey

Full Screen

Using AI Code Generation

copy

Full Screen

1const { replace } = require('@redwoodjs/internal')2replace({3 <Route path="/test" page={TestPage} name="test" />4})5import { Router, Route } from '@redwoodjs/router'6import TestPage from 'src/pages/TestPage/TestPage'7const Routes = () => {8 return (9 <Route path="/test" page={TestPage} name="test" />10 <Route notfound page={NotFoundPage} />11}

Full Screen

Using AI Code Generation

copy

Full Screen

1const replace = require("replace-in-file");2const options = {3};4try {5 let changedFiles = replace.sync(options);6 console.log("Modified files:", changedFiles.join(", "));7} catch (error) {8 console.error("Error occurred:", error);9}

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2redwood.replace('test.txt', 'redwood', 'redwoodjs');3var redwood = require('redwood');4redwood.append('test.txt', 'redwood');5var redwood = require('redwood');6redwood.prepend('test.txt', 'redwood');7var redwood = require('redwood');8redwood.remove('test.txt', 'redwood');9var redwood = require('redwood');10redwood.delete('test.txt');11var redwood = require('redwood');12redwood.rename('test.txt', 'test.js');13var redwood = require('redwood');14redwood.copy('test.js', 'test.txt');15var redwood = require('redwood');16redwood.move('test.txt', 'test.js');

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run redwood automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful