I am trying to use stack over flows markdown editor showdown by its Angularjs Module ng-showdown
Everything is going fine but the image that are getting included are in their actual/original size.
how to resize them to fit in the text?
Given below is a dummy that is showing the same problem.
Many thanks!!!
<html ng-app="theShowdown">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular-route.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular-animate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/1.2.1/ui-bootstrap-tpls.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.3.0/showdown.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular-sanitize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ng-showdown/1.1.0/ng-showdown.min.js"></script>
<script>
var theShowdown = angular.module('theShowdown', ['ngRoute', 'ngSanitize', 'ngAnimate', 'ui.bootstrap', 'ng-showdown']);
theShowdown.config(function() {
})
theShowdown.controller('theMain', function($scope, $showdown) {
$scope.mymarkdown = `**Hello** _Stackover Flow_ ![Showdown][sd-logo]
[sd-logo]: http://logz.io/wp-content/uploads/2016/02/stack-overflow-logo.png`;
var htmlValue = $showdown.makeHtml($scope.mymarkdown)
})
</script>
</head>
<body ng-controller="theMain">
<p markdown-to-html="mymarkdown"></p>
<textarea rows="4" cols="150" ng-model="mymarkdown"></textarea>
</body>
</html>
I'm the current showdown's project leader.
As per showdown's documentation:
parseImgDimensions: (boolean) [default false] Enable support for setting image dimensions from within markdown syntax. Examples:
![foo](foo.jpg =100x80) simple, assumes units are in px ![bar](bar.jpg =100x*) sets the height to "auto" ![baz](baz.jpg =80%x5em) Image with width of 80% and height of 5em
So you need to enable the option parseImgDimensions and then use the above syntax.
Passing options in the constructor:
var converter = new showdown.Converter({parseImgDimensions: true});
or
var converter = new showdown.Converter();
converter.setOption('parseImgDimensions', true);