Skip to content

Commit

Permalink
trying to move html replacer into a new stage
Browse files Browse the repository at this point in the history
  • Loading branch information
atherdon committed Nov 21, 2021
1 parent 1aa426e commit e0ba1b5
Show file tree
Hide file tree
Showing 9 changed files with 285 additions and 113 deletions.
35 changes: 35 additions & 0 deletions package/__ToUseLater/converter/plainCallbacks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
PlainCallbacks, newLine
} from 'atherdon-callbacks';

const {
strong,
link,
blockquote,
mem,
header,
italic,
del,
q,
code,
hr,
empty
} = PlainCallbacks;

const {
ulList,
olList
} = PlainCallbacks;

const {
image,
paragraphWrapper,
sponsorship,
br
} = PlainCallbacks;

const { previewText, separator } = PlainCallbacks;
// ---------------------------------



1 change: 1 addition & 0 deletions package/__ToUseLater/converter/typography.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// REGEXP_EMPTY_UL,
// REGEXP_EMPTY_OL
// } = require('atherdon-newsletter-constants');

import {
PlainCallbacks
} from 'atherdon-callbacks';
Expand Down
1 change: 0 additions & 1 deletion package/__ToUseLater/renderer2.js

This file was deleted.

37 changes: 0 additions & 37 deletions package/__ToUseLater/template-renderer.js

This file was deleted.

8 changes: 8 additions & 0 deletions package/callbacks/src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import reactLayouts from 'atherdon-newsletter-react';





console.log(layouts);





const platform = os.platform();
const newLine = platform === 'win32' ? '\r\n' : '\n';

Expand Down
8 changes: 7 additions & 1 deletion package/callbacks/src/replace-md.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function extractOptions(converter, key){
function replaceMarkdownNew( key ){


const {regexp, callback} = extractOptions(converter, key);
const { regexp, callback } = extractOptions(converter, key);

// const {regexp, callback} = options;

Expand All @@ -36,6 +36,12 @@ function replaceMarkdownNew( key ){

}



// THIS WILL BE BROKEN SOOOOON
// this.replaceMDBinded(this._constants.REGEXP_PREVIEW_TEXT, previewText);
// this.replaceMDBinded("previewText");

function replaceMarkdown(regexp, callback) {

// console.log('helpers- replace markdown method')
Expand Down
4 changes: 4 additions & 0 deletions package/html/replacer/src/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ const generateContentOnly = (sourceFile) => {
// printMessage(message, 'green2');
// }





//--------------
function compileEmptyTemplate(){

Expand Down
223 changes: 223 additions & 0 deletions package/html/replacer/src/replace copy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@



// import * as constants from 'atherdon-newsletter-constants';

// ---------------------------------

import {
PlainCallbacks, newLine
} from 'atherdon-callbacks';

const {
strong,
link,
blockquote,
mem,
header,
italic,
del,
q,
code,
hr,
empty
} = PlainCallbacks;

const {
ulList,
olList
} = PlainCallbacks;

const {
image,
paragraphWrapper,
sponsorship,
br
} = PlainCallbacks;

const { previewText, separator } = PlainCallbacks;
// ---------------------------------







// @TODO include things from a new module that we have.


// we need to pass all constants somewhere, but not to the replaceWrapper

class Replace {
// constructor(constants) {
constructor() {


// this._constants = constants;



this.replaceMDBinded = () => { };
this.replaceMDBindedPreviewText = () => { };


this.previewText = function () {
// this.replaceMDBinded(this._constants.REGEXP_PREVIEW_TEXT, previewText);
this.replaceMDBinded("previewText");
};

this.comments = () => {
// this.replaceMDBinded(this._constants.REGEXP_HTML_COMMENTS, empty);
this.replaceMDBinded( "" );
};

this.strong = () => {
// this.replaceMDBinded(this._constants.REGEXP_STRONG, strong);
this.replaceMDBinded("strong");
};

this.em = () => {
// this.replaceMDBinded(this._constants.REGEXP_EM, italic);
this.replaceMDBinded("italic");
};

this.header = () => {
// this.replaceMDBinded(this._constants.REGEXP_HEADER, header);
this.replaceMDBinded("header");
};

this.image = () => {
// this.replaceMDBinded(this._constants.REGEXP_IMAGE, image);
this.replaceMDBinded("image");
};

this.link = () => {
// this.replaceMDBinded(this._constants.REGEXP_LINK, link);
this.replaceMDBinded("link");
};

this.del = () => {
// this.replaceMDBinded(this._constants.REGEXP_DEL, del);
this.replaceMDBinded("del");
};

this.q = () => {
// this.replaceMDBinded(this._constants.REGEXP_Q, q);
this.replaceMDBinded("q");
};

this.code = () => {
// this.replaceMDBinded(this._constants.REGEXP_CODE, code);
this.replaceMDBinded("code");
};

this.ul = () => {
// this.replaceMDBinded(this._constants.REGEXP_UL_LIST, ulList);
this.replaceMDBinded("ulList");
};

this.ol = () => {
// this.replaceMDBinded(this._constants.REGEXP_OL_LIST, olList);
this.replaceMDBinded("olList");
};

this.blockquote = () => {
// this.replaceMDBinded(this._constants.REGEXP_BLOCKQUOTE, blockquote);
this.replaceMDBinded("blockquote");
};

this.hr = () => {
// this.replaceMDBinded(this._constants.REGEXP_HR, hr);
this.replaceMDBinded("hr");
};

this.paragraph = () => {
// this.replaceMDBinded(this._constants.REGEXP_PARAGRAPH, paragraphWrapper);
this.replaceMDBinded("paragraphWrapper");
};

this.emptyUl = () => {
// this.replaceMDBinded(this._constants.REGEXP_EMPTY_UL, empty);
this.replaceMDBinded("REGEXP_EMPTY_UL");
};

this.emptyOl = () => {
// this.replaceMDBinded(this._constants.REGEXP_EMPTY_OL, empty);
this.replaceMDBinded("REGEXP_EMPTY_OL");
};


this.emptyBlockquote = () => {
// this line is generating an error
// this.replaceMDBinded(this._constants.REGEXP_EMPTY_BLOCKQUOTE, newLine);
this.replaceMDBinded("REGEXP_EMPTY_BLOCKQUOTE");
};

this.br = function () {
// this.replaceMDBinded(this._constants.REGEXP_BR, br);
this.replaceMDBinded("br");
};
this.sponsorship = function () {
// this.replaceMDBinded(this._constants.REGEXP_SPONSORSHIP, sponsorship);
this.replaceMDBinded("sponsorship");
};

this.memes = function () {
// this.replaceMDBinded(this._constants.REGEXP_MEM, mem);
this.replaceMDBinded("memes");
};

this.separator = function () {
// this.replaceMDBinded(this._constants.REGEXP_SEPARATOR, separator);
this.replaceMDBinded("separator");
};
}


template(){
this.header();
}

// test this part
miscellaneous(){

// this line is generating an error
this.emptyBlockquote();
this.br();

if (!process.env.PARSE === 'noAdv' || process.env.PARSE === 'full') {
this.sponsorship();
}

this.memes();
this.separator();
}

typography(){
this.strong();
this.em();
// this.header();
this.image();
this.link();
this.del();
this.q();
this.code();
//-----
this.ul();
this.ol();
//-----
this.blockquote();
this.hr();
//-----
this.paragraph();
this.emptyUl();
this.emptyOl();
}



}

export default new Replace();
// export default new Replace(constants);
Loading

0 comments on commit e0ba1b5

Please sign in to comment.