Skip to content

Commit 46c2e5b

Browse files
authored
Merge pull request markedjs#1182 from UziTech/cmd-string
allow string arg from command line
2 parents cb0b639 + c5df14c commit 46c2e5b

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

bin/marked

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ function main(argv, callback) {
4141
options = {},
4242
input,
4343
output,
44+
string,
4445
arg,
4546
tokens,
4647
opt;
@@ -86,6 +87,10 @@ function main(argv, callback) {
8687
case '--input':
8788
input = argv.shift();
8889
break;
90+
case '-s':
91+
case '--string':
92+
string = argv.shift();
93+
break;
8994
case '-t':
9095
case '--tokens':
9196
tokens = true;
@@ -118,6 +123,9 @@ function main(argv, callback) {
118123
function getData(callback) {
119124
if (!input) {
120125
if (files.length <= 2) {
126+
if (string) {
127+
return callback(null, string);
128+
}
121129
return getStdin(callback);
122130
}
123131
input = files.pop();

docs/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ $ cat hello.html
4949
<p>hello world</p>
5050
```
5151

52+
``` bash
53+
$ marked -s "*hello world*"
54+
<p><em>hello world</em></p>
55+
```
56+
5257
**Browser**
5358

5459
```html

test/unit/marked-spec.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ it('should run the test', function () {
77
});
88

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

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

0 commit comments

Comments
 (0)