forked from external/vscode-xml
		
	Merge pull request #315 from DotJoshJohnson/bug/271-xml-entity-escaping
Add &, ", and ' Entities
This commit is contained in:
		
						commit
						3e20dd05c4
					
				
					 2 changed files with 14 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -19,7 +19,13 @@ export function textToXml(textEditor: TextEditor): void {
 | 
			
		|||
                );
 | 
			
		||||
            }
 | 
			
		||||
            const txt = textEditor.document.getText(new Range(selection.start, selection.end));
 | 
			
		||||
            const transformed = txt.replace(/</g, "<").replace(/>/g, ">");
 | 
			
		||||
            const transformed = txt
 | 
			
		||||
                .replace(/</g, "<")
 | 
			
		||||
                .replace(/>/g, ">")
 | 
			
		||||
                .replace(/&/g, "&")
 | 
			
		||||
                .replace(/"/g, '"')
 | 
			
		||||
                .replace(/'/g, "'");
 | 
			
		||||
 | 
			
		||||
            textEdit.replace(selection, transformed);
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,13 @@ export function xmlToText(textEditor: TextEditor): void {
 | 
			
		|||
                );
 | 
			
		||||
            }
 | 
			
		||||
            const txt = textEditor.document.getText(new Range(selection.start, selection.end));
 | 
			
		||||
            const transformed = txt.replace(/</g, "<").replace(/>/g, ">");
 | 
			
		||||
            const transformed = txt
 | 
			
		||||
                .replace(/</g, "<")
 | 
			
		||||
                .replace(/>/g, ">")
 | 
			
		||||
                .replace(/&/g, "&")
 | 
			
		||||
                .replace(/"/g, """)
 | 
			
		||||
                .replace(/'/g, "'");
 | 
			
		||||
 | 
			
		||||
            textEdit.replace(selection, transformed);
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue