diff --git a/README.md b/README.md index bec041311..253754b0b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/atherdon/markdown-to-email) +[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/LLazyEmail/markdown-to-email) This simple and light tool generates email template from markdown. The command is `npm run dev:parseFull`. The path to markdown file must be `./source/source.md`, and output directory is `generated/newEmail.html`. diff --git a/bash/lint-fix.sh b/bash/lint-fix.sh new file mode 100644 index 000000000..0715f66d3 --- /dev/null +++ b/bash/lint-fix.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +yarn eslint -c ./.eslintrc.js ./src --fix --ignore-pattern \"./package.json\" \ No newline at end of file diff --git a/bash/pre-push-check.sh b/bash/pre-push-check.sh index b17634e1c..a85bbde9b 100644 --- a/bash/pre-push-check.sh +++ b/bash/pre-push-check.sh @@ -1 +1 @@ -### nothing here yer +### nothing here yet diff --git a/bash/prettier-fix.sh b/bash/prettier-fix.sh new file mode 100644 index 000000000..690f17317 --- /dev/null +++ b/bash/prettier-fix.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +yarn install && yarn prettier --write '**/*.js' \ No newline at end of file diff --git a/package.json b/package.json index 62bd9c01a..dd3f5ba39 100644 --- a/package.json +++ b/package.json @@ -8,11 +8,10 @@ "dev:parseFull": "cross-env PARSE=full rollup -c -w", "dev:parseFullRecipes": "cross-env PARSE=recipesFull rollup -c -w", "dev:parseReactFull": "cross-env PARSE=reactFull rollup -c -w", + "dev:parseFrontHN": "cross-env PARSE=hackernnonFront rollup -c -w", "prod:parseFull": "npm run build && cross-env PARSE=full node ./dist/bundle", "prod:parseReactFull": "npm run build && cross-env PARSE=reactFull node ./dist/bundle", "test:react": "npm run checkFolders && jest ./src/parserMDReact/tests", - "lint:fix": "eslint -c ./.eslintrc.js ./src --fix --ignore-pattern \"./package.json\" ", - "lint": "eslint -c ./.eslintrc.js ./src --quiet --ignore-pattern \"./package.json\" ", "checkFolders": "node ./checkFolders", "test": "npm run checkFolders && jest ./src/tests", "test:typography": "jest --all --testPathPattern=./src/tests/typography", @@ -20,7 +19,9 @@ "test:custom": "jest --watchAll --all --testPathPattern=./src/tests/custom", "test:watch": "npm run checkFolders && jest --watch ./src/tests", "prepare": "husky install", - "fix:prettier": "prettier --write '**/*.js'" + "prettier:fix": "bash ./bash/prettier-fix.sh", + "lint": "eslint -c ./.eslintrc.js ./src --quiet --ignore-pattern \"./package.json\" ", + "lint:fix": "bash ./bash/lint-fix.sh" }, "author": "atherdon, vadim9999, hirdbluebird", "license": "ISC", @@ -44,7 +45,7 @@ "husky": "7.0.0", "jest": "27.5.1", "lint-staged": "12.4.1", - "markup-generator": "^2.5.0", + "markup-generator": "^2.7.0", "prettier": "2.7.0", "rollup": "2.75.6", "rollup-plugin-node-polyfills": "0.2.1", @@ -54,7 +55,7 @@ "atherdon-newsletter-js-layouts-body": "^3.2.0", "atherdon-newsletter-js-layouts-typography": "^3.0.0", "atherdon-newsletter-react-layouts-typography": "^0.4.0", - "atherdon-old-newsletter-js-outertemplate": "^3.7.0", + "atherdon-old-newsletter-js-outertemplate": "^3.9.0", "chalk": "5.0.1", "cross-env": "7.0.3", "lodash": "4.17.21", diff --git a/package/__ToUseLater/converter/___template.js b/package/__ToUseLater/converter/___template.js deleted file mode 100644 index 16449f442..000000000 --- a/package/__ToUseLater/converter/___template.js +++ /dev/null @@ -1,35 +0,0 @@ -const { - REGEXP_HEADER, - REGEXP_SPONSORSHIP, - REGEXP_HTML_COMMENTS, - REGEXP_PREVIEW_TEXT, -} = require('atherdon-newsletter-constants'); - -const { header, sponsorship } = require('../callbacks'); - -// const layouts = require("atherdon-newsletter-constants"); - -const ConverterBody = { - header: { - key: 'REGEXP_HEADER', - value: header, - // title: "xxx", - }, - comments: { - key: 'REGEXP_HTML_COMMENTS', - // value: 1, - // title: "xxx", - }, - previewText: { - key: 'REGEXP_PREVIEW_TEXT', - // value: 1, - // title: "xxx", - }, - sponsor: { - key: 'REGEXP_SPONSORSHIP', - value: sponsorship, - // title: "xxx", - }, -}; - -module.exports = ConverterBody; diff --git a/package/__ToUseLater/converter/full-we-need-to-move-missing-parts.js b/package/__ToUseLater/converter/full-we-need-to-move-missing-parts.js deleted file mode 100644 index 0f24ffe7b..000000000 --- a/package/__ToUseLater/converter/full-we-need-to-move-missing-parts.js +++ /dev/null @@ -1,101 +0,0 @@ -const { - REGEXP_HEADER, - REGEXP_IMAGE, - REGEXP_LINK, - REGEXP_STRONG, - REGEXP_DEL, - REGEXP_Q, - REGEXP_CODE, - REGEXP_UL_LIST, - REGEXP_OL_LIST, - REGEXP_BLOCKQUOTE, - REGEXP_HR, - REGEXP_PARAGRAPH, - REGEXP_EMPTY_UL, - REGEXP_EMPTY_OL, - REGEXP_BR, - REGEXP_EMPTY_BLOCKQUOTE, - REGEXP_EM, - REGEXP_SPONSORSHIP, - REGEXP_HTML_COMMENTS, - REGEXP_MEM, - REGEXP_PREVIEW_TEXT, -} = require('atherdon-newsletter-constants'); - -const { - header, - image, - link, - ulList, - olList, - blockquote, - paragraphWrapper, - sponsorship, - br, - strong, - mem, - italic, - del, - q, - code, - hr, - empty, - newLine, -} = require('atherdon-callbacks'); - -// const layouts = require("atherdon-newsletter-constants"); - -const ConverterTypography = { - heading: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - image: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - italic: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - link: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - list: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - listItem: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - mainTitle: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - paragraph: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - strong: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, - subtitle: { - // key: "REGEXP_H3", - // value: 1, - // title: "xxx", - }, -}; - -// export data diff --git a/source/front-matter/03-hackernoon-source.md b/source/front-matter/03-hackernoon-source.md new file mode 100644 index 000000000..2eb77bc7e --- /dev/null +++ b/source/front-matter/03-hackernoon-source.md @@ -0,0 +1,132 @@ +--- +preview: "As a developer, you might have dreamed of a Google created specifically for techies. Just imagine, a digital platform brimming with content for coders, including Q&A and job listings. Every question about programming answered. Each inextricable bug is solved. A larger audience of qualified experts come-at-able. Sounds dreamlike, right?" +title: "Secrets Of High-Performing Teams: Part II" +ads: + - slogan: The security-as-code solution for developers + - link: https://bit.ly/3n9CgbE + - logo: https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/logos/thematic/2020/October/Bridgecrew_stacked.jpg +images: + - image1: + src: https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image3.gif + link: https://media.giphy.com/media/QNFhOolVeCzPQ2Mx85/giphy.gif + - image2: + src: https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image4.gif + link: https://media.giphy.com/media/l2JeierkQlHpJsGWY/giphy.gif + - image3: + src: https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image6.gif + link: https://media.giphy.com/media/PvvSfSDFoAL5e/giphy.gif + - image4: + src: https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image1.gif + link: https://media.giphy.com/media/3oFzmjFxbBiPQW4qVa/giphy.gif + - image5: + src: https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image5.gif + link: https://media.giphy.com/media/3orieTeAMaKc4yhwmk/giphy.gif + - image6: + src: https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image6.gif + link: https://media.giphy.com/media/PvvSfSDFoAL5e/giphy.gif +--- + + + + +[separator] + +## This is our second newsletter in the series of Secrets of Top-Performing DevOps Teams. In the first part, we’ve got to grips with the [DevOps approach](https://hackernoon.com/devops-fundamentals-you-ever-wanted-to-know-zt2m3uh6) and the way it has [amplified the IT workflow](https://hackernoon.com/tagged/workflow). + + + +[WE NEED TO REPLACE AN IMAGE] + +![alt_text](https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image3.gif "image_tooltip") +[image3] + + + +Here’s a quick reminder and a short introduction for the unaware: + +Tech role has germinated from ["help fix my laptop"](https://hackernoon.com/search?query=horror) to "help me become the best." While [many dev teams are trapped firefighting](https://hackernoon.com/tagged/team-productivity), leading teams [align with the business](https://hackernoon.com/tagged/business), [adopt agile principles](https://hackernoon.com/tagged/agile) and automation, and lead the [digital transformation](https://hackernoon.com/tagged/transformation). + +What’s in it for [DevOps](https://hackernoon.com/tagged/devops), you’d ask? It’s simple: a robust DevOps team facilitates [faster development](https://hackernoon.com/founders-guide-how-to-outsource-software-development-in-2020-y1473yr7) of new products and [easier maintenance](https://hackernoon.com/3-reasons-why-teams-fail-avx3ta7) of existing deployments. + +Read between the lines - agile-based DevOps approach yields an increase in [development productivity](https://hackernoon.com/4-ways-startups-can-use-tech-and-automation-to-be-more-efficient-j3423w51). And with no silver bullet methods for improving IT [efficiency](https://hackernoon.com/if-formula-1-defined-efficiency-675z3yqd), perfecting DevOps might be your best shot. + +Without further ado, let’s dive into our top picks for [DevOps team success](https://hackernoon.com/devops-as-a-service-or-do-you-really-need-a-devops-team-cc4q32wj). + + +## Hacking Your Way Through to a High-Performing DevOps Team + + + +1. [High-performing](https://hackernoon.com/3-easy-ways-to-improve-performance-of-your-python-code-dw183uzo) teams put business first + +You’d say, a [revenue-first mindset](https://hackernoon.com/five-undervalued-data-points-for-emerging-businesses-5c2w3eun) won’t get you the probity medal. However, it’s not our point. In fact, profitability should be your top of mind not for the sake of money only. + + +Successful DevOps teams are more likely to tie their tech projects to revenue, mainly because it’s the 1 [metric for their performance](https://hackernoon.com/the-secret-of-growth-how-to-achieve-dollar1m-arr-in-6-months-vi1832mp). As a result, teams that are business aligned tend to prioritize projects with business management and use business and tech scorecards to measure success. Therefore, just a simple shift from an [activity-driven mindset](https://hackernoon.com/data-that-you-need-is-worth-gold-not-data-that-you-already-have-5c60f9345c6b) to a [revenue-first approach](https://hackernoon.com/4-business-lessons-from-the-failure-of-wework-the-47-billion-dollar-tech-company-3ahi3201) can guarantee a positive change in your team productivity and overall result. + + + (We’re not implying that you should ditch the [customer-centric action](https://hackernoon.com/24-customer-retention-strategies-eq1y3ym0), don’t compare apples and oranges) + +[WE NEED TO REPLACE AN IMAGE] +![alt_text](https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image4.gif "image_tooltip") +[image4] + + + + +2. They assign end-to-end responsibility + +Separating [development](https://hackernoon.com/ownership-and-responsibility-in-software-development-teams-6wr3n17) and [operations](https://hackernoon.com/0-to-90-bn-in-a-decade-uber-takeaways-for-startups-and-roadblocks-ahead-for-uber-b17c3bee2a3f) can present potential issues and pitfalls like [performance problems](https://hackernoon.com/the-surprise-outcome-of-measuring-our-pull-requests-process-4v683tbw) and inconsistent environments. In DevOps, both groups cooperate as a team that's [completely responsible](https://hackernoon.com/take-responsibility-dont-blame-it-on-the-users-hoz3n2u) for a product from beginning to end. + + +Unlike the traditional approach or a [low-performing team](https://hackernoon.com/good-ux-manager-bad-ux-manager-33df51f7367c), where each team member is accountable for their own role, the perfect DevOps team [obliterates those silos](https://hackernoon.com/how-to-prioritize-product-requirements-77d139b4a343) and makes an excellent result the focus of the entire crew. + + +A [developer is no longer just a developer](https://hackernoon.com/highest-paid-software-developer-c66b9f4cc53e) in charge of X lines of code. A tester is no longer accountable for the expected functionality. A high-performing team wears multiple hats and has got it [ALL covered](https://hackernoon.com/dont-optimize-things-that-dont-work-yet-957j30qv). + + +[WE NEED TO REPLACE AN IMAGE] +![https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image6.gif][https://media.giphy.com/media/PvvSfSDFoAL5e/giphy.gif][alt text] +[image6] + +** 3. Automation technology is not an option for a [dazzling performance](https://hackernoon.com/my-top-three-priorities-as-a-software-development-manager-cq2x32c1)** + +Let’s be honest: the bright minds like working with new and shiny technology. And you need those [bright minds](https://hackernoon.com/software-specifications-define-plan-and-execute-more-effective-projects-p0803tzz) in your team to make it high-performing and guarantee superb results. It's a bit hard to employ and keep these big stars in a company that trusts in a [creaky, legacy toolchain](https://hackernoon.com/devops-principles-culture-vs-tooling-vvac367z) to build a product, right? + + +Investing in the [DevOps tools](https://hackernoon.com/7-best-devops-security-practices-devsecops-and-its-merits-mr2p3unk) will not only make the team more effective, but it will also make them want to stay. From a practical standpoint, [automation tools](https://hackernoon.com/automating-security-in-devops-top-15-tools-69253w9e) can increase [tech efficiency](https://hackernoon.com/why-devops-is-important-during-the-covid-19-pandemic-6u1i3tul), eliminate errors, and help [deploy apps faster](https://hackernoon.com/the-difference-between-ci-and-cd-in-devops-bc2z3uae). That refers to simplifying the [process of configuring](https://hackernoon.com/how-to-make-a-devops-strategy-pk153uyb), monitoring, and maintaining the [network infrastructure](https://hackernoon.com/ever-wondered-why-we-use-containers-in-devops-l5113wif). + + +[WE NEED TO REPLACE AN IMAGE] +![https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image1.gif][https://media.giphy.com/media/3oFzmjFxbBiPQW4qVa/giphy.gif][alt text] +[image1] + +------- + +## Pull it all together + +There's no panacea for [successful DevOps team building](https://hackernoon.com/measuring-devops-metrics-a-how-to-guide-ot113ztl), but the process itself is definitely easier than [quantum physics](https://www.hackernoon.com/how-quantum-dots-technology-driving-advancements-in-lcd-and-oled-display-quality-2e163uxg). The majority of our tips and tricks dispensed above are of common-sense variety. In practice, our [secrets](https://hackernoon.com/are-you-telling-the-story-of-your-software-mc133w92) call for good old-fashioned [hard work](https://hackernoon.com/how-to-approach-strategic-planning-when-the-sky-is-falling-oq5k3yer) and a sprinkle of knowledge. + +To deliver top-notch results, employees must be well-settled, teams well-structured, and objectives outlined based on [business priorities](https://hackernoon.com/ceos-survey-on-digital-transformation-in-2017-by-gartner-c2d6e842f86c). And it’s not enough to recruit the right people, retention and training are equally important. Overall, it takes a solid mix of all these components to build a team that truly thrives. + + + +_Join us to welcome today newsletter’s sponsor - [BridgeCrew](https://bit.ly/3n9CgbE). BridgeCrew helps find, fix, and prevent cloud misconfigurations straight from your CI/CD pipeline. Their platform leverages automation and delivers security-as-code to streamline your DevSecOps processes._ + + +* Hacker Noon Stickers +* A standard .TECH domain for 3 years +* A standard .TECH domain for 2 years + * .TECH domain - Sub item 1 + * .TECH domain - Sub item 2 + * .TECH domain -Sub item 3 +* A standard .TECH domain for 5 years + +*HAJKAKKSKKSKAKSK* + +[Got a tech story to share with our readers?](http://auth.hackernoon.com/) Everything you've ever wanted to know about how to get published on Hacker Noon - [get it here](https://hackernoon.com/how-to-get-published-on-hacker-noon-a-step-by-step-guide-zcp36rz). + +[WE NEED TO REPLACE AN IMAGE] +![https://gitlab.com/hackernoon/creative/-/raw/master/newsletters/memes/2020/november/18.11/image5.gif][https://media.giphy.com/media/3orieTeAMaKc4yhwmk/giphy.gif][alt text] + +[image5] \ No newline at end of file diff --git a/source/front-matter/05-source-weekly-menu.md b/source/front-matter/05-source-weekly-menu.md new file mode 100644 index 000000000..c01f6aec6 --- /dev/null +++ b/source/front-matter/05-source-weekly-menu.md @@ -0,0 +1,63 @@ +--- +title: Korean Barbecue Beef | Pork Schnitzel | Bahn Mi Meatball Skewers +date: April 22nd, 2021 +recipes: + - monday: + title: Chipotle Cream Skillet Chicken + subtitle: over Rice and Snap Peas + image: https://raw.githubusercontent.com/LLazyEmail/nomoretogo_email_template/main/data/images/recipe1.jpeg + link: https://www.nomoretogo.com/weekly-menu/ + - thuesday: + title: Pork Schnitzel + subtitle: with German Spaetzle and Green Beans + image: https://raw.githubusercontent.com/LLazyEmail/nomoretogo_email_template/main/data/images/recipe2.jpeg + link: https://www.nomoretogo.com/weekly-menu/ + - wednesday: + title: Bahn Mi Meatball Skewers + subtitle: + image: https://raw.githubusercontent.com/LLazyEmail/nomoretogo_email_template/main/data/images/recipe3.jpeg + link: https://www.nomoretogo.com/weekly-menu/ + - thirsday: + title: Korean Barbecue Beef with Sesame Rice Noodles + subtitle: and Spicy Pickled Cucumbers and Carrots + image: https://raw.githubusercontent.com/LLazyEmail/nomoretogo_email_template/main/data/images/recipe4.jpeg + link: https://www.nomoretogo.com/weekly-menu/ + - friday: + title: Grilled Salmon with Chipotle Cream Sauce + subtitle: over Potato Poblano Hash and Broccolini + image: https://raw.githubusercontent.com/LLazyEmail/nomoretogo_email_template/main/data/images/recipe5.jpeg + link: https://www.nomoretogo.com/weekly-menu/ + - saturday: + title: Saucy Grilled Shrimp + subtitle: and a Corn and Radish Salad with Avocado Dressing + image: https://raw.githubusercontent.com/LLazyEmail/nomoretogo_email_template/main/data/images/recipe6.jpeg + link: https://www.nomoretogo.com/weekly-menu/ +--- + + +# Korean Barbecue Beef | Pork Schnitzel | Bahn Mi Meatball Skewers + + +## Weekly Menu +### April 22nd, 2021 + +We have a very diverse line-up of meals for this week. Kicking off the week we have a delicious flaky salmon with creamy chipotle sauce. Followed by Korean Barbecue Beef, a quick and outstanding dinner! And oh my- the Saucy Shrimp Salad is amazing! Don’t miss the Pork Schnitzel with German Spaetzle. Overall, my family was blown away by this week and I hope yours is too. Enjoy!! + +Happy Cooking, +Stacey, Sloane, and the No More To-Go Team + + +[weekly-menu] + + +### Ingredients + +Saffron: Gives traditional Tandoori its famous yellow coloring. This week we are using it in the marinade for the Yogurt Spiced Chicken. It can be pretty expensive, so turmeric is a good alternative, providing the same color and very comparable taste. + +### Weekend Prep + +Free up your evening and get a little chopping and prep work done this weekend. + +Slice and Dice: Cut the vegetables and store in zippered bags or divided containers. + +Make Ahead and Refrigerate: Make the sauce; Cook the noodles; Make the dressing; Make the spaetzle; Cook the rice. \ No newline at end of file diff --git a/src/callbacks/html/index.js b/src/callbacks/html/index.js index 657338ce8..2d4952088 100644 --- a/src/callbacks/html/index.js +++ b/src/callbacks/html/index.js @@ -1,13 +1,9 @@ import _blockquote from './methods/simple'; -import _previewText from './methods/preview'; import _header from './methods/header'; - import _strong from './methods/strong'; import _link from './methods/link'; - import { // _italic, - _del, _q, _code, @@ -16,23 +12,22 @@ import { } from './methods/simple-without-replacer'; import { _italic, _italicAsterix } from './methods/italic'; - import { _ulList, _olList, getParsedSubList } from './methods/lists'; - import _br from './methods/br'; - -import { _image } from './methods/image'; -import _separator from './methods/separator'; -import _meme from './methods/memes'; -import { _sponsorship } from './methods/sponsor'; - +//--------------- +// advanced callbacks that might get replaced with front matter +import { _image } from './methods/advanced/image'; +import _separator from './methods/advanced/separator'; +import _meme from './methods/advanced/memes'; +import { _sponsorship } from './methods/advanced/sponsor'; +import _previewText from './methods/advanced/preview'; +//--------------- import { _paragraphWrapper } from './methods/paragraph'; export { _strong, _link, _blockquote, - _meme, _header, //------------ _italic, @@ -54,4 +49,5 @@ export { _br, _separator, _previewText, + _meme, }; diff --git a/src/callbacks/html/methods/image.js b/src/callbacks/html/methods/advanced/image.js similarity index 88% rename from src/callbacks/html/methods/image.js rename to src/callbacks/html/methods/advanced/image.js index 23d8b4b69..d1ff7fc2f 100644 --- a/src/callbacks/html/methods/image.js +++ b/src/callbacks/html/methods/advanced/image.js @@ -1,4 +1,4 @@ -import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; +import { commonReplace } from '../../../../domain/replace-wrapper3.0/commonReplace'; // TODO remove unused `text` argument export function _image(text, alt, srcWithTooltip) { diff --git a/src/callbacks/html/methods/memes.js b/src/callbacks/html/methods/advanced/memes.js similarity index 82% rename from src/callbacks/html/methods/memes.js rename to src/callbacks/html/methods/advanced/memes.js index 32dbb3edb..761ba74c8 100644 --- a/src/callbacks/html/methods/memes.js +++ b/src/callbacks/html/methods/advanced/memes.js @@ -1,4 +1,4 @@ -import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; +import { commonReplace } from '../../../../domain/replace-wrapper3.0/commonReplace'; // // TODO remove unused `text` argument function _meme(text, src, href, altText) { diff --git a/src/callbacks/html/methods/preview.js b/src/callbacks/html/methods/advanced/preview.js similarity index 83% rename from src/callbacks/html/methods/preview.js rename to src/callbacks/html/methods/advanced/preview.js index 7dbbcf7f7..5d439eab2 100644 --- a/src/callbacks/html/methods/preview.js +++ b/src/callbacks/html/methods/advanced/preview.js @@ -1,4 +1,4 @@ -import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; +import { commonReplace } from '../../../../domain/replace-wrapper3.0/commonReplace'; // TODO remove unused `text` argument function _previewText(text, content) { diff --git a/src/callbacks/html/methods/separator.js b/src/callbacks/html/methods/advanced/separator.js similarity index 78% rename from src/callbacks/html/methods/separator.js rename to src/callbacks/html/methods/advanced/separator.js index 10c2561e7..95c478482 100644 --- a/src/callbacks/html/methods/separator.js +++ b/src/callbacks/html/methods/advanced/separator.js @@ -1,6 +1,6 @@ -import { newLine } from '../helpers'; +import { newLine } from '../../helpers'; -import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; +import { commonReplace } from '../../../../domain/replace-wrapper3.0/commonReplace'; function _separator( text, diff --git a/src/callbacks/html/methods/sponsor.js b/src/callbacks/html/methods/advanced/sponsor.js similarity index 92% rename from src/callbacks/html/methods/sponsor.js rename to src/callbacks/html/methods/advanced/sponsor.js index 3dd21f071..f003f10a7 100644 --- a/src/callbacks/html/methods/sponsor.js +++ b/src/callbacks/html/methods/advanced/sponsor.js @@ -1,4 +1,4 @@ -import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; +import { commonReplace } from '../../../../domain/replace-wrapper3.0/commonReplace'; export function _sponsorship(markdown_string) { // TODO move out this regex into constants file. diff --git a/src/callbacksReact/index.js b/src/callbacksReact/index.js index 67b8f7bcd..c8be04338 100644 --- a/src/callbacksReact/index.js +++ b/src/callbacksReact/index.js @@ -3,6 +3,20 @@ import * as callbacks from './methods/callbacks'; import * as lists from './methods/lists'; import _header from './methods/header'; -const Callbacks = { ...simple, ...lists, _header, ...callbacks }; +import _sponsorship from './methods/advanced/sponsor'; +import _previewText from './methods/advanced/preview'; +import _meme from './methods/advanced/meme'; +import _image from './methods/advanced/image'; + +const Callbacks = { + ...simple, + ...lists, + _header, + ...callbacks, + _sponsorship, + _previewText, + _meme, + _image, +}; export { Callbacks }; diff --git a/src/callbacksReact/methods/advanced/image.js b/src/callbacksReact/methods/advanced/image.js new file mode 100644 index 000000000..98bbd0a6f --- /dev/null +++ b/src/callbacksReact/methods/advanced/image.js @@ -0,0 +1,25 @@ +// import { newLine } from '../../../domain/helper-methods'; +import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; + +function _image(text, alt, srcWithTooltip) { + const src = srcWithTooltip.trim().replace(/\"image_tooltip\"/, ''); + + const params = { + src: src.trim(), + altText: alt, + }; + + const config = { + configurationMap: this.configurationMap, + params, + name: 'image', + debug: true, + }; + + this.warnings.images += 1; + + const replaced = commonReplace(config); + + return replaced; +} +export default _image; diff --git a/src/callbacksReact/methods/advanced/meme.js b/src/callbacksReact/methods/advanced/meme.js new file mode 100644 index 000000000..009d24796 --- /dev/null +++ b/src/callbacksReact/methods/advanced/meme.js @@ -0,0 +1,23 @@ +// import { newLine } from '../../../domain/helper-methods'; + +import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; + +function _meme(text, src, href, altText) { + const params = { + src: src.trim(), + altText: altText.trim(), + href: href.trim(), + }; + + const config = { + configurationMap: this.configurationMap, + params, + name: 'meme', + debug: true, + }; + + const replaced = commonReplace(config); + return replaced; +} + +export default _meme; diff --git a/src/callbacksReact/methods/advanced/preview.js b/src/callbacksReact/methods/advanced/preview.js new file mode 100644 index 000000000..d1b1feef6 --- /dev/null +++ b/src/callbacksReact/methods/advanced/preview.js @@ -0,0 +1,20 @@ +import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; + +function _previewText(text, content) { + const params = { + content, + }; + + const config = { + configurationMap: this.configurationMap, + params, + name: 'previewText', + debug: true, + }; + + // this.previewText = true; + + const replaced = commonReplace(config); + return replaced; +} +export default _previewText; diff --git a/src/callbacksReact/methods/advanced/separator.js b/src/callbacksReact/methods/advanced/separator.js new file mode 100644 index 000000000..1811a7d52 --- /dev/null +++ b/src/callbacksReact/methods/advanced/separator.js @@ -0,0 +1,21 @@ +import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; +import { newLine } from '../../../domain/helper-methods'; + +function _separator(text) { + const params = { + content: text.trim(), // we have an issue, when we passing empty params + }; + + const config = { + configurationMap: this.configurationMap, + params, + + name: 'separator', + debug: true, + }; + + const replaced = commonReplace(config); + return newLine + replaced + newLine; +} + +export default _separator; diff --git a/src/callbacksReact/methods/advanced/sponsor.js b/src/callbacksReact/methods/advanced/sponsor.js new file mode 100644 index 000000000..7b2663324 --- /dev/null +++ b/src/callbacksReact/methods/advanced/sponsor.js @@ -0,0 +1,37 @@ +// import { newLine } from '../../../domain/helper-methods'; + +import { commonReplace } from '../../../domain/replace-wrapper3.0/commonReplace'; + +function _sponsorship(text) { + // TODO move out this regex into constants file. + const regex = /\[(.*?)\]/g; + + const regex2 = /[\[\]]/g; + + const [content, href, src] = text + .match(regex) + .map((match) => match.replace(regex2, '')); + + const params = { + src: src.trim(), + href: href.trim(), + content: content.trim(), + }; + + const config = { + configurationMap: this.configurationMap, + params, + name: 'sponsor', + debug: true, + }; + const replaced = commonReplace(config); + return replaced; + + // TODO upgrade a way to handle errors in state object + // eslint-disable-next-line no-unused-expressions + // this.errors.sponsorshipTop + // ? (this.errors.sponsorshipBottom = true) + // : (this.errors.sponsorshipTop = true); +} + +export default _sponsorship; diff --git a/src/callbacksReact/methods/custom.js b/src/callbacksReact/methods/custom.js deleted file mode 100644 index cb0ff5c3b..000000000 --- a/src/callbacksReact/methods/custom.js +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/callbacksReact/methods/simple.js b/src/callbacksReact/methods/simple.js index de70bc812..6afaa016b 100644 --- a/src/callbacksReact/methods/simple.js +++ b/src/callbacksReact/methods/simple.js @@ -122,85 +122,10 @@ function _blockquote() { // }; } -function _meme(text, src, href, altText) { - const params = { - src: src.trim(), - altText: altText.trim(), - href: href.trim(), - }; - - const config = { - configurationMap: this.configurationMap, - params, - name: 'meme', - debug: true, - }; - - const replaced = commonReplace(config); - return replaced; -} - -// function _header(text, chars, content) { -// const params = { -// content: content.trim(), -// }; - -// const titleType = ['mainTitle', 'subtitle', 'heading']; -// const name = titleTypes[chars.length - 1]; - -// const config = { -// configurationMap: this.configurationMap, -// params, -// name, - -// // debug: true, -// }; - -// const replaced = commonReplace(config); -// return newLine + replaced; - -// } - -function _separator(text) { - const params = { - content: text.trim(), // we have an issue, when we passing empty params - }; - - const config = { - configurationMap: this.configurationMap, - params, - - name: 'separator', - debug: true, - }; - - const replaced = commonReplace(config); - return newLine + replaced + newLine; -} - -function _previewText(text, content) { - const params = { - content, - }; - - const config = { - configurationMap: this.configurationMap, - params, - name: 'previewText', - debug: true, - }; - - // this.previewText = true; - - const replaced = commonReplace(config); - return replaced; -} - export { _strong, _link, _blockquote, - _meme, // _header, _italic, _del, @@ -208,6 +133,4 @@ export { _code, _hr, _empty, - _previewText, - _separator, }; diff --git a/src/constants/addon.js b/src/constants/addon.js index 39ce9aea8..f01832275 100644 --- a/src/constants/addon.js +++ b/src/constants/addon.js @@ -9,8 +9,6 @@ const REGEXP_SECTION_TAGS = /^<\/?(ul|ol|li|h|p|bl)/i; const REGEXP_IMAGE_TOOLTIP = /\"image_tooltip\"/; const REGEXP_NEWLINE = `${newLine}g`; -// const REGEXP_SPONSORHSHIP = - // command-line-methods.js // const REGEXP_BASIC_TABLE_TAGS = new RegExp('(|)', 'i'); diff --git a/src/constants/customTags.js b/src/constants/customTags.js index a46843da9..eb19c824f 100644 --- a/src/constants/customTags.js +++ b/src/constants/customTags.js @@ -5,12 +5,17 @@ import os from 'os'; const platform = os.platform(); const newLine = platform === 'win32' ? '\r\n' : '\n'; - +// those RegEx`es might gone after integration of front matter const REGEXP_SPONSORSHIP = /~(\[(.*?)\]){3}/g; const REGEXP_HTML_COMMENTS = //g; // eslint-disable-next-line no-useless-escape const REGEXP_MEM = /\!\[(.*?)\]\[(.*?)\]\[(.*?)\]/g; const REGEXP_PREVIEW_TEXT = new RegExp(`#~(.*?)${newLine}`); +//------- +// TODO add that beforeMethod +const regexString = `\\[separator\\]`; +const REGEXP_SEPARATOR = new RegExp(newLine + regexString + newLine, 'g'); +//---------- const REGEXP_HASH_TAG = new RegExp( // eslint-disable-next-line no-control-regex @@ -24,9 +29,8 @@ const REGEXP_LINK_HTTPS = new RegExp('>https', 'g'); const REGEXP_STR_BEGIN = '>https'; const REGEXP_STR_END = 'f<'; -// TODO add that beforeMethod -const regex_string = `\\[separator\\]`; -const REGEXP_SEPARATOR = new RegExp(newLine + regex_string + newLine, 'g'); +const regexString2 = `\\[image\\d\\]`; +const REGEXP_IMAGES_FRONT = new RegExp(newLine + regexString2 + newLine, 'g'); export { REGEXP_SPONSORSHIP, @@ -39,4 +43,6 @@ export { REGEXP_STR_BEGIN, REGEXP_STR_END, REGEXP_SEPARATOR, + // ------------ + REGEXP_IMAGES_FRONT, }; diff --git a/src/constants/regexp/_to-try.js b/src/constants/regexp/_to-try.js deleted file mode 100644 index 387e2966f..000000000 --- a/src/constants/regexp/_to-try.js +++ /dev/null @@ -1,28 +0,0 @@ -// @todo or expand this thing -// this.rules = [ -// {regex: /(#+)(.*)/g, replacement: header}, // headers -// {regex: /!\[([^\[]+)\]\(([^\)]+)\)/g, replacement: '\'$1\''}, // image -// {regex: /\[([^\[]+)\]\(([^\)]+)\)/g, replacement: '$1'}, // hyperlink -// {regex: /(\*\*|__)(.*?)\1/g, replacement: '$2'}, // bold -// {regex: /(\*|_)(.*?)\1/g, replacement: '$2'}, // emphasis -// {regex: /\~\~(.*?)\~\~/g, replacement: '$1'}, // del -// {regex: /\:\"(.*?)\"\:/g, replacement: '$1'}, // quote -// {regex: /`(.*?)`/g, replacement: '$1'}, // inline code -// {regex: /\n\*(.*)/g, replacement: ulList}, // ul lists -// {regex: /\n[0-9]+\.(.*)/g, replacement: olList}, // ol lists -// {regex: /\n(>|\>)(.*)/g, replacement: blockquote}, // blockquotes -// {regex: /\n-{5,}/g, replacement: '\n
'}, // horizontal rule -// {regex: /\n([^\n]+)\n/g, replacement: para}, // add paragraphs -// {regex: /<\/ul>\s?