Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.3.3 - 2025-03-22

* 📝 Add search function to nekochan emoji list(by [List.js](https://listjs.com/))

## v0.3.2 - 2025-03-19

* ✨ Add nekochan directive
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"class": "fa-brands fa-solid fa-github fa-2x",
},
],

}

html_css_files = [
Expand Down
Binary file added docs/images/nekochan-search.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions docs/nekochan_emojis.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,11 @@ Each emoji can be specified by name or alias.
If you want to add or edit aliases to any Nekochan emoji, please send a Pull Request to [aliases.json](https://github.com/takanory/sphinx-nekochan/blob/main/sphinx_nekochan/data/aliases.json).
```

```{tip}
You can search nekochan emojis.

![](images/nekochan-search.gif)
```

```{_all_nekochan}
```
48 changes: 32 additions & 16 deletions sphinx_nekochan/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""sphinx-nekochan emoji extension"""

__version__ = "0.3.2"
__version__ = "0.3.3"

from functools import cache
from importlib import resources
Expand Down Expand Up @@ -155,26 +155,40 @@ def run(self) -> list[nodes.Node]:
nekochan_emoji, _ = get_nekochan_emoji_data()

text = f"Number of Nekochan emojis: {len(nekochan_emoji)}"
node_list.append(nodes.Text(text))
paragraph = nodes.paragraph()
paragraph.append(nodes.Text(text))
node_list.append(paragraph)

# add div
container = nodes.container()
container.attributes["ids"] = ["nekochan"]
search_text = '<input class="search" placeholder="Search" />'
search = nodes.raw("", nodes.Text(search_text), format="html")
container.append(search)

# create table and header
table, tgroup = self.create_table_header()
tbody = nodes.tbody()
tbody.set_class("list")
tgroup += tbody

container.append(table)
node_list.append(container)

first_char = ""
for name, data in nekochan_emoji.items():
if name[0] != first_char:
first_char = name[0]
# create section and title(H2)
section = nodes.section(ids=[first_char])
title = nodes.title(first_char.upper(), first_char.upper())
section.append(title)
node_list.append(section)

# create table and header
table, tgroup = self.create_table_header()
tbody = nodes.tbody()
tgroup += tbody
node_list.append(table)
# add row to table
tbody += self.create_row(name, nekochan_emoji[name]["aliases"])

# add javascript for list.js
js = """<script src="https://cdnjs.cloudflare.com/ajax/libs/list.js/2.3.1/list.min.js"></script>
<script>
var options = {valueNames: ['name', 'aliases']};
var userList = new List('nekochan', options);
</script>"""
search_text = '<input class="search" placeholder="Search" />'
js_node = nodes.raw("", nodes.Text(js), format="html")
container.append(js_node)

return node_list

def create_table_header(self) -> nodes.Node:
Expand Down Expand Up @@ -218,12 +232,14 @@ def create_row(self, name: str, aliases) -> nodes.Node:
cell = nodes.entry()
row += cell
cell += nodes.literal(name, name)
cell.set_class("name")
cell = nodes.entry()
row += cell
for idx, alias in enumerate(aliases):
if idx > 0:
cell += nodes.Text(", ")
cell += nodes.literal(alias, alias)
cell.set_class("aliases")

return row

Expand Down
Loading