File tree Expand file tree Collapse file tree 2 files changed +26
-16
lines changed Expand file tree Collapse file tree 2 files changed +26
-16
lines changed Original file line number Diff line number Diff line change @@ -85,14 +85,23 @@ var getConfig = function(lineString, lineCount) {
85
85
} ;
86
86
} ;
87
87
88
- function findPreviousSibling ( el , tag ) {
88
+ function findPreviousSibling ( start , tag ) {
89
89
tag = tag . toUpperCase ( ) ;
90
90
91
- while ( el = el . previousSibling ) {
92
- if ( el . tagName && el . tagName . toUpperCase ( ) === tag ) {
93
- return el ;
94
- }
95
- }
91
+ while ( start ) {
92
+ if ( start . nodeName === tag ) {
93
+ return start ;
94
+ }
95
+ if ( start . querySelector ) {
96
+ var pre = start . querySelector ( tag ) ;
97
+ if ( pre ) {
98
+ return pre ;
99
+ }
100
+ }
101
+
102
+ // needs to be previousSibling for zombie
103
+ start = start . previousSibling ;
104
+ }
96
105
}
97
106
98
107
module . exports = function ( ) {
Original file line number Diff line number Diff line change 1
1
/**
2
2
* @parent bit-docs-html-highlight-line/tags
3
3
* @module {bit-docs-process-tags/types/tag} bit-docs-html-highlight-line/tags/highlight @highlight
4
- *
4
+ *
5
5
* Highlight the specified code lines.
6
- *
6
+ *
7
7
* @signature `@highlight LINES[,ONLY]`
8
- *
8
+ *
9
9
* @param {String } LINES The lines to highlight like `2-4`.
10
- *
10
+ *
11
11
* @param {String } [,ONLY] Collapse non-highlighted lines greater than three
12
12
* lines away (useful for long code snippets).
13
- *
13
+ *
14
14
* @codestart javascript
15
15
* /**
16
16
* * ```js
24
24
* * "season": "Summer",
25
25
* * "awesome": "yes"
26
26
* * }
27
- * * ```
27
+ * * ```
28
28
* *
29
29
* * @highlight 2-4,only
30
30
* *|
31
31
* @codeend
32
- *
32
+ *
33
33
* Injects a `<span line-highlight="2-4,only"></span>` element to the page that
34
34
* will be picked up and used by the static front-end script
35
35
* [bit-docs-html-highlight-line/highlight-line.js].
36
36
*/
37
37
exports . highlight = {
38
38
add : function ( line , curData ) {
39
+ var space = line . substr ( 0 , line . indexOf ( "@highlight" ) ) ;
39
40
var lines = line . replace ( "@highlight" , "" ) . trim ( ) ;
40
- var html = "<span line-highlight='" + lines + "'></span>" ;
41
+ var html = space + "<span line-highlight='" + lines + "'></span>" ;
41
42
var validCurData = ( curData && curData . length !== 2 ) ;
42
43
var useCurData = validCurData && ( typeof curData . description === "string" ) && ! curData . body ;
43
44
44
45
if ( useCurData ) {
45
- curData . description += html ;
46
+ curData . description += "\n" + html + "\n" ;
46
47
} else {
47
- this . body += html ;
48
+ this . body += html + "\n" ;
48
49
}
49
50
}
50
51
} ;
You can’t perform that action at this time.
0 commit comments