Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
"tschüß",
"TSCHÜSS",
"ὈΔΥΣΣΕΎΣ",
"ὀδυσσεύς"
"ὀδυσσεύς",
"commonmark",
"strikethroughs"
],
}
],
Expand Down
4 changes: 4 additions & 0 deletions docs/astro/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ export default defineConfig({
label: "Timer",
slug: "reference/timer",
},
{
label: "Styled Text",
slug: "reference/styled-text",
},
],
},
{
Expand Down
57 changes: 57 additions & 0 deletions docs/astro/src/content/docs/reference/styled-text.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: Styled Text
description: Styled Text
---

import CodeSnippetMD from "@slint/common-files/src/components/CodeSnippetMD.astro";

The `StyledText` type renders text with various styling and interactive properties, such as bolded, underlined and colored sections as well as HTTP links. It is based on a subset of the [commonmark](https://commonmark.org/) spec.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is under types and properties but it looks like the reference documentation for the element (as the quoted text says).

I suggest to either fold this into the styled text element reference docs or cross-link between them and disambiguate that this is about the property type, not the element. A way of disambiguating would be to use the actual property type in this file. But my preference is folding them for now.


<CodeSnippetMD imagePath="/src/assets/generated/styled-text-example.png" scale="3" imageWidth="200" imageHeight="200" imageAlt='Styled Text Example'>
```slint
export component Example inherits Window {
width: 200px;
height: 200px;
StyledText {
text: @markdown("This is a piece of <u>Styled Text</u>\nwith a red value inserted: <font color=\"red\">{}</font>", 55);
}
}
```
</CodeSnippetMD>


## Features

Styled Text supports the following features:

Feature | Method
---------------|-------
Italics | Builtin
Strikethroughs | Builtin
Inline code | Builtin
Links | Builtin
Ordered and unordered lists | Builtin
Underlines | `<u>` HTML tag
Text Colors |`<font color="...">` HTML tags

### Currently Unsupported


Feature |
-----------------|
Headings |
Images |
Tables |
Block Quotes |
Subscripts |
Superscripts |
Horizontal Rules |
Footnotes |
Math expressions |
Other HTML tags |

## Interpolation

Text can be interpolated into strings for styled text with the `@markdown` macro. For example, `@markdown("Hello *{}*", "World")` becomes `"Hello *World*"`.

Any text passed as an argument to the macro will be escaped, for example `@markdown("Hello {}", "*World*")` will become `"Hello \*World\*"`
2 changes: 1 addition & 1 deletion tools/docsnapper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ keywords = ["viewer", "gui", "ui", "toolkit"]

[dependencies]
i-slint-compiler = { workspace = true }
i-slint-core = { workspace = true }
i-slint-core = { workspace = true, features = ["experimental-rich-text"] }
slint-interpreter = { workspace = true, features = ["display-diagnostics", "compat-1-2", "internal", "accessibility"] }
i-slint-renderer-skia = { workspace = true, features = ["default", "wayland"] }

Expand Down
11 changes: 6 additions & 5 deletions tools/docsnapper/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,12 @@ fn init_compiler(args: &Cli) -> slint_interpreter::Compiler {
compiler.set_style(style.clone());
}

compiler.compiler_configuration(i_slint_core::InternalToken).components_to_generate =
match &args.component {
Some(component) => ComponentSelection::Named(component.clone()),
None => ComponentSelection::LastExported,
};
let config = compiler.compiler_configuration(i_slint_core::InternalToken);
config.components_to_generate = match &args.component {
Some(component) => ComponentSelection::Named(component.clone()),
None => ComponentSelection::LastExported,
};
config.enable_experimental = true;

compiler
}
Loading