Skip to content
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

Support HTML5 element id #801

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var browserify = require('gulp-browserify')

var preserveFirstComment = function() {
var set = false;
Expand All @@ -14,6 +15,7 @@ var preserveFirstComment = function() {

gulp.task('uglify', function() {
gulp.src('lib/marked.js')
.pipe(browserify())
.pipe(uglify({preserveComments: preserveFirstComment()}))
.pipe(concat('marked.min.js'))
.pipe(gulp.dest('.'));
Expand Down
6 changes: 4 additions & 2 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* https://github.com/chjj/marked
*/

var fuckIE = require('fuck-ie')

;(function() {

/**
Expand Down Expand Up @@ -797,7 +799,7 @@ Renderer.prototype.heading = function(text, level, raw) {
+ level
+ ' id="'
+ this.options.headerPrefix
+ raw.toLowerCase().replace(/[^\w]+/g, '-')
+ fuckIE(6, 7, 8) ? raw.toLowerCase().replace(/[^\w]+/g, '-') : raw
+ '">'
+ text
+ '</h'
Expand Down Expand Up @@ -1094,7 +1096,7 @@ function escape(html, encode) {
}

function unescape(html) {
// explicitly match decimal, hex, and named HTML entities
// explicitly match decimal, hex, and named HTML entities
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g, function(_, n) {
n = n.toLowerCase();
if (n === 'colon') return ':';
Expand Down
Loading