Skip to content

Commit

Permalink
transformer hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
JSerZANP committed Jul 6, 2024
1 parent 4078d64 commit 95c5dcd
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 41 deletions.
6 changes: 6 additions & 0 deletions packages/shaku-code-annotate-shiki-transformer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# shaku-code-annotate

## 0.2.1

### Patch Changes

- hotfix for the language alias

## 0.2.0

### Minor Changes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shaku-code-annotate-shiki-transformer",
"version": "0.2.0",
"version": "0.2.1",
"dependencies": {
"@types/hast": "^3.0.4",
"shaku-code-annotate-core": "^0.10.0",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import { expect, test } from "vitest";
import { getShakuHighlighters } from "../getHighlighters";
import rehypeShiki from "@shikijs/rehype";
import rehypeStringify from "rehype-stringify";
import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import { unified } from "unified";
import shakuCodeAnnotateShikiTransformer from "..";
import * as shiki from "shiki";
import { fetchProcessor } from "./util";

const snippets = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<pre class="shiki github-light shaku" style="background-color:#fff;color:#24292e" tabindex="0"><code><span class="line"></span><span class="line"><span style="color:#D73A49">#import</span><span style="color:#032F62"> &#x3C;Foundation/Foundation.h></span></span><span class="line"><span style="color:#6A737D">// @highlight</span></span><span class="line"><span style="color:#6A737D">// This is a single-line comment</span></span><span class="line"><span style="color:#6A737D">// ------</span></span><span class="line"><span style="color:#6A737D">// ^</span></span><span class="line"><span style="color:#6A737D">// [Hello World!]</span></span><span class="line"></span><span class="line"></span></code></pre>
<pre class="shiki github-light shaku" style="background-color:#fff;color:#24292e" tabindex="0"><code><span class="line"></span><span class="line"><span style="color:#D73A49">#import</span><span style="color:#032F62"> &#x3C;Foundation/Foundation.h></span></span><span class="line highlight"><span style="color:#6A737D">// This is a single-line comment</span></span><div class="shaku-underline shaku-underline-solid" style="left:3ch"><span class="shaku-underline-line" style="left:0ch">------</span></div><div class="shaku-callout" style="left:3ch"><span class="shaku-callout-arrow" style="left:1ch"></span><p>Hello World!</p></div><span class="line"></span><span class="line"></span></code></pre>
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export const commentPatterns: Record<string, RegExp> = {
awk: PatternHash,
ballerina: PatternDoubleSlash,
batch: PatternBatch,
bat: PatternBatch,
berry: PatternHash,
be: PatternHash,
bicep: PatternDoubleSlash,
blade:
/^(?<leadingSpaces>\s*)(?<markerStart>\{\{\-\-)(?<body>.*)(?<markerEnd>\-\-\}\})$/,
Expand All @@ -61,13 +63,18 @@ export const commentPatterns: Record<string, RegExp> = {
dart: PatternDoubleSlash,
dax: PatternDoubleSlash,
dockerfile: PatternHash,
docker: PatternHash,
"dream-maker": PatternDoubleSlash,
elixir: PatternHash,
elm: PatternDoubleDash,
erb: /^(?<leadingSpaces>\s*)(?<markerStart>\<%#)(?<body>.*)(?<markerEnd>%\>)$/,
erlang: PatternDoublePercentage,
erl: PatternDoublePercentage,

fish: PatternHash,
"f#": PatternDoubleSlash,
fsharp: PatternDoubleSlash,
fs: PatternDoubleSlash,
"git-commit": PatternHash,
glsl: PatternDoubleSlash,
gnuplot: PatternHash,
Expand All @@ -76,15 +83,19 @@ export const commentPatterns: Record<string, RegExp> = {
hack: PatternDoubleSlash,
haml: /^(?<leadingSpaces>\s*)(?<markerStart>-#)(?<body>.*)$/,
handlebars: PatternHBS,
hbs: PatternHBS,
haskell: PatternDoubleDash,
hs: PatternDoubleDash,
hcl: PatternHash,
hlsl: PatternDoubleSlash,
html: PatternXML,
cpp: PatternDoubleSlash,
"c#": PatternDoubleSlash,
cs: PatternDoubleSlash,
go: PatternDoubleSlash,
java: PatternDoubleSlash,
javascript: PatternJSWithJSX,
js: PatternJSWithJSX,
imba: PatternHash,
ini: PatternSemiColon,
properties: PatternHash,
Expand All @@ -107,13 +118,16 @@ export const commentPatterns: Record<string, RegExp> = {
make: PatternHash,
makefile: PatternHash,
markdown: PatternXML,
md: PatternXML,
marko: PatternXML,
mdx: /^(?<leadingSpaces>\s*)(?<markerStart>\{\/\*)(?<body>.*)(?<markerEnd>\*\/\})$/,
mermaid: /^(?<leadingSpaces>\s*)(?<markerStart>%%)(?<body>.*)$/,
nginx: PatternHash,
nim: PatternHash,
nix: PatternHash,
"objective-c": PatternDoubleSlash,
objc: PatternDoubleSlash,

"objective-cpp": PatternDoubleSlash,
ocaml:
/^(?<leadingSpaces>\s*)(?<markerStart>\(\*)(?<body>.*)(?<markerEnd>\*\))$/,
Expand All @@ -122,6 +136,7 @@ export const commentPatterns: Record<string, RegExp> = {
perl: PatternHash,
powerquery: PatternDoubleSlash,
powershell: PatternHash,
ps: PatternHash,
prisma: PatternDoubleSlash,
prolog: PatternPercentage,
proto: PatternDoubleSlash,
Expand Down Expand Up @@ -149,10 +164,13 @@ export const commentPatterns: Record<string, RegExp> = {
sparql: PatternHash,
stata: PatternAsterisk,
stylus: PatternDoubleSlash,
styl: PatternDoubleSlash,
svelte: PatternSFC,
python: PatternHash,
ruby: PatternHash,
rb: PatternHash,
rust: PatternDoubleSlash,
rs: PatternDoubleSlash,
sql: PatternDoubleDash,
"system-verilog": PatternDoubleSlash,
tcl: PatternHash,
Expand All @@ -163,6 +181,7 @@ export const commentPatterns: Record<string, RegExp> = {
swift: PatternDoubleSlash,
twig: /^(?<leadingSpaces>\s*)(?<markerStart>\{#)(?<body>.*)(?<markerEnd>#\})$/,
typescript: PatternJSWithJSX,
ts: PatternJSWithJSX,
vb: /^(?<leadingSpaces>\s*)(?<markerStart>\')(?<body>.*)$/,
verilog: PatternDoubleSlash,
vhdl: PatternDoubleDash,
Expand All @@ -171,12 +190,14 @@ export const commentPatterns: Record<string, RegExp> = {
vue: PatternSFC,
wasm: PatternDoubleSemiColon,
wenyan: /^(?<leadingSpaces>\s*)(?<markerStart>)(?<body>.*)$/,
文言: /^(?<leadingSpaces>\s*)(?<markerStart>)(?<body>.*)$/,
wgsl: PatternDoubleSlash,
wolfram:
/^(?<leadingSpaces>\s*)(?<markerStart>\(\*)(?<body>.*)(?<markerEnd>\*\))$/,
xml: PatternXML,
xsl: PatternXML,
yaml: PatternHash,
yml: PatternHash,
zenscript: PatternDoubleSlash,
jison: PatternDoubleSlash,
"ssh-config": PatternHash,
Expand Down
36 changes: 18 additions & 18 deletions packages/shaku-code-annotate-shiki-transformer/src/defaultCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1530,10 +1530,10 @@ export const supportedLangs = [
"astro",
"awk",
"ballerina",
// "bat",
"bat",
"batch",
"berry",
// "be",
"be",
// "bibtex",
"bicep",
"blade",
Expand All @@ -1551,25 +1551,25 @@ export const supportedLangs = [
"cpp",
"crystal",
"c#",
// "cs",
"cs",
"css",
"cue",
"d",
"dart",
"dax",
// "diff", // nothing to test
// "docker",
"docker",
"dockerfile",
"dream-maker",
"elixir",
"elm",
"erb",
"erlang",
// "erl",
"erl",
"fish",
// "fsharp",
"fsharp",
"f#",
// "fs",
"fs",
// "gdresource",
// "gdscript",
// "gdshader",
Expand All @@ -1584,9 +1584,9 @@ export const supportedLangs = [
"hack",
"haml",
"handlebars",
// "hbs",
"hbs",
"haskell",
// "hs",
"hs",
"hcl",
"hlsl",
"html",
Expand Down Expand Up @@ -1619,7 +1619,7 @@ export const supportedLangs = [
"make",
"makefile",
"markdown",
// "md",
"md",
"marko",
"matlab",
"mdx",
Expand All @@ -1628,7 +1628,7 @@ export const supportedLangs = [
"nim",
"nix",
"objective-c",
// "objc",
"objc",
"objective-cpp",
"ocaml",
"pascal",
Expand All @@ -1638,7 +1638,7 @@ export const supportedLangs = [
// "postcss",
"powerquery",
"powershell",
// "ps",
"ps",
// "ps1",
"prisma",
"prolog",
Expand All @@ -1657,9 +1657,9 @@ export const supportedLangs = [
"riscv",
// "rst",
"ruby",
// "rb",
"rb",
"rust",
// "rs",
"rs",
"sas",
"sass",
"scala",
Expand All @@ -1680,7 +1680,7 @@ export const supportedLangs = [
"ssh-config",
"stata",
"stylus",
// "styl",
"styl",
"svelte",
"swift",
"system-verilog",
Expand All @@ -1692,7 +1692,7 @@ export const supportedLangs = [
"turtle",
"twig",
"typescript",
// "ts",
"ts",
// "v",
"vb",
// "cmd",
Expand All @@ -1705,12 +1705,12 @@ export const supportedLangs = [
"vue",
"wasm",
"wenyan",
// "文言",
"文言",
"wgsl",
"wolfram",
"xml",
"xsl",
"yaml",
// "yml",
"yml",
"zenscript",
] as const;
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type ShakuUpdatesForLine = Map<number, Array<ShakuUpdate>>;
type Options = {
/**
* whether or not to escape the annotation
* use it if you want to support markdown in annotation
* @default false
*/
useDangerousRawHtml?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"skipLibCheck": true,
"noEmit": true,
"strict": true,
"target": "ES2015"
"target": "ES2018"
},
"exclude": ["node_modules"]
}

0 comments on commit 95c5dcd

Please sign in to comment.