2

我正在尝试通过其 Angularjs 模块ng-showdown使用堆栈而不是流降价编辑器摊牌

一切都很好,但包含的图像是它们的实际/原始大小。

如何调整它们的大小以适合文本?

下面给出的是一个显示相同问题的假人。

非常感谢!!!

<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>

4

2 回答 2

4

免责声明:

我是当前摊牌的项目负责人。


根据摊牌的文档

parseImgDimensions: (boolean) [default false] 启用对在 markdown 语法中设置图像尺寸的支持。例子:

![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

因此,您需要启用parseImgDimensions选项,然后使用上述语法。

例子

在构造函数中传递选项:

var converter = new showdown.Converter({parseImgDimensions: true});

或者

var converter = new showdown.Converter();
converter.setOption('parseImgDimensions', true);
于 2016-06-21T16:53:05.500 回答
2

终于找到方法了

在声明链接添加的 URL 时abc.png =100x*,它将高度设置为 100,宽度将自动计算。

于 2016-06-21T10:08:05.900 回答