Skip to content

Allow options JavaScript file to be provided for cli#613

Closed
matthewp wants to merge 1 commit intomarkedjs:masterfrom
matthewp:marked-options
Closed

Allow options JavaScript file to be provided for cli#613
matthewp wants to merge 1 commit intomarkedjs:masterfrom
matthewp:marked-options

Conversation

@matthewp
Copy link
Copy Markdown

@matthewp matthewp commented Jul 1, 2015

This adds an --options option. The use case is if you want to provide
more advanced options that are possible with the cli options. For
example you might want to provide a syntax highlighting function. You
could define a module like:

var highlight = require("highlight.js");

module.exports = {
  langPrefix: 'hljs ',
  highlight: function(code){
    return highlight.highlightAuto(code).value;
  }
};

and then you can use it from the cli:

cat post.md | marked --options marked_options.js

This adds an `--options` option. The use case is if you want to provide
more advanced options that are possible with the cli options. For
example you might want to provide a syntax highlighting function. You
could define a module like:

```js
var highlight = require("highlight.js");

module.exports = {
  langPrefix: 'hljs ',
  highlight: function(code){
    return highlight.highlightAuto(code).value;
  }
};
```

and then you can use it from the cli:

```shell
cat post.md | marked --options marked_options.js
```

 Please enter the commit message for your changes. Lines starting
@matthewp
Copy link
Copy Markdown
Author

matthewp commented Oct 1, 2015

@chjj any opinion on this?

@UziTech
Copy link
Copy Markdown
Member

UziTech commented Apr 11, 2018

This seems very useful, however I think we are going to deprecate most options at some point to try to slim down marked, and I feel like this would be a short lived feature.

Thoughts @joshbruce @styfle?

@styfle
Copy link
Copy Markdown
Member

styfle commented Apr 11, 2018

I would hold off on this one too (it seems its already been on hold for 3 years).

Thinking out loud here, we might want to create a separate package marked-cli that depends on the marked package. That way the users who have no intention of every using the cli don't get anything extra.

The other thing about this PR, although its elegant, it feels wrong to pass a js file as "options".

@UziTech
Copy link
Copy Markdown
Member

UziTech commented Apr 11, 2018

I like the marked-cli idea 👍

@joshbruce
Copy link
Copy Markdown
Member

Been thinking about separating packages a bit as well. Marked (client-side), Marked CLI, then the docs site. But this would be something more in the 1.x or 2.x imho.

@matthewp
Copy link
Copy Markdown
Author

This can be closed then if you all are thinking of a different approach.

@joshbruce
Copy link
Copy Markdown
Member

@matthewp: Thanks for the okay. We'll probably leave it open for a little bit. We're mainly just looking to triage things a bit better to turn the focus on passing the test cases and examples for the two supported specifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants