This patch fixes two regressions caused by the recently introduced change
to not highlight keywords used as symbol names when binding optionals:
1. When a weak reference to `self` is unwrapped using a `guard` statement.
2. When a property declaration is placed after a comment ending with “var”.
Since such new lines are grouped with their trailing marker, and start
with an escaping backslash, they would previously be ignored (since they
were incorrectly treated as string interpolation or escaped markers).
This patch makes Splash no longer highlight variables with the same
name as a keyword when used in optional binding, for example:
```
if let override = makeOverride() { ... }
```
This change makes Splash correctly handle connected multiline
comment delimiters; `/*` and `*/`, when those are either connected,
or directly placed next to punctuation.
Raw string interpolation has proven to be a bit trickier to
implement, since we don’t want to treat `#` as a delimiter
(since it’s used in so many other ways in Swift, for example
for `#if`, `#available`, etc.).
This patch contains a “quick fix” for supporting interpolated
raw strings that contain a single expression per interpolation.
A proper fix should be developed as soon as possible, but this
unblocks using Splash to highlight most raw string interpolated
code samples, for now.
This change makes it possible to inject a custom CSS class
prefix into `MarkdownDecorator`, which will in turn be
passed to its underlying HTML-based syntax highlighter.
This patch fixes syntax highlighting for any comments that begin with
a delimiter, which would previously prevent the comment’s leading token
from being parsed correctly. The fix is to prevent slashes to be merged
with any other delimiter, except for other slashes and asterisks.
This patch fixes highlighting of any type declarations that follow
a comment which was ended with a punctuation character. The fix is
to only look at previous tokens on the same line when determining
whether a given token is a keyword.
This change adds a test that verifies that indented function calls
are correctly highlighted. This was fixed as part of the previous
change to make static methods highlight correctly, but this test
will ensure we don’t see any regressions for this particular use case.
This patch makes Splash correctly highlight strings in which a value
is interpolated next to a delimiter character. The fix is to enable
each `Grammar` implementation to decide whether two tokens should be
*merged*, which in turn enables `SwiftGrammar` to veto that string
interpolation delimiters should be merged with their predecesor.
- Don’t highlight what *could* be a static method call using
the `dotAccess` style, only highlight tokens that are either
value-less enum cases or static properties.
- The exception to the above rule is within `switch` statements,
in which even call-like tokens are assumed to be enum cases.
- Highlight calls to `.init()` as keywords, for consistency
with other `init` usages.
This patch makes MarkdownDecorator not include line breaks before and
after the `<pre>` and `<code>` tags that it adds to code blocks, since
this will be rendered as whitespace in the browser.
This patch fixes syntax highlighting for types and functions which names
begin with an underscore. Previously these entities would be treated as
plain text, but now they’re highlighted correctly as either types or
function calls.
This patch fixes syntax highlighting for when shorthand closure
arguments ($0, $1…) are interpolated into a string literal. The
fix is to no longer treat “$” as a delimiter, which should help
solve similar issues that might be encountered in the future as
well.
Splash was already capable of highlighting property wrappers, since
anything following an `@` symbol is treated as a keyword, but this
change adds a test that makes sure that it’ll keep working.
While Splash has supported iOS since its early days, this change makes
it possible to compile the iOS version as a Swift Package, using Xcode 11.
The changes require us to not make the assumption that != macOS == Linux.
(Also git ignore the new `.swiftpm` directory that SwiftPM now uses)
This patch makes Splash correctly highlight closure argument
shorthands (`$0`, `$1`, etc.), while also making the logic for
detecting a function call a bit simpler.
This makes Splash correctly highlight key paths that are passed as arguments
to a function, especially when there’s no external parameter label for that
argument.
This patch makes Splash correctly highlight nested closures marked with
the `@escaping` attribute. The fix is to start treating `@` like a proper
token, rather than as a delimiter.
- Add clarification that Splash is used on Swift by Sundell.
- Update installation instructions to reference Swift 4.2.
- Use more even dependency version.
This change adds a new command line tool to the Splash family:
`SplashMarkdown`.
It’s an adapted version of the tool that I’ve been using for months to
publish every article on Swift by Sundell, and works by replacing all
code blocks within a Markdown file.
Adding this will hopefully make Splash even easier to use, without the
need for writing custom tooling, or to manually replace each code block
within a Markdown file with a “splashed” version.
Swift 5 enables us to define custom ways to interpolate expressions into
strings, and Splash already successfully highlights that syntax, but let’s
add a test to make sure that continues to be the case.
This change makes Splash capable of highlighting Swift 5 raw strings,
although it’s currently limited to single line string literals. Support
for multi-line literals will be added in a future commit.
This change adds SwiftLint to the project. For now, the rules are tweaked
to match the current state of the code base — but will over time be changed
back to their defaults in several cases.
Some smaller changes (mostly related to code style) were applied to the
project to remove all warnings.