mirror of
https://github.com/typst/typst
synced 2025-08-12 22:27:56 +08:00
Merge 4f6712e3b30b6af56f3809a942a4b06d0e859c2d into 5661c20580584d86897d139cdeffd6fb1a9a6d5c
This commit is contained in:
commit
a5f371ea09
@ -14,8 +14,8 @@ use typst_library::model::{
|
|||||||
RefElem, StrongElem, TableCell, TableElem, TermsElem,
|
RefElem, StrongElem, TableCell, TableElem, TermsElem,
|
||||||
};
|
};
|
||||||
use typst_library::text::{
|
use typst_library::text::{
|
||||||
HighlightElem, LinebreakElem, OverlineElem, RawElem, RawLine, SpaceElem, StrikeElem,
|
HighlightElem, LinebreakElem, OverlineElem, RawElem, RawLine, SmallcapsElem,
|
||||||
SubElem, SuperElem, UnderlineElem,
|
SpaceElem, StrikeElem, SubElem, SuperElem, UnderlineElem,
|
||||||
};
|
};
|
||||||
use typst_library::visualize::ImageElem;
|
use typst_library::visualize::ImageElem;
|
||||||
|
|
||||||
@ -47,6 +47,7 @@ pub fn register(rules: &mut NativeRuleMap) {
|
|||||||
rules.register(Html, OVERLINE_RULE);
|
rules.register(Html, OVERLINE_RULE);
|
||||||
rules.register(Html, STRIKE_RULE);
|
rules.register(Html, STRIKE_RULE);
|
||||||
rules.register(Html, HIGHLIGHT_RULE);
|
rules.register(Html, HIGHLIGHT_RULE);
|
||||||
|
rules.register(Html, SMALLCAPS_RULE);
|
||||||
rules.register(Html, RAW_RULE);
|
rules.register(Html, RAW_RULE);
|
||||||
rules.register(Html, RAW_LINE_RULE);
|
rules.register(Html, RAW_LINE_RULE);
|
||||||
|
|
||||||
@ -390,6 +391,20 @@ const STRIKE_RULE: ShowFn<StrikeElem> =
|
|||||||
const HIGHLIGHT_RULE: ShowFn<HighlightElem> =
|
const HIGHLIGHT_RULE: ShowFn<HighlightElem> =
|
||||||
|elem, _, _| Ok(HtmlElem::new(tag::mark).with_body(Some(elem.body.clone())).pack());
|
|elem, _, _| Ok(HtmlElem::new(tag::mark).with_body(Some(elem.body.clone())).pack());
|
||||||
|
|
||||||
|
const SMALLCAPS_RULE: ShowFn<SmallcapsElem> = |elem, _, styles| {
|
||||||
|
Ok(HtmlElem::new(tag::span)
|
||||||
|
.with_attr(
|
||||||
|
attr::style,
|
||||||
|
if elem.all.get(styles) {
|
||||||
|
"font-variant-caps: all-small-caps"
|
||||||
|
} else {
|
||||||
|
"font-variant-caps: small-caps"
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.with_body(Some(elem.body.clone()))
|
||||||
|
.pack())
|
||||||
|
};
|
||||||
|
|
||||||
const RAW_RULE: ShowFn<RawElem> = |elem, _, styles| {
|
const RAW_RULE: ShowFn<RawElem> = |elem, _, styles| {
|
||||||
let lines = elem.lines.as_deref().unwrap_or_default();
|
let lines = elem.lines.as_deref().unwrap_or_default();
|
||||||
|
|
||||||
|
@ -7,5 +7,6 @@
|
|||||||
<body>
|
<body>
|
||||||
<p><s>Struck</s> <mark>Highlighted</mark> <span style="text-decoration: underline">Underlined</span> <span style="text-decoration: overline">Overlined</span></p>
|
<p><s>Struck</s> <mark>Highlighted</mark> <span style="text-decoration: underline">Underlined</span> <span style="text-decoration: overline">Overlined</span></p>
|
||||||
<p><span style="text-decoration: overline"><span style="text-decoration: underline"><mark><s>Mixed</s></mark></span></span></p>
|
<p><span style="text-decoration: overline"><span style="text-decoration: underline"><mark><s>Mixed</s></mark></span></span></p>
|
||||||
|
<p><span style="font-variant-caps: small-caps">Small Caps</span> <span style="font-variant-caps: all-small-caps">All Small Caps</span></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -91,3 +91,6 @@ We can also specify a customized value
|
|||||||
#overline[Overlined]
|
#overline[Overlined]
|
||||||
|
|
||||||
#(strike, highlight, underline, overline).fold([Mixed], (it, f) => f(it))
|
#(strike, highlight, underline, overline).fold([Mixed], (it, f) => f(it))
|
||||||
|
|
||||||
|
#smallcaps[Small Caps]
|
||||||
|
#smallcaps(all: true)[All Small Caps]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user