Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow string arg from command line #1182

Merged
merged 4 commits into from
Apr 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});