Skip to content

Custom syntax highlighting #373

Closed
Closed

Description

@imbrem

Would it be possible to support syntax highlighting for custom languages?

Activity

  1. SaitoAtsushi commented on Mar 28, 2023

    @SaitoAtsushi

    I found a good example in code comment.

    /// #show raw.where(lang: "mydsl"): it => {
    /// let sum = 0
    /// for part in it.text.split("+") {
    /// sum += int(part.trim())
    /// }
    /// sum
    /// }
    ///
    /// ```mydsl
    /// 1 + 2 + 3 + 4 + 5
    /// ```

    We can imitate this.

    Keyword emphasis can be written like following:

    #show raw.where(lang: "foo_lang"): it => [
        #show regex("\b(for|to|begin|end)\b") : keyword => text(weight:"bold", keyword)
        #it
    ]
    
    ```foo_lang
    for i=1 to 10
    begin
        print(i)
    end
    ```
    
  2. imbrem commented on Mar 28, 2023

    @imbrem
    Author

    Thanks, I didn't think of that! Guess I'll go ahead and close this then.

  3. lucifer1004 commented on Apr 13, 2023

    @lucifer1004
    Contributor

    Is it possible to provide custom Sublime syntax files to support extra languages? The workaround above can only deal with some naive cases.

  4. PgBiel commented on Apr 13, 2023

    @PgBiel
    Contributor

    Perhaps raw should have some theme dict option to override the default THEME used by raw (allowing a theme to be specified in Typst, even)? (Paging @laurmaedje)

  5. reopened this on Apr 13, 2023
  6. laurmaedje commented on Apr 13, 2023

    @laurmaedje
    Member

    Perhaps raw should have some theme dict option to override the default THEME used by raw (allowing a theme to be specified in Typst, even)? (Paging @laurmaedje)

    Yes, I planned on having something like this. Not sure how it would be specified. The two options I see are a dictionary that statically specifies the theme or a function that gets a piece of text + its textmate scopes and is free to do whatever.

  7. added
    feature request
    text
    on May 9, 2023
  8. LaurenzV commented on Sep 2, 2023

    @LaurenzV
    Collaborator

    This feature already exists now, right? Can this issue be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requesttext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions