Skip to content

Commit

Permalink
🎨 Use tree-sitter-lsp's API to simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Dec 2, 2023
1 parent 76c4f6e commit a05f19c
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/zathura_language_server/misc/zathurarc.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
r"""Zathurarc
=============
"""
import os
import re
from gzip import decompress
from typing import Any

from markdown_it import MarkdownIt
from platformdirs import site_data_dir
from pypandoc import convert_text
from tree_sitter_lsp.misc import get_md_tokens

from .._metainfo import SOURCE, project

Expand All @@ -31,16 +27,7 @@ def init_schema() -> dict[str, Any]:
"properties": {},
}
}
with open(
os.path.join(
os.path.join(site_data_dir("man"), "man5"), "zathurarc.5.gz"
),
"rb",
) as f:
text = decompress(f.read()).decode()
text = convert_text(text, "markdown", "man")
md = MarkdownIt("commonmark", {})
tokens = md.parse(text)
tokens = get_md_tokens("zathurarc")
indices = []
end_index = len(tokens)
for i, token in enumerate(tokens):
Expand Down

0 comments on commit a05f19c

Please sign in to comment.