aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/helpers/markdown.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/helpers/markdown.js')
-rw-r--r--server/sonar-web/src/main/js/helpers/markdown.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/server/sonar-web/src/main/js/helpers/markdown.js b/server/sonar-web/src/main/js/helpers/markdown.js
index b92c05e04dd..1b7f29c25bf 100644
--- a/server/sonar-web/src/main/js/helpers/markdown.js
+++ b/server/sonar-web/src/main/js/helpers/markdown.js
@@ -71,12 +71,16 @@ function parseFrontMatter(lines) {
* @returns {string}
*/
function filterContent(content) {
+ const regexBase = '<!-- \\/?(sonarqube|sonarcloud|static) -->';
const { isSonarCloud, getInstance } = require('./system');
const contentWithInstance = content.replace(/{instance}/gi, getInstance());
const contentWithoutStatic = cutConditionalContent(contentWithInstance, 'static');
- return isSonarCloud()
+ const filteredContent = isSonarCloud()
? cutConditionalContent(contentWithoutStatic, 'sonarqube')
: cutConditionalContent(contentWithoutStatic, 'sonarcloud');
+ return filteredContent
+ .replace(new RegExp(`^${regexBase}(\n|\r|\r\n|$)`, 'gm'), '') // First, remove single-line ones, including ending carriage-returns.
+ .replace(new RegExp(`${regexBase}`, 'g'), ''); // Now remove all remaining ones.
}
/**