A Python library for processing Tex files, such as formatting BibTeX titles, capitalizing words, and more.
Project description
TexHelper
TexHelper is a Python library designed to assist with various tasks related to LaTeX files, including automating title formatting, processing BibTeX files, and more. It is particularly useful for anyone working with LaTeX documents who needs to handle common formatting issues and improve productivity.
Features
- Title Formatting: Automatically capitalizes the words in titles while respecting common style rules (e.g., only capitalizing the first and last words, and specific important words).
- BibTeX Processing: Supports processing and formatting of BibTeX entries, including fixing capitalization in titles and beautifying BibTeX files.
- File Processing: Allows reading and processing
.bibfiles, capitalizing the titles in the entries and saving the results to new files. - BibTeX Beautification: Beautifies BibTeX files by formatting each entry with consistent field order and proper spacing.
- Extensible: The library is designed to be modular, allowing for easy addition of new features.
Installation
You can install TexHelper directly from PyPI using pip:
pip install texhelper
Usage
After installation, you can import and use the functions in your Python code.
Example: Capitalizing Titles
Here’s an example of how to use the title_case_only function, which formats multiple titles according to common capitalization rules.
from texhelper.bibtex import title_case_only
titles = "{the quick brown fox jumps over the lazy dog}{a quick overview of deep learning}"
formatted_titles = title_case_only(titles)
print(formatted_titles)
Output:
The Quick Brown Fox Jumps Over the Lazy Dog The Quick Overview of Deep Learning
Example: Processing a BibTeX Entry
You can also use TexHelper to process BibTeX files, applying the correct title capitalization.
from texhelper.bibtex import title_case_bibtex
bib_content = [
'author={John Doe},\n',
'title={the quick brown fox jumps over the lazy dog},\n',
'year={2024},\n'
]
processed_bib = title_case_bibtex(bib_content)
print(''.join(processed_bib))
Output:
author={John Doe},
title={The Quick Brown Fox Jumps Over the Lazy Dog},
year={2024},
Example: Processing a BibTeX File
You can use TexHelper to read a .bib file, process the titles, and save the results to a new file.
from texhelper.bibtex import title_case_file
input_filepath = "input.bib"
output_filepath = "output.bib"
title_case_file(input_filepath, output_filepath)
This function reads the .bib file, capitalizes all titles, and saves the processed content to the output file.
Example: Beautifying a BibTeX File
The beautify_bibtex_file function formats and beautifies a .bib file by ensuring proper field order and spacing.
from texhelper.bibtex import beautify_bibtex_file
input_file = "input.bib"
output_file = "output.bib"
beautify_bibtex_file(input_file, output_file)
This function reads the .bib file, formats the entries, and saves the beautified content to a new file.
License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
Contributing
We welcome contributions! To contribute to TexHelper, please fork the repository and create a pull request. Here are some ways you can help:
- Bug Reports: If you find a bug, please report it in the Issues section of the GitHub repository.
- Feature Requests: Suggest new features or improvements.
- Code Improvements: If you see areas where the code can be improved, feel free to submit a pull request with your changes.
Credits
TexHelper was created and is maintained by Shuhong Dai.
Acknowledgements
- Thanks to the open-source community for their valuable libraries and tools that made this project possible.
- Special thanks to PyPI for providing a platform for publishing Python packages.
Support
For any questions or support, feel free to open an issue on the GitHub Issues page.
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 texhelper-0.1.1.tar.gz.
File metadata
- Download URL: texhelper-0.1.1.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d62a404ae5a2f54b0f0993b9f7135da70e9ccd84bcd0c8e91e29c40b4ab2747
|
|
| MD5 |
07afc161f2f4bf8242a7ad0c7007830b
|
|
| BLAKE2b-256 |
09f5a19fe6331c261c95714e632371720461c21a492dc9f00b91bcddf492fe44
|
File details
Details for the file texhelper-0.1.1-py3-none-any.whl.
File metadata
- Download URL: texhelper-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ba8de318d106a43720694f504c394132713f9a0774bf7dc3a117a47afbb7083
|
|
| MD5 |
83220de5a03adbe2849d1cbb3d5da032
|
|
| BLAKE2b-256 |
6915a446f2f78845e5a9295e0da954d0808f0d2583e518fa8565c7bc310c084a
|