Releases: trishume/syntect
Fixes to errors
Pure-Rust regex engine support!
Headline feature: pure-Rust fancy-regex
engine option
Users can now opt in to a pure-Rust regex engine using Cargo features, making
compilation easier in general. People experiencing difficulty compiling for
Windows and Wasm should try switching to fancy-regex
. Note this currently
approximately halves highlighting speed.
See the Readme and #270 for details.
Thanks to @robinst for implementing this!
Other changes
- Ability to generate CSS for a theme for use with classed HTML generation (won't always be correct) #274
- Don't generate empty spans in classed HTML #276
- Miscellaneous dependency bumps and cleanup
Breaking changes and upgrading
Upgrading should cause no errors for nearly all users. Users using more unusual APIs may have a small amount of tweaking to do.
- Edit March 30: If you generate custom pack files and want to use fancy-regex you need to regenerate them. The binary format is the same but at YAML loading time regex rewrites get applied that make fancy-regex work properly.
- If you use
default-features = false
you may need to update your features to choose a regex engine - A bunch of technically public APIs that I don't know if anyone uses changed due to the regex engine refactor, common uses shouldn't break
Bug fixes and new utilities
- Fixes multiple bugs
- Add RangedHighlightIterator
- Add
as_latex_escaped
util
Onig dependency bump and inconsequential patches
Hopefully no behavior changes.
Make method tokens_to_classed_spans public like intended
Really a bug fix but the bug was not having an API be public so hence SemVer demands a minor version bump.
Metadata and new classed HTML generation
Bug fixes
Minor bug fixes
Breaking changes and major new features
This is a major release with multiple breaking API changes, although upgrading shouldn't be too difficult. It fixes bugs and comes with some nice new features.
Breaking changes and upgrading
- The
SyntaxSet
API has been revamped to use a builder and an arena of contexts. See example usage. - Many functions now need to be passed the
SyntaxSet
that goes with the rest of their arguments because of this new arena. - Filename added to
LoadingError::ParseSyntax
- Many functions in the
html
module now take thenewlines
version of syntaxes.- These methods have also been renamed, partially so that code that needs updating doesn't break without a compile error.
- The HTML they output also treats newlines slightly differently and I think more correctly but uglier when you look at the HTML.
Breaking rename upgrade guide
SyntaxSet::add_syntax -> SyntaxSetBuilder::add
SyntaxSet::load_syntaxes -> SyntaxSetBuilder::add_from_folder
SyntaxSet::load_plain_text_syntax -> SyntaxSetBuilder::add_plain_text_syntax
html::highlighted_snippet_for_string -> html::highlighted_html_for_string
: also change tonewlines
SyntaxSet
html::highlighted_snippet_for_file -> html::highlighted_html_for_file
: also change tonewlines
SyntaxSet
html::styles_to_coloured_html -> html::styled_line_to_highlighted_html
: also change tonewlines
SyntaxSet
html::start_coloured_html_snippet -> html::start_highlighted_html_snippet
: return type also changed
Major changes and new features
- Use arena for contexts (#182 #186 #187 #190 #195): This makes the code cleaner, enables use of syntaxes from multiple threads, and prevents accidental misuse.
- This involves a new
SyntaxSetBuilder
API for constructing newSyntaxSet
s - See the revamped parsyncat example.
- This involves a new
- Encourage use of newlines (#197 #207 #196): The
nonewlines
mode is often buggy so we made it easier to use thenewlines
mode.- Added a
LinesWithEndings
utility for iterating over the lines of a string with\n
characters. - Reengineer the
html
module to usenewlines
syntaxes.
- Added a
- Add helpers for modifying highlighted lines (#198): For use cases like highlighting a piece of text in a blog code snippet or debugger. This allows you to reach into the highlighted spans and add styles.
- Check out
split_at
andmodify_range
in theutil
module.
- Check out
- New
ThemeSet::add_from_folder
function (#200): For modifying existing theme sets.
Bug Fixes
- Improve nonewlines regex rewriting: #212 #211
- Reengineer theme application to match Sublime: #209
- Also mark contexts referenced by name as "no prototype" (same as ST): #180
- keep with_prototype when switching contexts with
set
: #177 #166 - Fix unused import warning: #174
- Ignore trailing dots in selectors: #173
- Fix
embed
to not include prototypes: #172 #160
Upgraded dependencies
- plist:
0.2 -> 0.3
- regex:
0.2 -> 1.0
- onig:
3.2.1 -> 4.1
Regex checking and plain file names
- Check regexes compile upon loading from YAML (There's technically a small breaking change here if you match on the previously unused regex error, but I don't think anyone does)
- Can detect the correct syntax on full file names like
CMakeLists.txt
- Make nonewlines mode marginally less buggy (still prefer using newlines mode)
- Better error types
- Better examples and tests