shiki testing
This commit is contained in:
parent
4fbb038c0d
commit
9c1f293a2a
|
@ -7,6 +7,7 @@ import { markdownConfig } from "./src/config/io/markdown.ts";
|
|||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
markdown: markdownConfig,
|
||||
integrations: [
|
||||
solidJs({
|
||||
devtools: true,
|
||||
|
@ -14,5 +15,4 @@ export default defineConfig({
|
|||
mdx(),
|
||||
pagefind(),
|
||||
],
|
||||
markdown: markdownConfig,
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import type { Parent, Node } from "unist";
|
||||
import { visit, CONTINUE, SKIP } from "unist-util-visit";
|
||||
import { fromHtml } from "hast-util-from-html";
|
||||
import type { Root, Element } from "hast";
|
||||
import type { Root } from "hast";
|
||||
import type {
|
||||
AstroMarkdownOptions,
|
||||
MarkdownProcessor,
|
||||
|
@ -69,27 +69,16 @@ const rehypeRewriteTypelinks: RehypePlugin<[]> = () => {
|
|||
};
|
||||
};
|
||||
|
||||
const shikiRewriteTypelinks = (): ShikiTransformer => {
|
||||
return {
|
||||
const shikiRewriteTypelinks: ShikiTransformer = {
|
||||
name: "rewrite-typelinks",
|
||||
preprocess(code, _options) {
|
||||
const qtRegExp = /QT_(\w+)/g;
|
||||
const qsRegExp = /QS_(\w+)/g;
|
||||
postprocess(code, _options) {
|
||||
// WARN: need to change the code link identifier to this
|
||||
// const hasTypelinks = code.search(/TYPE99(\w+.)99TYPE/g) !== -1;
|
||||
const hasQTLink = code.search(qtRegExp) !== -1;
|
||||
const hasQSLink = code.search(qsRegExp) !== -1;
|
||||
const regExp = /TYPE99(\w+.)99TYPE/g;
|
||||
const hasTypelinks = code.search(regExp) !== -1;
|
||||
console.log(hasTypelinks);
|
||||
|
||||
if (hasQTLink) {
|
||||
code.replace(qtRegExp, (_full: string, match: string) => {
|
||||
const linkObject = getQMLTypeLinkObject(match);
|
||||
const link = getQMLTypeLink(linkObject);
|
||||
return `<a href=${link}>${linkObject.name ?? ""}</a>`;
|
||||
});
|
||||
}
|
||||
|
||||
if (hasQSLink) {
|
||||
code.replace(qsRegExp, (_full: string, match: string) => {
|
||||
if (hasTypelinks) {
|
||||
code.replace(regExp, (_full: string, match: string) => {
|
||||
const linkObject = getQMLTypeLinkObject(match);
|
||||
const link = getQMLTypeLink(linkObject);
|
||||
return `<a href=${link}>${linkObject.name ?? ""}</a>`;
|
||||
|
@ -97,14 +86,13 @@ const shikiRewriteTypelinks = (): ShikiTransformer => {
|
|||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const markdownConfig: AstroMarkdownOptions = {
|
||||
syntaxHighlight: "shiki",
|
||||
shikiConfig: {
|
||||
theme: "material-theme-ocean",
|
||||
wrap: true,
|
||||
transformers: [shikiRewriteTypelinks()],
|
||||
transformers: [shikiRewriteTypelinks],
|
||||
},
|
||||
remarkPlugins: [[remarkAlert, { legacyTitle: true }]],
|
||||
rehypePlugins: [
|
||||
|
|
|
@ -3,9 +3,11 @@ layout: "@layouts/ConfigLayout.astro"
|
|||
title: "Configuration"
|
||||
description: "Configuring the shell"
|
||||
---
|
||||
import MD_Title from "@components/MD_Title.tsx"
|
||||
|
||||
import MD_Title from "@components/MD_Title.tsx";
|
||||
|
||||
# <MD_Title titleVar={1}> {frontmatter.title} </MD_Title>
|
||||
|
||||
You should start with the [Introduction](./configuration/intro) which will guide you
|
||||
through the basics of QML by creating a simple topbar with a clock.
|
||||
|
||||
|
|
Loading…
Reference in a new issue