Commit 4ce317f5 authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Use double-space for pretty-printed HTML indentation

parent 19aed53e
...@@ -469,8 +469,8 @@ describe('ExportAnnotations', () => { ...@@ -469,8 +469,8 @@ describe('ExportAnnotations', () => {
context('when copying annotations export to clipboard', () => { context('when copying annotations export to clipboard', () => {
[true, false].forEach(exportFormatsEnabled => { [true, false].forEach(exportFormatsEnabled => {
it('displays copy button if `export_formats` FF is enabled', () => { it('displays copy button if `export_formats` FF is enabled', () => {
fakeStore.isFeatureEnabled.callsFake( fakeStore.isFeatureEnabled.callsFake(ff =>
ff => exportFormatsEnabled || ff !== 'export_formats', ff === 'export_formats' ? exportFormatsEnabled : true,
); );
const wrapper = createComponent(); const wrapper = createComponent();
......
...@@ -275,7 +275,10 @@ export class AnnotationsExporter { ...@@ -275,7 +275,10 @@ export class AnnotationsExporter {
</html>, </html>,
{}, {},
{ pretty: true }, { pretty: true },
); // `renderToString` indents lines with tabs when using `pretty: true`.
// Replacing them with double spaces we avoid side effects when pasting
// the result in a web app.
).replace(/\t/g, ' ');
} }
private _exportCommon( private _exportCommon(
......
...@@ -292,13 +292,9 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex ...@@ -292,13 +292,9 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
now, now,
}); });
// The result uses tabs to indent lines.
// We can get rid of that for simplicity and just compare the markup
const removeAllIndentation = str => str.replace(/^[ \t]+/gm, '');
assert.equal( assert.equal(
removeAllIndentation(result), result,
removeAllIndentation(`<html lang="en"> `<html lang="en">
<head> <head>
<title> <title>
Annotations on &quot;A special document&quot; Annotations on &quot;A special document&quot;
...@@ -444,7 +440,7 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex ...@@ -444,7 +440,7 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
</article> </article>
</section> </section>
</body> </body>
</html>`), </html>`,
); );
}); });
}); });
......
...@@ -45,8 +45,7 @@ export async function copyPlainText(text: string, navigator_ = navigator) { ...@@ -45,8 +45,7 @@ export async function copyPlainText(text: string, navigator_ = navigator) {
} }
/** /**
* Copy the string `text` to the clipboard, rendering HTML if any, instead of * Copy the string `text` to the clipboard with an HTML media type.
* raw markup.
* *
* If the browser does not support this, it will fall back to copy the string * If the browser does not support this, it will fall back to copy the string
* as plain text. * as plain text.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment