Skip to content

Commit

Permalink
Merge pull request markedjs#1182 from UziTech/cmd-string
Browse files Browse the repository at this point in the history
allow string arg from command line
  • Loading branch information
joshbruce authored Apr 5, 2018
2 parents cb0b639 + c5df14c commit 46c2e5b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
8 changes: 8 additions & 0 deletions bin/marked
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function main(argv, callback) {
options = {},
input,
output,
string,
arg,
tokens,
opt;
Expand Down Expand Up @@ -86,6 +87,10 @@ function main(argv, callback) {
case '--input':
input = argv.shift();
break;
case '-s':
case '--string':
string = argv.shift();
break;
case '-t':
case '--tokens':
tokens = true;
Expand Down Expand Up @@ -118,6 +123,9 @@ function main(argv, callback) {
function getData(callback) {
if (!input) {
if (files.length <= 2) {
if (string) {
return callback(null, string);
}
return getStdin(callback);
}
input = files.pop();
Expand Down
5 changes: 5 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ $ cat hello.html
<p>hello world</p>
```

``` bash
$ marked -s "*hello world*"
<p><em>hello world</em></p>
```

**Browser**

```html
Expand Down
20 changes: 10 additions & 10 deletions test/unit/marked-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ it('should run the test', function () {
});

describe('Test heading ID functionality', function() {
it('should add id attribute by default', function() {
var renderer = new marked.Renderer(marked.defaults);
var header = renderer.heading('test', 1, 'test');
expect(header).toBe('<h1 id="test">test</h1>\n');
});
it('should add id attribute by default', function() {
var renderer = new marked.Renderer(marked.defaults);
var header = renderer.heading('test', 1, 'test');
expect(header).toBe('<h1 id="test">test</h1>\n');
});

it('should NOT add id attribute when options set false', function() {
var renderer = new marked.Renderer({ headerIds: false });
var header = renderer.heading('test', 1, 'test');
expect(header).toBe('<h1>test</h1>\n');
});
it('should NOT add id attribute when options set false', function() {
var renderer = new marked.Renderer({ headerIds: false });
var header = renderer.heading('test', 1, 'test');
expect(header).toBe('<h1>test</h1>\n');
});
});

0 comments on commit 46c2e5b

Please sign in to comment.