-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Archive: GenSvgImg function from Token.wl.
(cherry picked from commit d5e411ac1cbc5ddbe222c3579c136c1162f96ae2)
- Loading branch information
1 parent
2c36473
commit 066f3e3
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
(* ::Package:: *) | ||
(*Archives*) | ||
|
||
(* Wolfram Language Server Archived Functions *) | ||
(* Author: kenkangxgwe <kenkangxgwe_at_gmail.com>, | ||
huxianglong <hxianglong_at_gmail.com> | ||
*) | ||
|
||
|
||
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[] |