Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions checkFolders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { isFolderExists } = require('./src/utils');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да правильно но проблема в том что это не будет работать потому что код написан в es6 и даст ошибку при запуске

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нужно придумать решение чтобы при запуске тестов это работало


isFolderExists('generated');
isFolderExists('./src/tests/_generated');
isFolderExists('./src/parserMDReact/tests/_generated');
121 changes: 118 additions & 3 deletions src/callbacks/replace-md.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -38,10 +62,101 @@
// Should be working like this
// this.replaceMDBinded("previewText");

function replaceMarkdown(regexp, callback) {
const map = {
'strong': {
constant: REGEXP_STRONG,
callback: strong
Copy link
Collaborator

Choose a reason for hiding this comment

The 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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The 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]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

уже лучше но название константы сделайте другой начиная с маленькой буквы

// eslint-disable-next-line no-useless-catch
try {
let fixedCallbackMethod = false;
Expand All @@ -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 */
Expand Down