@@ -137,50 +137,6 @@ function pullComments(fileId, callback) {
137
137
xhr . send ( '' ) ;
138
138
}
139
139
140
- function updateOpenedSpans ( currentSpans , line ) {
141
- /* Because we have each line wrapped in it's own span, we must close
142
- * all the opened spans in this specific line and re-open them in the next
143
- * line. This function help us to manage the state of open span tags.
144
- */
145
- let isCatching = false ;
146
- let phrase = '' ;
147
- for ( let i = 0 ; i < line . length ; i += 1 ) {
148
- const c = line [ i ] ;
149
- if ( c === '>' ) {
150
- isCatching = false ;
151
- phrase = `<${ phrase } >` ;
152
- if ( phrase === '</span>' ) {
153
- currentSpans . pop ( ) ;
154
- } else if ( phrase . startsWith ( '<span' ) ) {
155
- currentSpans . push ( phrase ) ;
156
- }
157
- phrase = '' ;
158
- } else if ( c === '<' ) {
159
- isCatching = true ;
160
- } else if ( isCatching ) {
161
- phrase += c ;
162
- }
163
- }
164
- }
165
-
166
- function addLineSpansToPre ( items ) {
167
- const openSpans = [ ] ;
168
- Array . from ( items ) . forEach ( ( item ) => {
169
- const code = item . innerHTML . trim ( ) . split ( '\n' ) ;
170
- const digits = code . length . toString ( ) . length ;
171
- item . innerHTML = code . map (
172
- ( line , i ) => {
173
- let lineContent = openSpans . join ( '' ) + line ;
174
- updateOpenedSpans ( openSpans , line ) ;
175
- lineContent += '</span>' . repeat ( openSpans . length ) ;
176
- const wrappedLine = `<div class="line-container" data-line="${ i + 1 } "><span class="line-number" style="width: ${ digits } em">${ i + 1 } </span> <span data-line="${ i + 1 } " class="line">${ lineContent } </span></div>` ;
177
- return wrappedLine ;
178
- } ,
179
- ) . join ( '\n' ) ;
180
- } ) ;
181
- window . dispatchEvent ( new Event ( 'lines-numbered' ) ) ;
182
- }
183
-
184
140
class LineComment extends HTMLElement {
185
141
static observedAttributes = [
186
142
'data-line' , 'avatar' , 'name' , 'date' , 'editor' , 'data-comment-id' ,
@@ -295,6 +251,5 @@ window.addEventListener('load', () => {
295
251
sessionStorage . setItem ( 'allowedComment' , codeElementData . allowedComment ) ;
296
252
customElements . define ( 'comment-line' , LineComment ) ;
297
253
configureMarkdownParser ( ) ;
298
- addLineSpansToPre ( document . getElementsByTagName ( 'code' ) ) ;
299
254
pullComments ( window . fileId , treatComments ) ;
300
255
} ) ;
0 commit comments