1
0
silverbullet/packages/web/style.ts

48 lines
1.9 KiB
TypeScript
Raw Normal View History

import { HighlightStyle, tags as t } from "@codemirror/highlight";
import * as ct from "./customtags";
2022-04-11 18:34:09 +00:00
import { MDExt } from "./markdown_ext";
2022-04-11 18:34:09 +00:00
export default function highlightStyles(mdExtension: MDExt[]) {
return HighlightStyle.define([
{ tag: t.heading1, class: "h1" },
{ tag: t.heading2, class: "h2" },
{ tag: t.heading3, class: "h3" },
{ tag: t.link, class: "link" },
{ tag: t.meta, class: "meta" },
{ tag: t.quote, class: "quote" },
{ tag: t.monospace, class: "code" },
{ tag: t.url, class: "url" },
{ tag: ct.WikiLinkTag, class: "wiki-link" },
{ tag: ct.WikiLinkPageTag, class: "wiki-link-page" },
{ tag: ct.TaskTag, class: "task" },
{ tag: ct.TaskMarkerTag, class: "task-marker" },
2022-04-24 16:06:34 +00:00
{ tag: ct.CodeInfoTag, class: "code-info" },
2022-04-11 18:34:09 +00:00
{ tag: ct.CommentTag, class: "comment" },
{ tag: ct.CommentMarkerTag, class: "comment-marker" },
{ tag: t.emphasis, class: "emphasis" },
{ tag: t.strong, class: "strong" },
{ tag: t.atom, class: "atom" },
{ tag: t.bool, class: "bool" },
{ tag: t.url, class: "url" },
{ tag: t.inserted, class: "inserted" },
{ tag: t.deleted, class: "deleted" },
{ tag: t.literal, class: "literal" },
2022-04-24 16:06:34 +00:00
{ tag: t.keyword, class: "keyword" },
2022-04-11 18:34:09 +00:00
{ tag: t.list, class: "list" },
{ tag: t.definition, class: "li" },
{ tag: t.string, class: "string" },
{ tag: t.number, class: "number" },
{ tag: [t.regexp, t.escape, t.special(t.string)], class: "string2" },
{ tag: t.variableName, class: "variableName" },
2022-04-24 16:06:34 +00:00
{ tag: t.typeName, class: "typeName" },
2022-04-11 18:34:09 +00:00
{ tag: t.comment, class: "comment" },
{ tag: t.invalid, class: "invalid" },
{ tag: t.processingInstruction, class: "meta" },
// { tag: t.content, class: "tbl-content" },
2022-04-11 18:34:09 +00:00
{ tag: t.punctuation, class: "punctuation" },
...mdExtension.map((mdExt) => {
return { tag: mdExt.tag, ...mdExt.styles };
}),
]);
}