-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(convert-markdown): Convert markdown inline code blocks to cli
- Loading branch information
Simon Mollweide
committed
Dec 17, 2017
1 parent
419fc39
commit 5169517
Showing
7 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
```html | ||
// Key and Value | ||
react.impulsCoach.components.teaserOverview.title = This is an <a href="#">example</a> | ||
react.components.title = This is an <a href="#">example</a> | ||
```; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
``` | ||
// Key and Value | ||
react.impulsCoach.components.teaserOverview.title = This is an <a href="#">example</a> | ||
react.components.title = This is an <a href="#">example</a> | ||
```; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Contribute buddy collect all readme files in the project and split them into sections and topics by using the `h1` and `h2` headlines. These sections and topics will be displayed in the cli before start (and after install) if you didn't read them before and nothing had changed. The reading history will be stored in your filesystem (user directory). | ||
|
||
```html | ||
// Key and Value | ||
react.components.title = This is an <a href="#">example</a> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const symbols = require('../symbols'); | ||
|
||
/** | ||
* @param {string} markdown - the readme files data | ||
* @param {Object} di - dependency injection | ||
* @returns {string} markdown - replaced readme file data | ||
**/ | ||
function convertMarkdownInlineCodeToCli(markdown) { | ||
const reg = /(`)([^`]*)(`)/g; | ||
let results; | ||
|
||
// eslint-disable-next-line | ||
while ((results = reg.exec(markdown)) !== null) { | ||
if (results[0] !== '``' && results[0].indexOf('\n') < 0) { | ||
markdown = markdown.replace(results[0], symbols.codeInline.msg(results[2])); | ||
} | ||
} | ||
|
||
return markdown; | ||
} | ||
|
||
module.exports = convertMarkdownInlineCodeToCli; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* eslint quote-props: 0*/ | ||
const fs = require('fs'); | ||
const convertMarkdownInlineCodeToCli = require('./index'); | ||
|
||
describe('convertMarkdownInlineCodeToCli', () => { | ||
it('default', () => { | ||
const data = fs.readFileSync('./src/convertMarkdownInlineCodeToCli/__mocks__/default.md', 'utf8'); | ||
expect(typeof convertMarkdownInlineCodeToCli(data)).toBe('string'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters