Skip to content

Commit

Permalink
fix: 🐛 avoid unexpected replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
shufo committed Jul 18, 2020
1 parent bde1e75 commit f4f5db1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,16 @@ export function formatAsPhp(content) {
}

export function preserveOriginalPhpTagInHtml(content) {
let prettified = _.replace(content, /<\?php/g, '/* <?php */');
prettified = _.replace(prettified, /\?>/g, '/* ?> */');
let prettified = _.replace(content, /<\?php/g, '/* <?phptag_start */');
prettified = _.replace(prettified, /\?>/g, '/* end_phptag?> */');

return prettified;
}

export function revertOriginalPhpTagInHtml(content) {
let prettified = _.replace(content, /\/\* <\?php \*\//g, '<?php');
prettified = _.replace(prettified, /\/\* \?> \*\/\s;\n/g, '?>;');
prettified = _.replace(prettified, /\/\* \?> \*\//g, '?>');
let prettified = _.replace(content, /\/\* <\?phptag_start \*\//g, '<?php');
prettified = _.replace(prettified, /\/\* end_phptag\?> \*\/\s;\n/g, '?>;');
prettified = _.replace(prettified, /\/\* end_phptag\?> \*\//g, '?>');

return prettified;
}
Expand Down

0 comments on commit f4f5db1

Please sign in to comment.