Skip to content

Commit

Permalink
#34 multi-line property values save fix with \ marker gen for \n
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomFractals committed Jun 17, 2019
1 parent e25c524 commit f4c571f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 5 additions & 5 deletions data/yaml/demo.properties
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ null.null=null key
null.sparse.1=2nd entry
null.sparse.3=4th entry
string=abcd
function=function anonymous(
) {

return 'Wow! JS-YAML Rocks!';

function=function anonymous(\
) {\
\
return 'Wow! JS-YAML Rocks!';\
\
}
8 changes: 7 additions & 1 deletion src/data.preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,15 @@ export class DataPreview {
if (fileData.length > 0 &&
fileData[0].hasOwnProperty('key') && fileData[0].hasOwnProperty('value')) { // data in properties format
let propertiesString: string = '';
const newLineRegExp: RegExp = new RegExp('\n', 'g');
fileData = fileData.forEach(property => {
// convert it to properties string
propertiesString += `${property['key']}=${property['value']}\n`;
let propertyLine:string =`${property['key']}=${property['value']}`;
if (propertyLine.indexOf(`\n`) > 0) {
// replace all new lines for multi-line property values with \ next line marker and \n
propertyLine = propertyLine.replace(newLineRegExp, '\\\n');
}
propertiesString += `${propertyLine}\n`;
});
fileData = propertiesString;
} else {
Expand Down

0 comments on commit f4c571f

Please sign in to comment.