Skip to content

Commit

Permalink
update support for Req: replace ligatures in PDF text #24
Browse files Browse the repository at this point in the history
  • Loading branch information
Benature committed Jul 24, 2023
1 parent ce86395 commit 9212942
Showing 1 changed file with 63 additions and 59 deletions.
122 changes: 63 additions & 59 deletions src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,72 +308,73 @@ export function textWrapper(prefix: string, suffix: string, app: App): void {

export function replaceLigature(s: string): string {
let ligatures = {
: "AA",
Æ: "AE",
: "AO",
: "AU",
: "AV",
: "AV",
: "AY",
: "aa",
æ: "ae",
: "ao",
: "au",
: "av",
: "av",
: "ay",
"Ꜳ": "AA",
"Æ": "AE",
"Ꜵ": "AO",
"Ꜷ": "AU",
"Ꜹ": "AV",
"Ꜻ": "AV",
"Ꜽ": "AY",
"ꜳ": "aa",
"æ": "ae",
"ꜵ": "ao",
"ꜷ": "au",
"ꜹ": "av",
"ꜻ": "av",
"ꜽ": "ay",
"🙰": "et",
: "ff",
: "ffi",
: "ffl",
: "fi",
: "fl",
"ff": "ff",
"ffi": "ffi",
"ffl": "ffl",
"fi": "fi",
"fl": "fl",
"℔": "lb",
Ƕ: "Hv",
: "lL",
Œ: "OE",
: "OO",
ƕ: "hv",
: "ll",
œ: "oe",
: "oo",
: "ɔe",
: "st",
: "ſt",
: "ue",
: "uo",
: "ſs",
: "TZ",
W: "VV",
: "VY",
ß: "ſz",
: "tz",
w: "vv",
: "vy",
: "aə",
: "əø",
ȸ: "db",
ʣ: "dz",
"Ƕ": "Hv",
"Ỻ": "lL",
"Œ": "OE",
"Ꝏ": "OO",
"ƕ": "hv",
"ỻ": "ll",
"œ": "oe",
"ꝏ": "oo",
"ꭢ": "ɔe",
"st": "st",
"ſt": "ſt",
"ᵫ": "ue",
"ꭣ": "uo",
"ẞ": "ſs",
"Ꜩ": "TZ",
"W": "VV",
"Ꝡ": "VY",
"ß": "ſz",
"ꜩ": "tz",
// "w": "vv",
"ꝡ": "vy",
"ꬱ": "aə",
"ꭁ": "əø",
"ȸ": "db",
"ʣ": "dz",
"ꭦ": "dʐ",
ʥ: "dʑ",
ʤ: "dʒ",
ʩ: "fŋ",
ʪ: "ls",
ʫ: "lz",
ɮ: "lʒ",
: "oə",
ȹ: "qp[c]",
ʨ: "tɕ",
ʦ: "ts",
"ʥ": "dʑ",
"ʤ": "dʒ",
"ʩ": "fŋ",
"ʪ": "ls",
"ʫ": "lz",
"ɮ": "lʒ",
"ꭀ": "oə",
"ȹ": "qp[c]",
"ʨ": "tɕ",
"ʦ": "ts",
"ꭧ": "tʂ",
ʧ: "tʃ",
: "ui",
: "ui",
ɯ: "uu",
"ʧ": "tʃ",
"ꭐ": "ui",
"ꭑ": "ui",
"ɯ": "uu",
};

Object.entries(ligatures).forEach(([key, value]) => {
s = s.replace(key, value);
var rx = new RegExp(key, "g");
s = s.replace(rx, value);
});
return s;
}
Expand All @@ -390,6 +391,7 @@ export function sortTodo(s: string): string {
flag: string;
for (const [i, line] of lines.entries()) {
let flags = /- \[([ \w])\]/g.exec(line);
// console.log(flags);
if (flags) {
let head = line.match(/^[ \t]*/g)[0];
if (!todo_detected) {
Expand Down Expand Up @@ -419,6 +421,7 @@ export function sortTodo(s: string): string {
last_flag = flag;
}
} else {
// console.log("else", flags, todo_detected)
if (todo_detected) {
suffix_text_line = i;
break;
Expand All @@ -438,6 +441,7 @@ export function sortTodo(s: string): string {
})
}
body = body.slice(0, body.length - 1); // remove the last "\n"
// console.log(body)

let prefix_text = lines.slice(0, prefix_text_line + 1).join('\n');
let suffix_text = suffix_text_line == -1 ? "" : lines.slice(suffix_text_line, lines.length).join('\n');
Expand Down

0 comments on commit 9212942

Please sign in to comment.