https://bugs.kde.org/show_bug.cgi?id=477042

Christoph Cullmann <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Latest Commit|                            |https://invent.kde.org/fram
                   |                            |eworks/syntax-highlighting/
                   |                            |-/commit/11980feb06c982760b
                   |                            |34d9fa7a8402efd506276d
             Status|REPORTED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Christoph Cullmann <[email protected]> ---
Git commit 11980feb06c982760b34d9fa7a8402efd506276d by Christoph Cullmann, on
behalf of Jonathan Poelen.
Committed on 14/08/2025 at 17:24.
Pushed by cullmann into branch 'master'.

fix themes with two adjacent color in CSV syntaxes

All themes are modified to use 5 distinct colors,
with the exception of Vim Dark, which uses 10 colors.

The following program allows you to select a color (`names` variable)
and generate the JSON of the 'custom-styles' theme:

```js
const {openSync, readSync} = require('fs');

const fd = openSync('/dev/stdin');

const buf = Buffer.alloc(1024 * 1024);
const len = readSync(fd, buf);
if (len === 0) {
  exit(1)
}

o = JSON.parse(buf.subarray(0, len).toString())['text-styles']

//          0          1           2         3            4           5        
6          7         8           9
names = ['Normal', 'Variable', 'String', 'BuiltIn', 'Preprocessor', 'Char',
'Function', 'BaseN', 'Operator', 'DataType']
names = ['Normal', 'Variable', 'String', 'BuiltIn', 'Preprocessor']

f = (i) => {
    const name = names[i] || names[i % 5];
    return `
            "Column ${i}": {
                "selected-text-color": "${o[name]['selected-text-color']}",
                "text-color": "${o[name]['text-color']}"
            },`
}

r1 = `${f(0)}${f(1)}${f(2)}${f(3)}${f(4)}`;
r2 = `${f(5)}${f(6)}${f(7)}${f(8)}${f(9)}`;
r3 = r1.replaceAll('": {', ' Separator": {').replaceAll('"\n"', '",\n          
     "bold": true"')
r4 = r2.replaceAll('": {', ' Separator": {').replaceAll('"\n"', '",\n          
     "bold": true"')
r = `${r1}${r2}${r3}${r4.substr(0,r4.length-1)}`

console.log(`
        "CSV": {${r}
        },
        "TSV": {${r}
        },
        "CSV (semicolon)": {${r}
        },
        "CSV (whitespace)": {${r}
        },
        "CSV (pipe)": {${r}
        }`)
```

```sh
node prog.js <file.theme | xclip -selection clipboard
```

The following removes unnecessary column redefinitions from a theme:

(If column 9 is deleted, the end comma must manually delete.)

```sh
sed -E '/"Column [049]/,/}/d' -i data/themes/tokyo-night-light.theme
```

The following program allows a visualization of a theme
(deal with `XDG_DATA_DIRS` and symbolic links to use the themes of the
repository):

```sh
theme='Vim Dark'
r=$(ksyntaxhighlighter6 -fansi -s csv -t "$theme"
<<<"aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,xx,$theme" \
    | sed -E 's/\x1b\[38;2;([^m]+)m([a-z]{2})/\x1b[38;2;\1m[\1]\2/g')
echo -n "$r"
r=${r/xx*/}
s='                     '
s="${s:1:$((${#r}/43))}"
echo "      0${s}1${s}2${s}3${s}4${s}5${s}6${s}7${s}8${s}9        "
```

themes

M  +3    -3    autotests/html/highlight.csv-pipe.dark.html
M  +3    -3    autotests/html/highlight.csv-pipe.html
M  +4    -4    autotests/html/highlight.csv-semicolon.dark.html
M  +4    -4    autotests/html/highlight.csv-semicolon.html
M  +2    -2    autotests/html/highlight.csv-whitespace.dark.html
M  +2    -2    autotests/html/highlight.csv-whitespace.html
M  +4    -4    autotests/html/highlight.csv.dark.html
M  +4    -4    autotests/html/highlight.csv.html
M  +2    -2    autotests/html/highlight.tsv.dark.html
M  +2    -2    autotests/html/highlight.tsv.html
M  +11   -11   data/syntax/csv-whitespace.xml
M  +11   -11   data/syntax/tsv.xml
M  +211  -1    data/themes/atom-one-dark.theme
M  +211  -1    data/themes/atom-one-light.theme
M  +291  -1    data/themes/ayu-dark.theme
M  +293  -1    data/themes/ayu-light.theme
M  +251  -1    data/themes/ayu-mirage.theme
M  +294  -2    data/themes/breeze-dark.theme
M  +299  -2    data/themes/breeze-light.theme
M  +331  -1    data/themes/catppuccin-frappe.theme
M  +331  -1    data/themes/catppuccin-latte.theme
M  +331  -1    data/themes/catppuccin-macchiato.theme
M  +331  -1    data/themes/catppuccin-mocha.theme
M  +381  -1    data/themes/dracula.theme
M  +311  -1    data/themes/falcon.theme
M  +251  -1    data/themes/github-dark.theme
M  +251  -1    data/themes/github-light.theme
M  +294  -2    data/themes/gruvbox-dark.theme
M  +294  -2    data/themes/gruvbox-light.theme
M  +331  -1    data/themes/homunculus.theme
M  +341  -1    data/themes/monokai.theme
M  +344  -1    data/themes/nord.theme
M  +298  -1    data/themes/oblivion.theme
M  +214  -2    data/themes/printing.theme
M  +253  -1    data/themes/radical.theme
M  +371  -1    data/themes/solarized-dark.theme
M  +376  -1    data/themes/solarized-light.theme
M  +371  -1    data/themes/tokyo-night-light.theme
M  +371  -1    data/themes/tokyo-night-storm.theme
M  +371  -1    data/themes/tokyo-night.theme
M  +379  -2    data/themes/vim-dark.theme
M  +251  -1    data/themes/vscodium-dark.theme

https://invent.kde.org/frameworks/syntax-highlighting/-/commit/11980feb06c982760b34d9fa7a8402efd506276d

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to