miestrode / sourcerer

Typst package for displaying stylized source code blocks, with some extra features.
MIT License
3 stars 0 forks source link

Add a way to use custom syntaxes #3

Open citorva opened 1 month ago

citorva commented 1 month ago

The raw function allows to use custom or less known language through the syntaxes which takes a path to a sublime-syntax file. It looks good add a same argument to allows the use of sourcerer with custom syntaxes

miestrode commented 1 month ago

Hello! I agree, and am currently working on this.

citorva commented 3 weeks ago

After using the module, this issue was indeed a non-issue because the syntax is made from a raw element and the lang parameter is just a description of the code label.

miestrode commented 3 weeks ago

This is indeed possible with the current release. I will still be adding native support for this, for convenience and future-proofing.

citorva commented 2 weeks ago

I have rechecked and sourcerer lost syntax colorization with custom syntaxes. I reopen then the issue

citorva commented 2 weeks ago

A temporary working workaround was replacing the last raw call with this code:

  let source_args = (
    lang: source.lang
  )

  if source.has("theme") {
    source_args.insert("theme", source.theme)
  }

  if source.has("syntaxes") {
    source_args.insert("syntaxes", source.syntaxes)
  }

  raw(block: true, ..source_args, unlabelled-source)