@@ -7,6 +7,18 @@ var striptags = require('striptags');
7
7
var DocMapInfo = require ( "../doc-map-info" ) ;
8
8
var unescapeHTML = require ( "unescape-html" ) ;
9
9
10
+
11
+ function escapeOnlySingleElements ( text ) {
12
+ //This could be an alternate way of detecting if markdown escaped
13
+ //var html = stmd_to_html("<p>"+text+"</p>\n");
14
+ //if(html === "<p>"+text+"</p>\n") { }
15
+ if ( / ^ < \w + \/ ? > $ / . test ( text ) ) {
16
+ return escape ( text ) ;
17
+ } else {
18
+ return text ;
19
+ }
20
+ }
21
+
10
22
// Helper helpers
11
23
12
24
var sortChildren = function ( child1 , child2 ) {
@@ -200,11 +212,11 @@ module.exports = function(docMap, config, getCurrent, Handlebars){
200
212
* @body
201
213
*
202
214
* ## Use
203
- *
215
+ *
204
216
* ```
205
217
* {{{generatedWarning}}}
206
218
* ```
207
- *
219
+ *
208
220
* MUST use triple-braces to escape HTML so it is hidden in a comment.
209
221
*
210
222
* Creates a warning that looks like this:
@@ -230,7 +242,7 @@ module.exports = function(docMap, config, getCurrent, Handlebars){
230
242
} ,
231
243
/**
232
244
* @function bit-docs-generate-html/build/make_default_helpers.makeTitle makeTitle
233
- *
245
+ *
234
246
* Given the [bit-docs/types/docObject] context, returns a "pretty"
235
247
* name that is used in the sidebar and the page header.
236
248
*/
@@ -288,13 +300,15 @@ module.exports = function(docMap, config, getCurrent, Handlebars){
288
300
//if there is anything in the hashParts, append it to the end of the url
289
301
href = urlTo ( name ) + ( hashParts . length >= 1 ? ( "#" + hashParts . join ( "#" ) ) : "" ) ;
290
302
291
- return '<a href="' + href + '" title="' + stripMarkdown ( description ) + '">' + linkText + '</a>' ;
303
+
304
+
305
+ return '<a href="' + href + '" title="' + stripMarkdown ( description ) + '">' + escapeOnlySingleElements ( linkText ) + '</a>' ;
292
306
}
293
307
294
308
if ( httpRegExp . test ( name ) ) {
295
309
linkText = parts && parts [ 2 ] ? parts [ 2 ] : name ;
296
310
href = name ;
297
- return '<a href="' + href + '" title="' + escape ( linkText ) + '">' + linkText + '</a>' ;
311
+ return '<a href="' + href + '" title="' + escape ( linkText ) + '">' + escapeOnlySingleElements ( linkText ) + '</a>' ;
298
312
}
299
313
300
314
return match ;
0 commit comments