159 Commits

Author SHA1 Message Date
John Sundell
03ea9bdcbb
Don’t treat accessing properties within switch statements as calls (#103)
This patch fixes syntax highlighting for when a property is being switched
on, which previously would be treated as a function call with trailing
closure syntax.
2020-04-16 19:52:26 +02:00
John Sundell
8e96992997
Fix syntax highlighting for leading function calls within closures (#102)
This patch fixes syntax highlighting when a function call appears as the
first expression within a closure that accepts arguments or capture lists
using the ‘in’ keyword.
2020-04-16 19:29:01 +02:00
Marco Capano
26d4bbe7ca
Add option to specify a grammar for MarkdownDecorator (#101) 2020-04-16 19:28:37 +02:00
John Sundell
3b546b7dd0
Correctly highlight enum cases called “some” (#100)
Was previously highlighted as a keyword.
2020-02-11 16:14:53 +01:00
Tobias Due Munk
2d55b33529
Fix Swift 5.2 compiler crash (#99) 2020-02-07 15:09:18 +01:00
Artur Rymarz
b501e834a8
Added Comment component test with a number (#90) 2020-01-29 11:36:20 +01:00
John Sundell
eca0850b52
Fix regressions after keywords-in-optional binding change (#98)
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”.
2020-01-29 11:30:16 +01:00
John Sundell
cac40caf68
Handle string literals that only have a new line (#97)
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).
2020-01-29 11:09:14 +01:00
John Sundell
812811ff69
Don’t highlight keyword names used in optional binding (#96)
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() { ... }
```
2020-01-29 11:04:14 +01:00
John Sundell
bb8655e6d2
Support the ‘unowned’ keyword (#95)
This change makes Splash correctly highlight the `unowned` keyword
when used within closure capture lists.
2020-01-29 10:34:17 +01:00
Tobias Due Munk
b7e9141e1b
Fix comments with punctuation just prior or after (#93)
This change makes Splash correctly handle connected multiline
comment delimiters; `/*` and `*/`, when those are either connected,
or directly placed next to punctuation.
2020-01-29 10:19:38 +01:00
John Sundell
97541c8835
Don’t highlight keywords used as parameters on a new line (#94)
This patch fixes a bug that would cause Splash to incorrectly highlight
parameter labels defined on a new line when those would match a keyword.
2020-01-29 00:37:08 +01:00
John Sundell
4da9bbd0bc
Add support for the “prefix” keyword (#91)
This patch makes Splash correctly highlight the `prefix` keyword, which
can only appear before `func`, so a special case was added for it (for now).
2019-12-30 23:39:54 +00:00
John Sundell
3de0275b52
HTML: Fully escape all required entities (#89)
Both when outputting HTML, and when highlighting code blocks within a
Markdown text, Splash now fully escapes all required character entities.
2019-11-23 23:59:16 +00:00
John Sundell
3a6c961de8
README: Remove Marathon installation instructions
Also remove the word "recent" when explaining how Splash is used
on Swift by Sundell, since it's now used for all articles.
2019-11-04 11:38:47 +01:00
John Sundell
bc20ac969c
Support highlighting custom compiler directives (#88)
Add support for highlighting the `#warning` and `#error` directives.
2019-11-04 11:31:08 +01:00
John Sundell
66714d6867
Correctly highlight nil when passed as a function argument (#87)
This patch fixes syntax highlighting when `nil` is passed to a function
that doesn’t have any parameter labels, such as `handler(nil)`.
2019-11-04 11:26:15 +01:00
John Sundell
19df647082
Correctly highlight generic subscript type lists (#86)
This patch fixes highlighting for types that appear within a list of a
subscript’s generic types.
2019-09-05 14:17:48 +02:00
John Sundell
8ef48daff9
Fix highlighting for strings within interpolation (#85)
This patch fixes syntax highlighting for string literals that appear
within string interpolation. This patch only takes single words into
account.
2019-09-05 14:11:58 +02:00
John Sundell
dddf418cea
Quick fix for single-expression raw string interpolation (#84)
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.
2019-09-05 11:59:28 +02:00
John Sundell
d1dd1acda0
MarkdownDecorator: Enable CSS class prefix to be injected (#83)
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.
2019-09-05 11:54:56 +02:00
John Sundell
91adf9359f
Fix highlighting for comments starting with a delimiter (#82)
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.
2019-08-07 16:07:22 +02:00
John Sundell
e03dac1dd6
Fix highlighting for comments ending with punctuation (#81)
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.
2019-08-07 15:51:16 +02:00
John Sundell
016aaa13f3
Add a test for indented function calls (#79)
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.
2019-08-07 15:45:29 +02:00
John Sundell
dcf5951d10
Fix highlighting when delimiters appear next to string interpolation (#80)
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.
2019-08-07 15:45:15 +02:00
John Sundell
367b8408b1
Tweaks to how dot syntax is highlighted (#78)
- 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.
2019-08-06 15:50:23 +02:00
John Sundell
e107609b00
MarkdownDecorator: Don’t hard code line breaks (#77)
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.
2019-07-25 16:10:55 +02:00
John Sundell
5280f4abc7
Add support for the ‘convenience’ keyword (#76)
This patch makes Splash correctly highlight the ‘convenience’ keyword.
2019-07-21 13:44:11 +02:00
John Sundell
370f685cb1
Support types and functions named with a leading underscore (#74)
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.
2019-07-17 10:57:44 +02:00
John Sundell
b1f77c9ff1
Fix highlighting for interpolated closure shorthand arguments (#75)
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.
2019-07-17 10:57:30 +02:00
John Sundell
c582abf0a4
Add test verifying property wrapper compatibility (#73)
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.
2019-06-18 13:37:57 +02:00
John Sundell
0b22fa3dcd
Fix highlighting for #available checks (#72)
This patch makes availability checks using `#available` highlight correctly,
by treating `#available` like a keyword.
2019-06-18 12:28:11 +02:00
John Sundell
d978081933
Add support for Swift 5.1’s opaque return types (#71)
This change adds support for the Swift 5.1 `some` keyword, which is used
to declare opaque return types.
2019-06-09 12:33:00 +02:00
John Sundell
6fcb458c63
Enable Splash to be compiled for iOS as a Swift Package (#70)
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)
2019-06-09 11:56:10 +02:00
John Sundell
ec13df124a
Correctly highlight generic return types (#69)
This change makes Splash correctly highlight generics that are returned
from a function.
2019-05-13 11:25:16 +02:00
John Sundell
4675ffe963
Fix highlighting for inout closure arguments (#68)
This patch makes Splash correctly highlight the `inout` keyword when
it appears as part of a closure argument definition.
2019-05-13 11:19:15 +02:00
John Sundell
30d6cacb7c
Makefile: Support Swift 5 toolchain for installation (#67) 2019-04-14 22:17:58 +02:00
John Sundell
d01f7a6b2f
Correctly highlight closure argument shorthands (#66)
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.
2019-04-14 22:17:47 +02:00
John Sundell
2b9e65e0d8
Fix highlighting for keywords used as generic function parameter labels (#65)
This patch fixes highlighting for parameter labels that also match a
keyword, when used within a generic function declaration.
2019-03-31 22:52:09 +02:00
John Sundell
c05038072a
Correctly highlight key paths passed as arguments (#64)
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.
2019-03-31 22:40:37 +02:00
John Sundell
f9cb0db662
README: Update Swift version to 5.0 2019-03-26 12:19:07 +01:00
John Sundell
3aa1a6dc99
Update Swift version to 5.0 (#63)
Swift 5 is now officially released, so it’s time to adopt it! :)
2019-03-26 12:18:32 +01:00
John Sundell
b9177c4104
Fix highlighting for nested escaping closures (#62)
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.
2019-03-24 11:35:33 +01:00
John Sundell
72837ce7f0
Correctly highlight the root level of a key path (#60)
When key path literals are used, Splash will now correctly highlight the
root level of that key path as a property, rather than as plain text.
2019-03-16 12:44:02 +01:00
John Sundell
2cdc99ce60
Correctly highlight generic parameters (#59)
This patch makes Splash highlight generics that appear as part of a
generic function’s parameter list in a correct way.
2019-03-16 12:41:53 +01:00
Agisilaos Tsaraboulidis
e3477a428e README: Bump up the number from 3 to 4 (#58)
With SplashMarkdown now there are 4 tools instead of 3
2019-03-15 20:58:35 +01:00
John Sundell
cfb33cf3e5
Minor README updates
- Add clarification that Splash is used on Swift by Sundell.
- Update installation instructions to reference Swift 4.2.
- Use more even dependency version.
2019-03-15 20:52:46 +01:00
John Sundell
8e7599150f
Add SplashMarkdown (#57)
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.
2019-03-15 20:24:53 +01:00
Marco Capano
60c06cc385 Adding support for rethrows keyword (#56) 2019-03-12 23:12:54 +01:00
Apokrupto
9485a4e762 Fixed comments for keyword and preprocessing (#55) 2019-03-12 12:04:21 +01:00