Mc-Zen / tidy

A documentation generator for Typst in Typst.
https://typst.app/universe/package/tidy
MIT License
49 stars 2 forks source link

raw elements in examples are explicitly set to `block: true` #21

Closed SillyFreak closed 2 months ago

SillyFreak commented 2 months ago

Reproducing example:

#import "@preview/tidy:0.3.0"

#let module = ````
/// #example(```
/// [a #raw("foo") b]
/// ```)
let x = none
````.text

#let module = tidy.parse-module(
  module,
)
#tidy.show-module(
  module,
  sort-functions: none,
  style: tidy.styles.minimal,
)

This uses #raw("foo") in an example. By default, this would not result in inline raw content, but due to this line it becomes a block. If I understand the intent behind it correctly, I think this could go here instead.

Mc-Zen commented 2 months ago

Oh yes, this is pity. I didn't think about raw elements occuring in the rendered output. Your suggested fix looks good. For now, until a new version is released, you could work around that by specifying


#let module = tidy.parse-module(
  module,
  preamble: "set raw(block: false);"
)

Thanks for reporting!

SillyFreak commented 2 months ago

thanks, will try that!

SillyFreak commented 2 months ago

I just noticed that lang has basically the same issue: https://github.com/Mc-Zen/tidy/blob/main/src/show-example.typ#L38

Mc-Zen commented 2 months ago

Ah yes, I will fix this along the way

Mc-Zen commented 2 months ago

Both issues should be fixed now. These two examples

#show-example(`a #raw("foo") b`, mode: "markup")
#show-example(`#raw("#import")`, mode: "markup")

produce

image