diff --git a/services/web/frontend/stylesheets/app/wiki.less b/services/web/frontend/stylesheets/app/wiki.less index c984abe74b..039bb1728e 100644 --- a/services/web/frontend/stylesheets/app/wiki.less +++ b/services/web/frontend/stylesheets/app/wiki.less @@ -14,11 +14,6 @@ } } - img { - height: auto; - max-width: 100%; - } - .page-header { a { font-size: 0.8em; @@ -235,4 +230,45 @@ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35); } } + + /* Keep the below rules in sync with the wiki pages */ + img { + height: auto; + max-width: 100%; + } + + img.add-vertical-space { + padding-bottom: 20px; + padding-top: 20px; + } + + th.no-wrap { + white-space: nowrap; + text-align: left; + } + + /* LATEX and TEX artwork */ + span.TEX { + letter-spacing: -0.125em; + padding-right: 0.5ex; + } + span.TEX span.E { + position: relative; + top: 0.5ex; + padding-right: 0.1ex; + } + a span.TEX span.E { + text-decoration: none; + } + span.LATEX span.A { + position: relative; + top: -0.5ex; + left: -0.4em; + font-size: 75%; + } + span.LATEX span.TEX { + position: relative; + left: -0.4em; + margin-right: -0.5ex; + } } diff --git a/services/web/scripts/learn/checkSanitize/README.md b/services/web/scripts/learn/checkSanitize/README.md new file mode 100644 index 0000000000..b425c5c576 --- /dev/null +++ b/services/web/scripts/learn/checkSanitize/README.md @@ -0,0 +1,32 @@ +# Usage + +``` +node scripts/learn/checkSanitize https://LEARN_WIKI +``` + +## Bulk export + +There is a bulk export for media wiki pages, but it produces different + html escaping compared to the regular parse API we use in web. + +The bulk export does not escape all the placeholder HTML-like elements, + like ``. + +## Example output + +Here is how a missing tag gets flagged: + +``` +--- +page : MediaWiki markup for the Overleaf support team +title : MediaWiki markup for the Overleaf support team +match : false +toText : false +text : "Overleaf\n \n Kb/TITLE_SLUGhttps://www.overleaf.com/learn/how-to/TITLE_SLUG\n \n \n Kb/TITLE_SLUG<nowiki>https://www.overleaf.com/learn/how-to/</nowiki>TITLE_SLUG\n " +textToText : " \n \n \n \n MediaWiki page\n Maps to on Overleaf\n \n Kb/TITLE_SLUGhttps://www.overleaf.com/learn/how-to/TITLE_SLUG\n " +sanitizedToText: " \n \n \n \n MediaWiki page\n Maps to on Overleaf\n \n Kb/TITLE_SLUGhttps://www.overleaf.com/learn/how-to/TITLE" +``` + +Note the hidden/escaped `` element. +In addition to the side-by-side comparison of HTML you will see a plain-text diff. diff --git a/services/web/scripts/learn/checkSanitize/checkSanitizeOptions.js b/services/web/scripts/learn/checkSanitize/checkSanitizeOptions.js new file mode 100644 index 0000000000..da7c221112 --- /dev/null +++ b/services/web/scripts/learn/checkSanitize/checkSanitizeOptions.js @@ -0,0 +1,120 @@ +const crypto = require('crypto') +const fs = require('fs') +const Path = require('path') + +const cheerio = require('cheerio') +const prettier = require('prettier') +const sanitizeHtml = require('sanitize-html') + +const { + sanitizeOptions, +} = require('../../../modules/learn/app/src/sanitizeOptions') + +const EXTRACT_STYLE = process.env.EXTRACT_STYLES === 'true' +const OMIT_STYLE = process.env.OMIT_STYLE !== 'false' +const DUMP_CSS_IN = Path.join( + Path.dirname(Path.dirname(Path.dirname(__dirname))), + 'data', + 'dumpFolder' +) + +function hash(blob) { + return crypto.createHash('sha1').update(blob).digest('hex') +} + +function normalize(blob, title) { + // styles are dropped in web and kept in wiki pages for previewing there. + blob = blob.replace(/