使用Gulp标记HTML并使用语法高亮显示

时间:2016-01-27 08:05:38

标签: javascript html gulp markdown

我正在使用gulp-markdown包将markdown文件呈现为HTML部分。 (它使用npm marked包进行实际渲染。)除了我的代码块之外,一切都很好!如何获得正确格式化的HTML?

这是我的意思:

var gulp      = require('gulp');
var markdown  = require('gulp-markdown');
markdown.marked.setOptions({
  renderer: new markdown.marked.Renderer(),
  gfm: true,
  tables: true,
  breaks: false,
  pedantic: false,
  sanitize: true,
  smartLists: true,
  smartypants: false
});

// turn md files into html partials
gulp.task('blogPosts', function () {
    return gulp.src('src/blog/blogOne.md')
        .pipe(markdown())
        .pipe(gulp.dest('src/partials'));
});

这是我的降价:

```JavaScript
app.controller('DisplayController', ['$scope', 'ClogsService', function($scope, ClogsService){
  $scope.clogs = [];
  $scope.getClogs = function() {
    ClogService.getClogs()
      .then(function(response){
        ClogsService.clogs = response.data;
          $scope.clogs = ClogsService.clogs;
      });
    };
})
```

这是输出HTML:

<pre><code>app.controller(&#39;DisplayController&#39;, [&#39;$scope&#39;, &#39;ClogsService&#39;, function($scope, ClogsService){
  $scope.clogs = [];
  $scope.getClogs = function() {
    ClogService.getClogs()
      .then(function(response){
        ClogsService.clogs = response.data;
          $scope.clogs = ClogsService.clogs;
      });
    };
})
</code></pre>

我的页面呈现如下:enter image description here

如何使用语法高亮显示正确呈现代码块的页面?

0 个答案:

没有答案