-
Notifications
You must be signed in to change notification settings - Fork 12
Remake functions #917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remake functions #917
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const { isFolderExists } = require('./src/utils'); | ||
|
||
isFolderExists('generated'); | ||
isFolderExists('./src/tests/_generated'); | ||
isFolderExists('./src/parserMDReact/tests/_generated'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,30 @@ | |
// https://www.npmjs.com/package/batch-replace | ||
// https://www.npmjs.com/package/pupa | ||
|
||
import { sponsorship } from "./callbacksHtml/methods/callbacks"; | ||
import { separator } from "./callbacksHtml/methods/custom"; | ||
import { mem, previewText } from "./callbacksHtml/methods/simple"; | ||
import {strong, | ||
link, | ||
blockquote, | ||
mem, | ||
header, | ||
italic, | ||
del, | ||
q, | ||
code, | ||
hr, | ||
empty, | ||
|
||
ulList, | ||
olList, | ||
|
||
image, | ||
paragraphWrapper, | ||
sponsorship, | ||
br, | ||
|
||
separator,} from "./callbacksHtml/index.js" | ||
// function extractOptions(converter, key) { | ||
// if (!converter.key) throw new Error('no options for this converter'); | ||
|
||
|
@@ -38,10 +62,101 @@ | |
// Should be working like this | ||
// this.replaceMDBinded("previewText"); | ||
|
||
function replaceMarkdown(regexp, callback) { | ||
const map = { | ||
'strong': { | ||
constant: REGEXP_STRONG, | ||
callback: strong | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it will not work because you didn't import it |
||
}, | ||
'previewText':{ | ||
constant: REGEXP_PREVIEW_TEXT, | ||
callback: previewText | ||
}, | ||
'empty': { | ||
constant: REGEXP_HTML_COMMENTS, | ||
callback: comments | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the same problem |
||
}, | ||
'italic': { | ||
constant: REGEXP_EM, | ||
callback: italic | ||
}, | ||
'header': { | ||
constant: REGEXP_HEADER, | ||
callback: header | ||
}, | ||
'image': { | ||
constant: REGEXP_IMAGE, | ||
callback: image | ||
}, | ||
'link': { | ||
constant: REGEXP_LINK, | ||
callback: link | ||
}, | ||
'del': { | ||
constant: REGEXP_DEL, | ||
callback: del | ||
}, | ||
'q': { | ||
constant: REGEXP_Q, | ||
callback: q | ||
}, | ||
'code': { | ||
constant: REGEXP_CODE, | ||
callback: code | ||
}, | ||
'ulList': { | ||
constant: REGEXP_UL_LIST, | ||
callback: ulList | ||
}, | ||
'olList': { | ||
constant: REGEXP_OL_LIST, | ||
callback: olList | ||
}, | ||
'blockquote': { | ||
constant: REGEXP_BLOCKQUOTE, | ||
callback: blockQuote | ||
}, | ||
'hr': { | ||
constant: REGEXP_HR, | ||
callback: hr | ||
}, | ||
'paragraphWrapper': { | ||
constant: REGEXP_PARAGRAPH, | ||
callback: paragraph | ||
}, | ||
'REGEXP_EMPTY_UL': { | ||
constant: REGEXP_EMPTY_UL, | ||
callback: emptyUl | ||
}, | ||
'REGEXP_EMPTY_OL': { | ||
constant: REGEXP_EMPTY_OL, | ||
callback: emptyOl | ||
}, | ||
'REGEXP_EMPTY_BLOCKQUOTE': { | ||
constant: REGEXP_EMPTY_BLOCKQUOTE, | ||
callback: emptyBlockQuote | ||
}, | ||
'REGEXP_BR': { | ||
constant: REGEXP_BR, | ||
callback: br | ||
}, | ||
'sponsorship': { | ||
constant: REGEXP_SPONSORSHIP, | ||
callback: sponsorship | ||
}, | ||
'mem': { | ||
constant: REGEXP_MEM, | ||
callback: mem | ||
}, | ||
'separator': { | ||
constant: REGEXP_SEPARATOR, | ||
callback: separator | ||
} | ||
} | ||
|
||
function replaceMarkdown(callback) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename the name of argument, please because it's not callback - it's a name for example just name |
||
// console.log('helpers- replace markdown method') | ||
// console.log(typeof callback) | ||
|
||
const LocalObject = map[callback] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. уже лучше но название константы сделайте другой начиная с маленькой буквы |
||
// eslint-disable-next-line no-useless-catch | ||
try { | ||
let fixedCallbackMethod = false; | ||
|
@@ -63,7 +178,7 @@ function replaceMarkdown(regexp, callback) { | |
break; | ||
} | ||
|
||
const result = this.content.replace(regexp, fixedCallbackMethod); | ||
const result = this.content.replace(LocalObject.constant, fixedCallbackMethod); | ||
this.content = result; | ||
} catch (e) { | ||
/* work in case there is an error */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
да правильно но проблема в том что это не будет работать потому что код написан в es6 и даст ошибку при запуске
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нужно придумать решение чтобы при запуске тестов это работало