<commit_before>import re

import sublime

from .view import MdeTextCommand, syntax_specific_settings_file

MARKDOWN_TEMPLATE = """# A sample Markdown document

This is a sample document so you can preview the color schemes.

## I am a second-level header

Markdown supports _italics_, __bold__, and ___bold italics___ style.

There are also inline styles like `inline code in monospace font` and ~~strikethrough style~~.
__There may be ~~strikethroughed text~~ or `code text` inside bold text.__
_And There may be ~~strikethroughed text~~ or `code text` inside italic text._

To reference something from a URL, [Named Links][links],
[Inline links](https://example.com/index.html) and direct link like <https://example.com/>
are of great help. Sometimes ![A picture][sample image] is worth a thousand words.

There are two types of lists, numbered and unnumbered.

1. Item 1
2. Item 2
3. Item 3

* Item A
    - Sub list
        + Sub sub list
        + Sub sub list 2
    - Sub list 2
* Item B
* Item C

## Fenced code

You can write fenced code inside three backticks.

```javascript
function fibo(n) {
    fibo.mem = fibo.mem || []; // I am some comment
    return fibo.mem[n] || fibo.mem[n] = n <= 1 ? 1 : fibo(n - 1) + fibo(n - 2);
}
```

## The following section is used to define named links

[links]: https://example.com/index.html
[sample image]: https://example.com/sample.png

## Wiki links

This [[SamplePage]] is a wiki link

---

"""


class MdeSelectColorSchemeCommand(MdeTextCommand):
    def run(self, edit):
        select_color_scheme(self.view)


def select_color_scheme(view=None):
    syntax_settings = syntax_specific_settings_file(view) or "Markdown.sublime-settings"

    window = view.window() if isinstance(view, sublime.View) else sublime.active_window()
    pre_view = window.new_file(
        flags=sublime.TRANSIENT, syntax="Packages/MarkdownEditing/Markdown.sublime-syntax"
    )
    pre_view.set_scratch(True)
    pre_view.run_command("append", {"characters": MARKDOWN_TEMPLATE})
    pre_view.set_read_only(True)

    md_settings = sublime.load_settings(syntax_settings)
    md_scheme = md_settings.get("color_scheme")

    global_settings = sublime.load_settings("Preferences.sublime-settings")
    global_scheme = global_settings.get("color_scheme")
    schemes = [global_scheme, "MarkdownEditor.sublime-color-scheme"]
    for scheme in sublime.find_resources("MarkdownEditor*.sublime-color-scheme"):
        file_name = scheme.split("/")[-1]
        if file_name not in schemes:
            schemes.append(file_name)

    schemes_display = []
    selected_index = 0
    for i, s in enumerate(schemes):<commit_msg>Plugins: Fix markdown syntax path in color choose<commit_after>import re

import sublime

from .view import MdeTextCommand, syntax_specific_settings_file

MARKDOWN_TEMPLATE = """# A sample Markdown document

This is a sample document so you can preview the color schemes.

## I am a second-level header

Markdown supports _italics_, __bold__, and ___bold italics___ style.

There are also inline styles like `inline code in monospace font` and ~~strikethrough style~~.
__There may be ~~strikethroughed text~~ or `code text` inside bold text.__
_And There may be ~~strikethroughed text~~ or `code text` inside italic text._

To reference something from a URL, [Named Links][links],
[Inline links](https://example.com/index.html) and direct link like <https://example.com/>
are of great help. Sometimes ![A picture][sample image] is worth a thousand words.

There are two types of lists, numbered and unnumbered.

1. Item 1
2. Item 2
3. Item 3

* Item A
    - Sub list
        + Sub sub list
        + Sub sub list 2
    - Sub list 2
* Item B
* Item C

## Fenced code

You can write fenced code inside three backticks.

```javascript
function fibo(n) {
    fibo.mem = fibo.mem || []; // I am some comment
    return fibo.mem[n] || fibo.mem[n] = n <= 1 ? 1 : fibo(n - 1) + fibo(n - 2);
}
```

## The following section is used to define named links

[links]: https://example.com/index.html
[sample image]: https://example.com/sample.png

## Wiki links

This [[SamplePage]] is a wiki link

---

"""


class MdeSelectColorSchemeCommand(MdeTextCommand):
    def run(self, edit):
        select_color_scheme(self.view)


def select_color_scheme(view=None):
    syntax_settings = syntax_specific_settings_file(view) or "Markdown.sublime-settings"

    window = view.window() if isinstance(view, sublime.View) else sublime.active_window()
    pre_view = window.new_file(
        flags=sublime.TRANSIENT, syntax="Packages/MarkdownEditing/syntaxes/Markdown.sublime-syntax"
    )
    pre_view.set_scratch(True)
    pre_view.run_command("append", {"characters": MARKDOWN_TEMPLATE})
    pre_view.set_read_only(True)

    md_settings = sublime.load_settings(syntax_settings)
    md_scheme = md_settings.get("color_scheme")

    global_settings = sublime.load_settings("Preferences.sublime-settings")
    global_scheme = global_settings.get("color_scheme")
    schemes = [global_scheme, "MarkdownEditor.sublime-color-scheme"]
    for scheme in sublime.find_resources("MarkdownEditor*.sublime-color-scheme"):
        file_name = scheme.split("/")[-1]
        if file_name not in schemes:
            schemes.append(file_name)

    schemes_display = []
    selected_index = 0
    for i, s in enumerate(schemes):
{'fraction_non_alphanumeric': 0.10676156583629894, 'fraction_numerical': 0.005244427795467316, 'mean_word_length': 3.8856358645928637, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1746515', 'n_tokens_mistral': 1735, 'n_tokens_neox': 1675, 'n_words': 506}