2012-09-01 07:48:21 +09:00
|
|
|
/* Copyright 2012 Mozilla Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2020-01-02 20:00:16 +09:00
|
|
|
import { warn } from "../shared/util.js";
|
2017-04-02 23:14:30 +09:00
|
|
|
|
|
|
|
// Character types for symbols from 0000 to 00FF.
|
|
|
|
// Source: ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt
|
2019-12-25 23:54:34 +09:00
|
|
|
// prettier-ignore
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
const baseTypes = [
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
"BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "S", "B", "S",
|
|
|
|
"WS", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN",
|
|
|
|
"BN", "BN", "BN", "BN", "B", "B", "B", "S", "WS", "ON", "ON", "ET",
|
|
|
|
"ET", "ET", "ON", "ON", "ON", "ON", "ON", "ES", "CS", "ES", "CS", "CS",
|
|
|
|
"EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "CS", "ON",
|
|
|
|
"ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L",
|
|
|
|
"L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L",
|
|
|
|
"L", "L", "L", "L", "ON", "ON", "ON", "ON", "ON", "ON", "L", "L", "L",
|
|
|
|
"L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L",
|
|
|
|
"L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "ON", "ON", "ON",
|
|
|
|
"BN", "BN", "BN", "BN", "BN", "BN", "B", "BN", "BN", "BN", "BN", "BN",
|
|
|
|
"BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN",
|
|
|
|
"BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "CS", "ON", "ET",
|
|
|
|
"ET", "ET", "ET", "ON", "ON", "ON", "ON", "L", "ON", "ON", "BN", "ON",
|
|
|
|
"ON", "ET", "ET", "EN", "EN", "ON", "L", "ON", "ON", "ON", "EN", "L",
|
|
|
|
"ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L",
|
|
|
|
"L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L",
|
|
|
|
"L", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L",
|
|
|
|
"L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L",
|
|
|
|
"L", "L", "L", "L", "L", "ON", "L", "L", "L", "L", "L", "L", "L", "L"
|
2017-04-02 23:14:30 +09:00
|
|
|
];
|
|
|
|
|
|
|
|
// Character types for symbols from 0600 to 06FF.
|
|
|
|
// Source: ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt
|
|
|
|
// Note that 061D does not exist in the Unicode standard (see
|
|
|
|
// http://unicode.org/charts/PDF/U0600.pdf), so we replace it with an
|
|
|
|
// empty string and issue a warning if we encounter this character. The
|
|
|
|
// empty string is required to properly index the items after it.
|
2019-12-25 23:54:34 +09:00
|
|
|
// prettier-ignore
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
const arabicTypes = [
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
"AN", "AN", "AN", "AN", "AN", "AN", "ON", "ON", "AL", "ET", "ET", "AL",
|
|
|
|
"CS", "AL", "ON", "ON", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM",
|
|
|
|
"NSM", "NSM", "NSM", "NSM", "AL", "AL", "", "AL", "AL", "AL", "AL", "AL",
|
|
|
|
"AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
|
|
|
|
"AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
|
|
|
|
"AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
|
|
|
|
"AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM",
|
|
|
|
"NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM",
|
|
|
|
"NSM", "NSM", "NSM", "NSM", "AN", "AN", "AN", "AN", "AN", "AN", "AN",
|
|
|
|
"AN", "AN", "AN", "ET", "AN", "AN", "AL", "AL", "AL", "NSM", "AL", "AL",
|
|
|
|
"AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
|
|
|
|
"AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
|
|
|
|
"AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
|
|
|
|
"AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
|
|
|
|
"AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
|
|
|
|
"AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
|
|
|
|
"AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
|
|
|
|
"AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
|
|
|
|
"AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN",
|
|
|
|
"ON", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "NSM", "NSM",
|
|
|
|
"ON", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "EN", "EN", "EN", "EN",
|
|
|
|
"EN", "EN", "EN", "EN", "EN", "EN", "AL", "AL", "AL", "AL", "AL", "AL"
|
2017-04-02 23:14:30 +09:00
|
|
|
];
|
|
|
|
|
|
|
|
function isOdd(i) {
|
|
|
|
return (i & 1) !== 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function isEven(i) {
|
|
|
|
return (i & 1) === 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function findUnequal(arr, start, value) {
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
let j, jj;
|
|
|
|
for (j = start, jj = arr.length; j < jj; ++j) {
|
2017-04-02 23:14:30 +09:00
|
|
|
if (arr[j] !== value) {
|
|
|
|
return j;
|
|
|
|
}
|
2015-11-22 01:32:47 +09:00
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
return j;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setValues(arr, start, end, value) {
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
for (let j = start; j < end; ++j) {
|
2017-04-02 23:14:30 +09:00
|
|
|
arr[j] = value;
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
}
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
function reverseValues(arr, start, end) {
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
for (let i = start, j = end - 1; i < j; ++i, --j) {
|
|
|
|
const temp = arr[i];
|
2017-04-02 23:14:30 +09:00
|
|
|
arr[i] = arr[j];
|
|
|
|
arr[j] = temp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-13 03:47:13 +09:00
|
|
|
function createBidiText(str, isLTR, vertical = false) {
|
|
|
|
let dir = "ltr";
|
|
|
|
if (vertical) {
|
|
|
|
dir = "ttb";
|
|
|
|
} else if (!isLTR) {
|
|
|
|
dir = "rtl";
|
|
|
|
}
|
|
|
|
return { str, dir };
|
2017-04-02 23:14:30 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
// These are used in bidi(), which is called frequently. We re-use them on
|
|
|
|
// each call to avoid unnecessary allocations.
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
const chars = [];
|
|
|
|
const types = [];
|
2017-04-02 23:14:30 +09:00
|
|
|
|
2021-09-25 00:30:56 +09:00
|
|
|
function bidi(str, startLevel = -1, vertical = false) {
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
let isLTR = true;
|
|
|
|
const strLength = str.length;
|
2017-04-02 23:14:30 +09:00
|
|
|
if (strLength === 0 || vertical) {
|
|
|
|
return createBidiText(str, isLTR, vertical);
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
// Get types and fill arrays
|
|
|
|
chars.length = strLength;
|
|
|
|
types.length = strLength;
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
let numBidi = 0;
|
2017-04-02 23:14:30 +09:00
|
|
|
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
let i, ii;
|
2017-04-02 23:14:30 +09:00
|
|
|
for (i = 0; i < strLength; ++i) {
|
|
|
|
chars[i] = str.charAt(i);
|
|
|
|
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
const charCode = str.charCodeAt(i);
|
|
|
|
let charType = "L";
|
2017-04-02 23:14:30 +09:00
|
|
|
if (charCode <= 0x00ff) {
|
|
|
|
charType = baseTypes[charCode];
|
|
|
|
} else if (0x0590 <= charCode && charCode <= 0x05f4) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
charType = "R";
|
2017-04-02 23:14:30 +09:00
|
|
|
} else if (0x0600 <= charCode && charCode <= 0x06ff) {
|
|
|
|
charType = arabicTypes[charCode & 0xff];
|
|
|
|
if (!charType) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
warn("Bidi: invalid Unicode character " + charCode.toString(16));
|
2014-03-09 05:49:53 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
} else if (0x0700 <= charCode && charCode <= 0x08ac) {
|
|
|
|
charType = "AL";
|
2017-04-02 23:14:30 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (charType === "R" || charType === "AL" || charType === "AN") {
|
2017-04-02 23:14:30 +09:00
|
|
|
numBidi++;
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
types[i] = charType;
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
// Detect the bidi method
|
|
|
|
// - If there are no rtl characters then no bidi needed
|
2021-11-01 01:46:42 +09:00
|
|
|
// - If less than 30% chars are rtl then string is primarily ltr,
|
|
|
|
// unless the string is very short.
|
2017-04-02 23:14:30 +09:00
|
|
|
// - If more than 30% chars are rtl then string is primarily rtl
|
|
|
|
if (numBidi === 0) {
|
|
|
|
isLTR = true;
|
|
|
|
return createBidiText(str, isLTR);
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
if (startLevel === -1) {
|
2021-11-01 01:46:42 +09:00
|
|
|
if (numBidi / strLength < 0.3 && strLength > 4) {
|
2017-04-02 23:14:30 +09:00
|
|
|
isLTR = true;
|
|
|
|
startLevel = 0;
|
|
|
|
} else {
|
|
|
|
isLTR = false;
|
|
|
|
startLevel = 1;
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
const levels = [];
|
2017-04-02 23:14:30 +09:00
|
|
|
for (i = 0; i < strLength; ++i) {
|
|
|
|
levels[i] = startLevel;
|
2012-09-12 08:42:24 +09:00
|
|
|
}
|
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
/*
|
|
|
|
X1-X10: skip most of this, since we are NOT doing the embeddings.
|
|
|
|
*/
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
const e = isOdd(startLevel) ? "R" : "L";
|
|
|
|
const sor = e;
|
|
|
|
const eor = sor;
|
2017-04-02 23:14:30 +09:00
|
|
|
|
|
|
|
/*
|
|
|
|
W1. Examine each non-spacing mark (NSM) in the level run, and change the
|
|
|
|
type of the NSM to the type of the previous character. If the NSM is at the
|
|
|
|
start of the level run, it will get the type of sor.
|
|
|
|
*/
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
let lastType = sor;
|
2017-04-02 23:14:30 +09:00
|
|
|
for (i = 0; i < strLength; ++i) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (types[i] === "NSM") {
|
2017-04-02 23:14:30 +09:00
|
|
|
types[i] = lastType;
|
|
|
|
} else {
|
|
|
|
lastType = types[i];
|
|
|
|
}
|
|
|
|
}
|
2014-03-12 13:48:50 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
/*
|
|
|
|
W2. Search backwards from each instance of a European number until the
|
|
|
|
first strong type (R, L, AL, or sor) is found. If an AL is found, change
|
|
|
|
the type of the European number to Arabic number.
|
|
|
|
*/
|
|
|
|
lastType = sor;
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
let t;
|
2017-04-02 23:14:30 +09:00
|
|
|
for (i = 0; i < strLength; ++i) {
|
|
|
|
t = types[i];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (t === "EN") {
|
|
|
|
types[i] = lastType === "AL" ? "AN" : "EN";
|
|
|
|
} else if (t === "R" || t === "L" || t === "AL") {
|
2017-04-02 23:14:30 +09:00
|
|
|
lastType = t;
|
2014-03-09 05:49:53 +09:00
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
}
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
/*
|
|
|
|
W3. Change all ALs to R.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < strLength; ++i) {
|
|
|
|
t = types[i];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (t === "AL") {
|
|
|
|
types[i] = "R";
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
}
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
/*
|
|
|
|
W4. A single European separator between two European numbers changes to a
|
|
|
|
European number. A single common separator between two numbers of the same
|
|
|
|
type changes to that type:
|
|
|
|
*/
|
|
|
|
for (i = 1; i < strLength - 1; ++i) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (types[i] === "ES" && types[i - 1] === "EN" && types[i + 1] === "EN") {
|
|
|
|
types[i] = "EN";
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (
|
|
|
|
types[i] === "CS" &&
|
|
|
|
(types[i - 1] === "EN" || types[i - 1] === "AN") &&
|
|
|
|
types[i + 1] === types[i - 1]
|
|
|
|
) {
|
2017-04-02 23:14:30 +09:00
|
|
|
types[i] = types[i - 1];
|
|
|
|
}
|
|
|
|
}
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
/*
|
|
|
|
W5. A sequence of European terminators adjacent to European numbers changes
|
|
|
|
to all European numbers:
|
|
|
|
*/
|
|
|
|
for (i = 0; i < strLength; ++i) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (types[i] === "EN") {
|
2017-04-02 23:14:30 +09:00
|
|
|
// do before
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
for (let j = i - 1; j >= 0; --j) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (types[j] !== "ET") {
|
2017-04-02 23:14:30 +09:00
|
|
|
break;
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
types[j] = "EN";
|
2017-04-02 23:14:30 +09:00
|
|
|
}
|
|
|
|
// do after
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
for (let j = i + 1; j < strLength; ++j) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (types[j] !== "ET") {
|
2017-04-02 23:14:30 +09:00
|
|
|
break;
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
types[j] = "EN";
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
}
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
/*
|
|
|
|
W6. Otherwise, separators and terminators change to Other Neutral:
|
|
|
|
*/
|
|
|
|
for (i = 0; i < strLength; ++i) {
|
|
|
|
t = types[i];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (t === "WS" || t === "ES" || t === "ET" || t === "CS") {
|
|
|
|
types[i] = "ON";
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
}
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
/*
|
|
|
|
W7. Search backwards from each instance of a European number until the
|
|
|
|
first strong type (R, L, or sor) is found. If an L is found, then change
|
|
|
|
the type of the European number to L.
|
|
|
|
*/
|
|
|
|
lastType = sor;
|
|
|
|
for (i = 0; i < strLength; ++i) {
|
|
|
|
t = types[i];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (t === "EN") {
|
|
|
|
types[i] = lastType === "L" ? "L" : "EN";
|
|
|
|
} else if (t === "R" || t === "L") {
|
2017-04-02 23:14:30 +09:00
|
|
|
lastType = t;
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
}
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
/*
|
|
|
|
N1. A sequence of neutrals takes the direction of the surrounding strong
|
|
|
|
text if the text on both sides has the same direction. European and Arabic
|
|
|
|
numbers are treated as though they were R. Start-of-level-run (sor) and
|
|
|
|
end-of-level-run (eor) are used at level run boundaries.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < strLength; ++i) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (types[i] === "ON") {
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
const end = findUnequal(types, i + 1, "ON");
|
|
|
|
let before = sor;
|
2017-04-02 23:14:30 +09:00
|
|
|
if (i > 0) {
|
|
|
|
before = types[i - 1];
|
2014-03-09 05:49:53 +09:00
|
|
|
}
|
2012-03-16 19:27:09 +09:00
|
|
|
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
let after = eor;
|
2017-04-02 23:14:30 +09:00
|
|
|
if (end + 1 < strLength) {
|
|
|
|
after = types[end + 1];
|
2014-03-09 05:49:53 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (before !== "L") {
|
|
|
|
before = "R";
|
2014-03-09 05:49:53 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (after !== "L") {
|
|
|
|
after = "R";
|
2014-03-09 05:49:53 +09:00
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
if (before === after) {
|
|
|
|
setValues(types, i, end, before);
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
i = end - 1; // reset to end (-1 so next iteration is ok)
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
}
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
/*
|
|
|
|
N2. Any remaining neutrals take the embedding direction.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < strLength; ++i) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (types[i] === "ON") {
|
2017-04-02 23:14:30 +09:00
|
|
|
types[i] = e;
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
}
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
/*
|
|
|
|
I1. For all characters with an even (left-to-right) embedding direction,
|
|
|
|
those of type R go up one level and those of type AN or EN go up two
|
|
|
|
levels.
|
|
|
|
I2. For all characters with an odd (right-to-left) embedding direction,
|
|
|
|
those of type L, EN or AN go up one level.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < strLength; ++i) {
|
|
|
|
t = types[i];
|
|
|
|
if (isEven(levels[i])) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (t === "R") {
|
2017-04-02 23:14:30 +09:00
|
|
|
levels[i] += 1;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
} else if (t === "AN" || t === "EN") {
|
2017-04-02 23:14:30 +09:00
|
|
|
levels[i] += 2;
|
2014-03-09 05:49:53 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
} else {
|
|
|
|
// isOdd
|
|
|
|
if (t === "L" || t === "AN" || t === "EN") {
|
2017-04-02 23:14:30 +09:00
|
|
|
levels[i] += 1;
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
}
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
/*
|
|
|
|
L1. On each line, reset the embedding level of the following characters to
|
|
|
|
the paragraph embedding level:
|
|
|
|
|
|
|
|
segment separators,
|
|
|
|
paragraph separators,
|
|
|
|
any sequence of whitespace characters preceding a segment separator or
|
|
|
|
paragraph separator, and any sequence of white space characters at the end
|
|
|
|
of the line.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// don't bother as text is only single line
|
|
|
|
|
|
|
|
/*
|
|
|
|
L2. From the highest level found in the text to the lowest odd level on
|
|
|
|
each line, reverse any contiguous sequence of characters that are at that
|
|
|
|
level or higher.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// find highest level & lowest odd level
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
let highestLevel = -1;
|
|
|
|
let lowestOddLevel = 99;
|
|
|
|
let level;
|
2017-04-02 23:14:30 +09:00
|
|
|
for (i = 0, ii = levels.length; i < ii; ++i) {
|
|
|
|
level = levels[i];
|
|
|
|
if (highestLevel < level) {
|
|
|
|
highestLevel = level;
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
if (lowestOddLevel > level && isOdd(level)) {
|
|
|
|
lowestOddLevel = level;
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
}
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
// now reverse between those limits
|
|
|
|
for (level = highestLevel; level >= lowestOddLevel; --level) {
|
|
|
|
// find segments to reverse
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
let start = -1;
|
2014-04-08 06:42:54 +09:00
|
|
|
for (i = 0, ii = levels.length; i < ii; ++i) {
|
2017-04-02 23:14:30 +09:00
|
|
|
if (levels[i] < level) {
|
|
|
|
if (start >= 0) {
|
|
|
|
reverseValues(chars, start, i);
|
|
|
|
start = -1;
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
} else if (start < 0) {
|
|
|
|
start = i;
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
|
|
|
}
|
2017-04-02 23:14:30 +09:00
|
|
|
if (start >= 0) {
|
|
|
|
reverseValues(chars, start, levels.length);
|
|
|
|
}
|
|
|
|
}
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
/*
|
|
|
|
L3. Combining marks applied to a right-to-left base character will at this
|
|
|
|
point precede their base character. If the rendering engine expects them to
|
|
|
|
follow the base characters in the final display process, then the ordering
|
|
|
|
of the marks and the base character must be reversed.
|
|
|
|
*/
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
// don't bother for now
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
/*
|
|
|
|
L4. A character that possesses the mirrored property as specified by
|
|
|
|
Section 4.7, Mirrored, must be depicted by a mirrored glyph if the resolved
|
|
|
|
directionality of that character is R.
|
|
|
|
*/
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
// don't mirror as characters are already mirrored in the pdf
|
2012-03-16 19:27:09 +09:00
|
|
|
|
2017-04-02 23:14:30 +09:00
|
|
|
// Finally, return string
|
|
|
|
for (i = 0, ii = chars.length; i < ii; ++i) {
|
Enable the `no-var` linting rule in `src/core/bidi.js`
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
}
function findUnequal(arr, start, value) {
- for (var j = start, jj = arr.length; j < jj; ++j) {
+ let j, jj;
+ for (j = start, jj = arr.length; j < jj; ++j) {
if (arr[j] !== value) {
return j;
}
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
for (i = 0; i < strLength; ++i) {
if (types[i] === "EN") {
// do before
- var j;
- for (j = i - 1; j >= 0; --j) {
+ for (let j = i - 1; j >= 0; --j) {
if (types[j] !== "ET") {
break;
}
types[j] = "EN";
}
// do after
- for (j = i + 1; j < strLength; ++j) {
+ for (let j = i + 1; j < strLength; ++j) {
if (types[j] !== "ET") {
break;
}
```
2021-05-16 21:10:36 +09:00
|
|
|
const ch = chars[i];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (ch === "<" || ch === ">") {
|
|
|
|
chars[i] = "";
|
2012-03-16 19:27:09 +09:00
|
|
|
}
|
2012-03-19 05:49:04 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
return createBidiText(chars.join(""), isLTR);
|
2017-04-02 23:14:30 +09:00
|
|
|
}
|
2012-03-19 05:49:04 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
export { bidi };
|