Skip to content

Commit

Permalink
Force monospace for raw text HTML pages
Browse files Browse the repository at this point in the history
  • Loading branch information
tombh committed Jun 23, 2018
1 parent 2350000 commit d4cb55f
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions webext/src/dom/serialise_mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,30 @@ export default (MixinBase) => class extends MixinBase {
}
raw_text += "\n";
}
const head = `<html><title>${document.title}</title><body><pre>`
const head = this._getHTMLHead();
const date_time = this._getCurrentDataTime();
info += "\n\n" + `Built by <a href="https://www.brow.sh">Browsh</a> on ${date_time}`
info += "\n\n" + `Built by <a href="https://www.brow.sh">Browsh</a> on ${date_time}`;
if (this.dimensions.is_page_truncated) {
info += '\nBrowsh parser: the page was too large, some text may have been truncated.';
}
const foot = `${info}</pre></body></html>`
return head + raw_text + foot;
}

_getHTMLHead() {
return `<html>
<head>
<title>${document.title}</title>
<style>
html * {
font-family: monospace;
}
</style>
</head>
<body>
<pre>`;
}

_getCurrentDataTime() {
let current_date = new Date();
const offset = -(new Date().getTimezoneOffset() / 60);
Expand Down

0 comments on commit d4cb55f

Please sign in to comment.