Getting Started
Install the Extension Locally
The extension doesn’t require a build step - you can load it directly from the source files.
For Firefox:
- Open Firefox and navigate to
about:debugging#/runtime/this-firefox - Click “Load Temporary Add-on”
- Select the
manifest.jsonfile from the repository
For Chrome/Chromium:
- Open Chrome and navigate to
chrome://extensions/ - Enable “Developer mode” (toggle in top right)
- Click “Load unpacked”
- Select the repository folder
Make Your Changes
The extension consists of three main files:
content.js- Core conversion logic that runs on Notion pagespopup.js- Extension popup interface handlermanifest.json- Extension configuration and permissions
Test Your Changes
- Open a Notion page in your browser
- Paste some LaTeX equations (e.g.,
$E=mc^2$or$$\int_0^\infty e^{-x^2}dx$$) - Test the conversion using:
- Keyboard shortcut:
Ctrl+Alt+M - Extension popup: Click the extension icon and press “Convert”
- Keyboard shortcut:
- Verify that both inline (
$...$) and display ($$...$$) equations convert correctly
Project Structure
The extension has a simple, focused structure:Understanding the Conversion Logic
The core conversion happens incontent.js. Here’s how it works:
Equation Detection
Equation Detection
The extension uses a regex pattern to find LaTeX equations:This matches both:
- Inline equations:
$...$ - Display equations:
$$...$$
Sequential Processing
Sequential Processing
Equations are converted one at a time in a loop:
- Find all equations in the DOM
- Convert the first equation
- Wait for Notion to update the DOM
- Rescan and repeat until no equations remain
Timing Configuration
Timing Configuration
The extension uses carefully tuned delays to work with Notion’s UI:
FOCUS: 50ms- Wait after focusing an editable blockQUICK: 20ms- Short pause for UI updatesDIALOG: 100ms- Wait for dialogs to appearMATH_BLOCK: 100ms- Wait for math block initializationPOST_CONVERT: 300ms- Wait after conversion for DOM update
Display vs Inline Equations
Display vs Inline Equations
The extension handles the two equation types differently:Display equations (
$$...$$):- Deletes the selected text
- Types
/mathto trigger Notion’s math block command - Presses Enter to create the block
- Inserts the LaTeX content into the math input
- Clicks “Done” or presses Escape to close
$...$):- Directly replaces the selected text with
$$content$$ - Notion automatically renders this as inline math
Coding Guidelines
Code Style
- Use clear, descriptive variable names
- Add comments for non-obvious logic
- Follow the existing code formatting
- Keep functions focused and single-purpose
Testing
- Test on both Firefox and Chrome
- Test with various LaTeX expressions
- Test with multiple equations on one page
- Verify error handling (invalid LaTeX)
Performance
- Minimize DOM queries
- Use appropriate timing delays
- Avoid blocking the main thread
- Test with pages containing many equations
Compatibility
- Use standard Web APIs
- Use browser polyfill:
const api = typeof browser !== 'undefined' ? browser : chrome; - Test Manifest V3 compatibility
- Ensure works with Notion’s dynamic content
Common Contribution Areas
Bug Fixes
If you’ve found a bug:- Check if an issue already exists on GitHub
- If not, open a new issue with:
- Steps to reproduce
- Expected vs actual behavior
- Browser and version
- Example LaTeX equations that fail
- Reference the issue number in your pull request
Feature Enhancements
Potential areas for improvement:- Support for additional LaTeX environments
- Better error handling for invalid LaTeX
- Visual feedback during conversion
- Support for other note-taking platforms
- Customizable keyboard shortcuts
- Batch conversion with progress indicator
Before starting work on a major feature, open an issue to discuss the approach and ensure it aligns with the project’s goals.
Documentation
Documentation improvements are always welcome:- Fix typos or unclear explanations
- Add examples for common use cases
- Improve code comments
- Add troubleshooting guides
- Create video tutorials or demos
Reporting Issues
When reporting issues, please include:Bug Report Template
Bug Report Template
Description:
A clear description of what went wrongSteps to Reproduce:
- Step one
- Step two
- …
- Browser: (Chrome/Firefox/Other)
- Browser version:
- Extension version:
- Operating System:
Development Tips
Browser Compatibility
The extension uses the browser API polyfill pattern:browser.*) and Chrome (which uses chrome.*).
Need Help?
If you have questions:- Open a GitHub issue
- Check existing issues for similar questions
- Review the code comments in
content.jsfor implementation details