1
0
silverbullet/web/style.ts

57 lines
2.5 KiB
TypeScript
Raw Normal View History

import { HighlightStyle } from "../common/deps.ts";
import { tagHighlighter, tags as t } from "./deps.ts";
import * as ct from "../common/markdown_parser/customtags.ts";
import { MDExt } from "../common/markdown_parser/markdown_ext.ts";
2022-04-11 18:34:09 +00:00
export default function highlightStyles(mdExtension: MDExt[]) {
2022-09-13 06:41:01 +00:00
tagHighlighter;
return HighlightStyle.define([
2022-08-02 12:40:04 +00:00
{ tag: t.heading1, class: "sb-h1" },
{ tag: t.heading2, class: "sb-h2" },
{ tag: t.heading3, class: "sb-h3" },
{ tag: t.link, class: "sb-link" },
{ tag: t.meta, class: "sb-meta" },
{ tag: t.quote, class: "sb-quote" },
{ tag: t.monospace, class: "sb-code" },
{ tag: t.url, class: "sb-url" },
{ tag: ct.WikiLinkTag, class: "sb-wiki-link" },
{ tag: ct.WikiLinkPageTag, class: "sb-wiki-link-page" },
{ tag: ct.CommandLinkTag, class: "sb-command-link" },
{ tag: ct.CommandLinkNameTag, class: "sb-command-link-name" },
2023-07-24 17:54:31 +00:00
{ tag: ct.AttributeTag, class: "sb-frontmatter" },
{ tag: ct.AttributeNameTag, class: "sb-atom" },
2022-08-02 12:40:04 +00:00
{ tag: ct.TaskTag, class: "sb-task" },
{ tag: ct.TaskMarkerTag, class: "sb-task-marker" },
{ tag: ct.CodeInfoTag, class: "sb-code-info" },
{ tag: ct.CommentTag, class: "sb-comment" },
{ tag: ct.CommentMarkerTag, class: "sb-comment-marker" },
{ tag: ct.Highlight, class: "sb-highlight" },
{ tag: t.emphasis, class: "sb-emphasis" },
{ tag: t.strong, class: "sb-strong" },
{ tag: t.atom, class: "sb-atom" },
{ tag: t.bool, class: "sb-bool" },
{ tag: t.url, class: "sb-url" },
{ tag: t.inserted, class: "sb-inserted" },
{ tag: t.deleted, class: "sb-deleted" },
{ tag: t.literal, class: "sb-literal" },
{ tag: t.keyword, class: "sb-keyword" },
{ tag: t.list, class: "sb-list" },
// { tag: t.def, class: "sb-li" },
{ tag: t.string, class: "sb-string" },
{ tag: t.number, class: "sb-number" },
{ tag: [t.regexp, t.escape, t.special(t.string)], class: "sb-string2" },
{ tag: t.variableName, class: "sb-variableName" },
{ tag: t.typeName, class: "sb-typeName" },
2022-12-05 12:05:48 +00:00
{ tag: t.strikethrough, class: "sb-strikethrough" },
2022-08-02 12:40:04 +00:00
{ tag: t.comment, class: "sb-comment" },
{ tag: t.invalid, class: "sb-invalid" },
{ tag: t.processingInstruction, class: "sb-meta" },
{ tag: t.punctuation, class: "sb-punctuation" },
{ tag: ct.DirectiveTag, class: "sb-directive" },
2022-08-29 14:48:52 +00:00
{ tag: ct.HorizontalRuleTag, class: "sb-hr" },
2022-04-11 18:34:09 +00:00
...mdExtension.map((mdExt) => {
2022-08-29 14:16:55 +00:00
return { tag: mdExt.tag, ...mdExt.styles, class: mdExt.className };
2022-04-11 18:34:09 +00:00
}),
]);
}