-
Notifications
You must be signed in to change notification settings - Fork 59
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 setting options per directive instance. #70
Comments
Actually, using the service, you can add options on the fly: <div ng-bind-html="htmlContent"></div> $scope.htmlContent = marked($scope.markdownContent, $scope.options); This also allows to override temporarily the renderer, so you can do things such as changing the way headings are rendered or make advanced custom dynamic content wherever you want without impacting other markdown editors in your app like so: var customRenderer = new marked.Renderer();
customRenderer.heading = function (text, level) {
return 'Title ' + level + ': ' + text; // renders Title 1: <text> instead of using <h1> tags
}
$scope.htmlContent = marked(markdownContent, {renderer: customRenderer}); And you won't loose the other options, it only overrides the ones provided to the service. |
Im concerned about performance implications of the solution proposed. If I'm not wrong about how |
Just to make sure, I tested it with both However, EDIT: BTW, what I did is having the textarea bound to |
Never mind. I was blind about the fact that the result of a function call is assigned (which is not a function itself) rather than the function called. |
Currently, one can configure options for the Marked renderer globally only using the
markedProvider
. It would be great if it would be possible, as an alternative, to provide options per directive instance.Something like:
where
expression
is an Angular expression that evaluates to a Marked options object. For instance, it could be a reference to some property defined in some (parent) scope:The text was updated successfully, but these errors were encountered: