Commit 9a0cb9753aa09409d5e2c0281ea1c6fe95dbdd12
Strip markdown from issue and pull request titles.
Stephen Whitmore committed on 12/23/2016, 9:39:39 PMParent: 843b716024394e2e1d8f44552cbcd044a9305d0a
Files changed
lib/repos/issues.js | changed |
lib/repos/pulls.js | changed |
lib/util.js | changed |
package.json | changed |
lib/repos/issues.js | ||
---|---|---|
@@ -66,9 +66,9 @@ | ||
66 | 66 … | return '<section class="collapse">' + |
67 | 67 … | '<i class="issue-state issue-state-' + state + '"' + |
68 | 68 … | ' title="' + stateStr + '">◼</i> ' + |
69 | 69 … | '<a href="' + u.encodeLink(issue.id) + '">' + |
70 | - u.escape(issue.title) + | |
70 … | + u.formatMarkdownTitle(issue.title) + | |
71 | 71 … | '<span class="right-bar">' + |
72 | 72 … | new Date(issue.created_at).toLocaleString(req._locale) + |
73 | 73 … | '</span>' + |
74 | 74 … | '</a>' + |
@@ -99,12 +99,12 @@ | ||
99 | 99 … | |
100 | 100 … | I.serveRepoIssue = function (req, repo, issue, path, postId) { |
101 | 101 … | var self = this |
102 | 102 … | var newestMsg = {key: issue.id, value: {timestamp: issue.created_at}} |
103 | - var title = u.escape(issue.title) + ' · %{author}/%{repo}' | |
103 … | + var title = u.formatMarkdownTitle(issue.title) + ' · %{author}/%{repo}' | |
104 | 104 … | return self.repo.serveRepoTemplate(req, repo, 'issues', null, title, cat([ |
105 | 105 … | pull.once( |
106 | - '<h3>' + u.link([issue.id], issue.title) + '</h3>' + | |
106 … | + '<h3>' + u.link([issue.id], u.formatMarkdownTitle(issue.title)) + '</h3>' + | |
107 | 107 … | '<code>' + issue.id + '</code>' + |
108 | 108 … | '<section class="collapse">' + |
109 | 109 … | (issue.open |
110 | 110 … | ? '<strong class="issue-status open">' + |
lib/repos/pulls.js | |||
---|---|---|---|
@@ -25,12 +25,12 @@ | |||
25 | 25 … | P.serveRepoPullReq = function (req, repo, pr, path, postId) { | |
26 | 26 … | var self = this | |
27 | 27 … | var headRepo, authorLink | |
28 | 28 … | var page = path[0] || 'activity' | |
29 | - var title = u.escape(pr.title) + ' · %{author}/%{repo}' | ||
29 … | + var title = u.formatMarkdownTitle(pr.title)) + ' · %{author}/%{repo}' | ||
30 | 30 … | return self.repo.serveRepoTemplate(req, repo, 'pulls', null, title, cat([ | |
31 | 31 … | pull.once('<div class="pull-request">' + | |
32 | - '<h3>' + u.link([pr.id], pr.title) + '</h3>' + | ||
32 … | + '<h3>' + u.link([pr.id], u.formatMarkdownTitle(pr.title)) + '</h3>' + | ||
33 | 33 … | '<code>' + pr.id + '</code>'), | |
34 | 34 … | u.readOnce(function (cb) { | |
35 | 35 … | var done = multicb({ pluck: 1, spread: true }) | |
36 | 36 … | var gotHeadRepo = done() |
lib/util.js | ||
---|---|---|
@@ -1,8 +1,9 @@ | ||
1 | 1 … | var pull = require('pull-stream') |
2 | 2 … | var h = require('pull-hyperscript') |
3 | 3 … | var paramap = require('pull-paramap') |
4 | 4 … | var Highlight = require('highlight.js') |
5 … | +var removeMd = require('remove-markdown') | |
5 | 6 … | var u = exports |
6 | 7 … | |
7 | 8 … | u.imgMimes = { |
8 | 9 … | png: 'image/png', |
@@ -217,4 +218,8 @@ | ||
217 | 218 … | }) |
218 | 219 … | } else cb(null, msg) |
219 | 220 … | }, 4) |
220 | 221 … | } |
222 … | + | |
223 … | +u.formatMarkdownTitle = function (title) { | |
224 … | + return u.escape(removeMd(title)) | |
225 … | +} |
package.json | ||
---|---|---|
@@ -20,8 +20,9 @@ | ||
20 | 20 … | "pull-identify-filetype": "^1.1.0", |
21 | 21 … | "pull-many": "^1.0.8", |
22 | 22 … | "pull-paramap": "^1.2.1", |
23 | 23 … | "pull-stream": "^3.5.0", |
24 … | + "remove-markdown": "^0.1.0", | |
24 | 25 … | "ssb-client": "^4.2.1", |
25 | 26 … | "ssb-config": "^2.2.0", |
26 | 27 … | "ssb-git-repo": "^2.4.0", |
27 | 28 … | "ssb-issues": "^1.0.0", |
Built with git-ssb-web