Convert Apple Dictionary HTML `<span>`s into semantic, readable HTML. Removes the dependency on CSS styles by converting span class names into appropriate semantic HTML tags and structural markup.
Project description
appledict2semantic
appledict2semantic is a Python tool to convert Apple Dictionary HTML files into clean, semantic HTML. It removes the dependency on the custom CSS by mapping span class names to appropriate semantic HTML tags and structural markup, making the output more readable and portable.
Screenshots
Before conversion:
After conversion:
Features
- Span-to-semantic conversion: Converts Apple Dictionary’s
<span class="...">elements into semantic HTML tags like<strong>,<em>,<u>, and more. - Structural transformation: Transforms sense and subsense blocks into nested lists
<ul>,<li>for better readability. - Block conversion: Converts etymology, derivatives, and usage note blocks into more meaningful HTML structures. This paves way for further processing, e.g. to convert to Markdown.
- Cleanup: Removes unnecessary or empty tags, and replaces bullet spans with proper list items.
- Batch processing: Supports processing single files or entire folders, with optional in-place replacement.
Installation
Make sure that you have Python 3.10 or higher installed.
Then install the package from PyPI:
pip install appledict2semantic
Obtain and extract Apple Dictionary HTML files
How to obtain
To obtain the Apple Dictionary, first you need to have a macOS.
Then, open the Dictionary app, select Dictionary > Settings. Choose the sources you want to download.
The dictionary files are stored in /System/Library/AssetsV2/com_apple_MobileAsset_DictionaryServices_dictionaryOSX.
How to extract
Install pyglossary:
pip install pyglossary
Then use pyglossary to point to the Body.data file, and convert to AppleDict Source. This will produces a XML file.
From there, use this script to extract the XML file to HTML files.
Usage
-
Converts a single Apple Dictionary HTML file to semantic HTML:
appledict2semantic --single input.html output.html
-
Processes all .html files in
input_folder, saving results tooutput_folder:appledict2semantic --multiple input_folder output_folder
-
Processes all .html files in
input_folder, replacing the original files:appledict2semantic --multiple input_folder --replace
You will need to confirm the action.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file appledict2semantic-1.1.2.tar.gz.
File metadata
- Download URL: appledict2semantic-1.1.2.tar.gz
- Upload date:
- Size: 324.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
222b021cfa7261967a79a3b396031464dae5d2e83ce5d98645f30c7f33321e65
|
|
| MD5 |
06975dd99ee9c85d7fe968fffbc5d41a
|
|
| BLAKE2b-256 |
40606547936f7283c35a684632da4330b4fd228a26d47ce0a4306763c07ae96d
|
Provenance
The following attestation bundles were made for appledict2semantic-1.1.2.tar.gz:
Publisher:
build.yaml on yell0wsuit/appledict2semantic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
appledict2semantic-1.1.2.tar.gz -
Subject digest:
222b021cfa7261967a79a3b396031464dae5d2e83ce5d98645f30c7f33321e65 - Sigstore transparency entry: 265219199
- Sigstore integration time:
-
Permalink:
yell0wsuit/appledict2semantic@4febc53571a1905e60b83ea88676405aaaca09bc -
Branch / Tag:
refs/heads/main - Owner: https://github.com/yell0wsuit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yaml@4febc53571a1905e60b83ea88676405aaaca09bc -
Trigger Event:
push
-
Statement type:
File details
Details for the file appledict2semantic-1.1.2-py3-none-any.whl.
File metadata
- Download URL: appledict2semantic-1.1.2-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e264560ee0f7a0199b26f15698c74a3645253b14884cefe8d1e6d01ce6f1df4
|
|
| MD5 |
ed681a3801cdd87e266b0e1c57f06869
|
|
| BLAKE2b-256 |
c90c4a4a081b6419f2de41b339cd4ef11ececdcbb44e465384ce8eb00f2e769a
|
Provenance
The following attestation bundles were made for appledict2semantic-1.1.2-py3-none-any.whl:
Publisher:
build.yaml on yell0wsuit/appledict2semantic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
appledict2semantic-1.1.2-py3-none-any.whl -
Subject digest:
7e264560ee0f7a0199b26f15698c74a3645253b14884cefe8d1e6d01ce6f1df4 - Sigstore transparency entry: 265219204
- Sigstore integration time:
-
Permalink:
yell0wsuit/appledict2semantic@4febc53571a1905e60b83ea88676405aaaca09bc -
Branch / Tag:
refs/heads/main - Owner: https://github.com/yell0wsuit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yaml@4febc53571a1905e60b83ea88676405aaaca09bc -
Trigger Event:
push
-
Statement type: