Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds StringSyntaxHighlighter #363

Merged
merged 8 commits into from
Mar 23, 2024
Merged

Adds StringSyntaxHighlighter #363

merged 8 commits into from
Mar 23, 2024

Conversation

simonbs
Copy link
Owner

@simonbs simonbs commented Mar 16, 2024

This PR adds StringSyntaxHighlighter which can be used to syntax highlight a string without needing to create a TextView.

let syntaxHighlighter = StringSyntaxHighlighter(
    theme: TomorrowTheme(),
    language: .javaScript
)
let attributedString = syntaxHighlighter.syntaxHighlight(
  """
  function fibonacci(num) {
    if (num <= 1) {
      return 1
    }
    return fibonacci(num - 1) + fibonacci(num - 2)
  }
  """
)

The StringSyntaxHighlighter is showcased in the example project living in the simonbs/RunestoneSnippetExample repository.

The PR is marked as a draft while I verify that the StringSyntaxHighlighter addresses a need.

@simonbs simonbs self-assigned this Mar 16, 2024
@simonbs simonbs marked this pull request as ready for review March 23, 2024 12:54
@simonbs simonbs merged commit 9a48654 into main Mar 23, 2024
9 checks passed
@simonbs simonbs deleted the feature/stringsyntaxhighlighter branch March 23, 2024 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant