Pail/csharp-quotes.js

18 lines
581 B
JavaScript

const fixCSharpStrings = () => {
const hasCSharpFileName = getFileName()?.endsWith('.cs')
if (!hasCSharpFileName) {
return
}
getClassNameElementsArray('hl-string')
.filter(e => e.innerText.includes('@"') || e.innerText.includes('@$""'))
.forEach(e => {
const s = e.innerHTML
const firstQuote = s.indexOf('"') + 1
const spanned = s.substring(firstQuote, s.length - 1).replaceAll('""', '<span class="hl-def">""</span>')
e.innerHTML = s.substring(0, firstQuote) + spanned + '"'
})
}
addFix(fixCSharpStrings)