Skip to content
Permalink
Browse files

Version 3.2

  • Loading branch information...
bengarrett committed Feb 26, 2019
1 parent 7e58604 commit 18fd155a2fa39b4c8f672e4960eb43d2d91dc38b
@@ -2,7 +2,7 @@
############

# Firefox packages
web-ext-artifacts
#web-ext-artifacts
*.xpi

# Visual Studio Code
@@ -157,6 +157,9 @@ main > section .font.block {
main > section .config-title {
flex-basis: 24em;
}
main > section .config-title.asterisk {
color: var(--error-text);
}
main > section .config-title code a,
main > section .config-content code {
font-size: 1.1em;
@@ -1,5 +1,20 @@
# RetroTxt Changes

## 3.2

### February 2019

- Added IBM AIX terminal bright and bold colour support.
- Improved _Allow access to file URLs is disabled_ notification to be more obvious.
- Added npm run scripts to the package.json.
- - `npm run build`
- - `npm run firefox`
- - `npm run lint`
- - `npm run version`
- Fixed `Downloads.listen()` causing an endless download loop (issue #56).
- Fixed `hideEntities()` not catching `<>` character combinations that broke ANSI rendering (issue #58).
- Fixed the Options _Apply RetroTxt to any local text files file:///_ link pointing to the `C:` drive on Linux and macOS.

## 3.1

### December 2018
@@ -24,7 +24,7 @@ Or run the following command in a terminal.

`npm install`

`web-ext --version`
`npm run version`

## Use on Chrome

@@ -51,7 +51,7 @@ The web-ext tool is the preferred method and [has a dedicated web page](https://
1. `cd RetroTxt` into the cloned directory
1. `copy manifest_firefox.json manifest.json`
1. `npm install` to install web-ext
1. `web-ext run` to load RetroTxt in Firefox
1. `npm run firefox` to load RetroTxt in Firefox
1. [Read more about web-ext](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Getting_started_with_web-ext)

![web-ext run example](assets/web-ext_example.png)
@@ -165,6 +165,8 @@ The following chart lists the limited ECMA-48 sequences that RetroTxt supports.
| overlined | SGR | 53 | Yes | |
| not framed nor encircled | SGR | 54 | Yes | |
| not overlined | SGR | 55 | Yes | |
| bold foreground colours | SGR | 90…97 | Yes | Non-standard IBM AIX terminal |
| bright background colours | SGR | 100…107 | Yes | Non-standard IBM AIX terminal (* requires iCE colours to be enabled) |

## Miscellaneous support

@@ -433,13 +433,19 @@
<div class="config block">
<div class="config-title">
Apply RetroTxt to any local text files
<code><a href="file:///c:/" id="run-file-urls-link" target="_blank">file:///</a></code>
<code><a href="file:///" id="run-file-urls-link" target="_blank">file:///</a></code>
</div>
<div class="config-content" id="run-file-urls-div">
<label><i class="material-icons">folder_open</i>
<input type="checkbox" id="run-file-urls"></label>
</div>
</div>
<!-- chrome.isAllowedFileSchemeAccess() = false -->
<div class="config block" id="allow-access-file-urls-div" style="display:none">
<div class="config-title asterisk">
Allow access to file URLs is disabled
</div>
</div>
<!-- update notices -->
<div class="config block">
<div class="config-title">
@@ -469,12 +475,6 @@
</div>
</div>
</div>
<!-- chrome.isAllowedFileSchemeAccess() = false -->
<div class="config block" id="allow-access-file-urls-div" style="display:none">
<div class="config-title">
Allow access to file URLs is disabled
</div>
</div>
</section>
<!-- About tab -->
<section class="tabcontent" id="tab4">
@@ -63,8 +63,8 @@
"*://*.retrotxt.com/*"
],
"short_name": "RetroTxt",
"version": "3.1.0",
"version_name": "3.1",
"version": "3.2.0",
"version_name": "3.2",
"web_accessible_resources": [
"css/*.css",
"fonts/woff2/*.woff2",
@@ -63,8 +63,8 @@
"*://*.retrotxt.com/*"
],
"short_name": "RetroTxt",
"version": "3.1.0",
"version_name": "3.1",
"version": "3.2.0",
"version_name": "3.2",
"web_accessible_resources": [
"css/*.css",
"fonts/woff2/*.woff2",
@@ -72,7 +72,7 @@
"*://*.retrotxt.com/*"
],
"short_name": "RetroTxt",
"version": "3.1.0",
"version": "3.2.0",
"web_accessible_resources": [
"css/*.css",
"fonts/woff2/*.woff2",
@@ -1,6 +1,6 @@
{
"name": "retrotxt",
"version": "3.0.0",
"version": "3.2.0",
"description": "Turn many pieces of ANSI text art and ASCII, NFO, Shift-JIS, plain text into HTML5.",
"keywords": [
"ascii",
@@ -42,5 +42,11 @@
"ajv": "latest",
"eslint": "latest",
"prettier-eslint": "^8.8.2"
},
"scripts": {
"build": "web-ext build",
"lint": "web-ext lint",
"firefox": "web-ext run",
"version": "web-ext --version"
}
}
@@ -293,7 +293,6 @@ class Tab {
* Intended to be run in conjunction with this.checkURL().
*/
compatibleURL() {
//if (RetroTxt.developer)
console.log(`Tabs.compatibleURL() has been requested.`)
const config = new Configuration()
const downloads = new Downloads()
@@ -633,7 +632,7 @@ class Security {
*/
test() {
if (RetroTxt.developer)
console.log(`⚿ Security test request for '${this.type}'.`)
console.trace(`⚿ Security test request for '${this.type}'.`)
if (this.type === `http`) {
this.origins = this.httpToOrigins()
}
@@ -892,37 +891,28 @@ class Downloads {
})
chrome.downloads.onChanged.addListener(delta => {
downloads.delta = delta
// security check blocks downloads.update()
// otherwise any Options changes will require a web-extension reload
chrome.permissions.contains(test, result => {
if (result !== true) {
if (RetroTxt.developer) security.fail()
return // abort
} else {
// a fix for the Chrome endless loop issue where it incorrectly identifies a text file as a binary
// (application/octet-stream) and forces it to download instead of render in a tab
if (!(`item` in downloads)) return
if (!(`mime` in downloads.item)) return
if (downloads.item.mime === `application/octet-stream`) {
if (
`state` in downloads.delta &&
downloads.delta.state.current === `complete`
) {
const config = new Configuration()
const textFile = config.validateFileExtension(
downloads.item.finalUrl
)
if (textFile === true)
console.warn(
`Downloaded filename looks to be a text file but the host server says it's a binary file: `,
downloads.item.finalUrl
)
}
return
}
downloads.update()
// a fix for the Chrome endless loop issue where it incorrectly identifies a text file as a binary
// (application/octet-stream) and forces it to download instead of render in a tab
if (!(`item` in downloads)) return
if (!(`mime` in downloads.item)) return
if (downloads.item.mime === `application/octet-stream`) {
if (
`state` in downloads.delta &&
downloads.delta.state.current === `complete`
) {
const config = new Configuration()
const textFile = config.validateFileExtension(
downloads.item.finalUrl
)
if (textFile === true)
console.warn(
`Downloaded filename looks to be a text file but the host server says it's a binary file: `,
downloads.item.finalUrl
)
}
})
return
}
downloads.update()
})
break
case false:
@@ -936,6 +926,7 @@ class Downloads {
* https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/downloads/onCreated
*/
initialize() {
console.log(`Initialize`)
const downloads = new Downloads()
switch (this.monitor) {
case true:
@@ -1013,6 +1013,7 @@ function findDigit(
function findForeground(v) {
if (
(v >= 30 && v <= 39) ||
(v >= 90 && v <= 97) ||
(v >= 380 && v <= 389) ||
(v >= 3810 && v <= 3899) ||
(v >= 38100 && v <= 38255)
@@ -1047,14 +1048,16 @@ function handleColumn(count = 1) {
// @s String of text
function hideEntities(s = ``) {
if (typeof s !== `string`) CheckArguments(`s`, `string`, s)
const rgt = new RegExp(`&gt;`, `gi`)
const rlt = new RegExp(`&lt;`, `gi`)
const ramp = new RegExp(`&amp;`, `gi`)
const regGT = new RegExp(`&gt;`, `gi`) // match &gt;
const regLT = new RegExp(`&lt;|<`, `gi`) // match &lt; or <
const regAmp = new RegExp(`&amp;`, `gi`)
const regRA = new RegExp(`>[?!\x1B\[]`, `gi`) // match > except ␛[>
// replace matches
s = s.replace(rgt, ``)
s = s.replace(rlt, ``)
s = s.replace(ramp, ``)
return s
const part1 = s.replace(regGT, ``)
const part2 = part1.replace(regRA, ``)
const part3 = part2.replace(regLT, ``)
const parts = part3.replace(regAmp, ``)
return parts
}

// Decode Unicode decimal values into readable strings
@@ -1317,7 +1320,7 @@ function RenditionParse(vals = ``, verbose = false) {
// forward loop as multiple codes together have compound effects
for (const v of values) {
if (v === null) continue
const val = parseInt(v, 10)
let val = parseInt(v, 10)
if (isNaN(val) === true) continue // error
if (val === 0 && vals !== `ICE+0`) {
if (verbose) console.info(`SGRInit()`)
@@ -1329,6 +1332,16 @@ function RenditionParse(vals = ``, verbose = false) {
case 1:
break // if color depth = 1 bit, then ignore SGR color values
default:
// handle aixterm bright colours
// these are standard ANSI SGR colours but with the bold flag
if (val >= 90 && val <= 97) {
sgrObject.bold = true
val = val - 60 // change val to a standard SGR value
} else if (val >= 100 && val <= 107) {
sgrObject.blinkSlow = true
val = val - 60
}
// handle RBG colours
if ([38, 48].includes(val) && values[2] === `2`) {
const r = parseInt(values[3], 10)
const g = parseInt(values[4], 10)
@@ -1351,11 +1364,15 @@ function RenditionParse(vals = ``, verbose = false) {
}
continue
}
} else if (findForeground(val) === true) {
}
// handle standard foreground
else if (findForeground(val) === true) {
sgrObject.colorF = val
sgrObject.rgbF = ``
if (sgrObject.rgbB.length > 0) this.styles = sgrObject.rgbB
} else if (findBackground(val) === true) {
}
// handle standard background
else if (findBackground(val) === true) {
sgrObject.colorB = val
sgrObject.rgbB = ``
if (sgrObject.rgbF.length > 0) this.styles = sgrObject.rgbF
@@ -0,0 +1,59 @@
8 Foreground
============
Black
Red
Green
Brown
Blue
Magenta
Cyan
White

8 Bold Foreground
=================
Black
Red
Green
Brown
Blue
Magenta
Cyan
White

8 AIX Bright Foreground
=======================
Black
Red
Green
Brown
Blue
Magenta
Cyan
White

8 Background
============
Black
Red
Green
Brown
Blue
Magenta
Cyan
White

8 AIX Bright Background
=======================
Black
Red
Green
Brown
Blue
Magenta
Cyan
White

Combinations
============

 Black  Black  Red  Red  White  White 
@@ -0,0 +1,7 @@
test Some text.
test <meta data>
test <open tag />
test <closed></closed>
test <closed tag></closed tag>
test & More text.
test & <ansi></ansi>
@@ -0,0 +1,6 @@
test Some text.
test <meta data>
test <open tag />
test <closed></closed>
test <closed tag></closed tag>
test & More text.
@@ -24,7 +24,7 @@ module.exports = {
run: {
browserConsole: true,
// Browser to run, either `firefox`, `firefoxdeveloperedition`
firefox: `firefoxdeveloperedition`,
firefox: `firefox`,
// start URL
startUrl: [`test/example_files/ecma-48.txt`]
}

0 comments on commit 18fd155

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.