diff --git a/WolframLanguageServer/Archives.wl b/WolframLanguageServer/Archives.wl new file mode 100644 index 0000000..bfa6595 --- /dev/null +++ b/WolframLanguageServer/Archives.wl @@ -0,0 +1,51 @@ +(* ::Package:: *) +(*Archives*) + +(* Wolfram Language Server Archived Functions *) +(* Author: kenkangxgwe , + huxianglong +*) + + +BeginPackage["WolframLanguageServer`Archives`"] +ClearAll[Evaluate[Context[] <> "*"]] + + +Begin["`Private`"] +ClearAll[Evaluate[Context[] <> "*"]] + + +(* ::Section:: *) +(*GenSvgImg*) + + +Options[GenSvgImg] := { + "Theme" -> "dark", + "TempDir" -> $TemporaryDirectory +} + + +GenSvgImg[token_String, width_Integer, o:OptionsPattern[]] := Module[ + { + tempImgPath, background, theme, tempDir + }, + + {theme, tempImgPath} = OptionValue[GenSvgImg, {o}, {"Theme", "TempDir"}]; + background = If[theme === "light", Black, White]; + tempImgPath = FileNameJoin[{tempDir, CreateUUID[] <> ".svg"}]; + (* Export[tempImgPath, Style[#, background]& @* (#::usage&) @ Symbol[token]]; *) + Export[tempImgPath, + Style[ + Pane[StringReplace[#, StartOfLine -> "\[FilledSmallCircle] "], .85*width, Alignment -> Left], FontSize -> 13, background + ]& @ ToExpression[token <> "::usage"] + ]; + (* "![" <> "test" <> "](" <> tempImgPath <> ")" <> "\n" <> "```" <> StringRepeat[StringJoin[CharacterRange["a", "z"]], 4] <> "```" *) + "![" <> "test" <> "](" <> tempImgPath <> ")" <> "\n\n" <> "```typescript" <> StringRepeat[StringRepeat["\t", 50] <> "\n", 20] <> "```" <> "\n\n" + (* "![" <> ToString[(#::usage&) @ Symbol[token]] <> "](" <> tempImgPath <> ")" *) +] + + +End[] + + +EndPackage[] \ No newline at end of file