Closed 7sDream closed 2 weeks ago
It is fine to add such a feature, but I will suggest that we should provide more programmatical way to make it. We could add a command that expose the entire summary as a json file, which can be read by programs friendly.
For simple needs (specifically, extract all font files used in the document from my font library), a plain text file with one font per line is actually easier to handle. If summary JSON is the only option, users would have to write code to process it themselves. But not everyone using Typst to write content is a technical person, right?
If the user is tech-savvy and requires information beyond just a list of font files, the JSON format is indeed a better (and more feature-rich) option. I'll see if I can add that functionality along the way.
For simple needs (specifically, extract all font files used in the document from my font library), a plain text file with one font per line is actually easier to handle. If summary JSON is the only option, users would have to write code to process it themselves. But not everyone using Typst to write content is a technical person, right?
Let us think of our possible workflow:
The boring work emerges at the step 4. This should mean that we have to open the summary page, and click the button for a list of used fonts, and update the font bundle according to the list. Therefore, it should be better to have some pipeline to make life easier, like that:
// tasks.json
{
{ name: "update-font-bundle", steps: [
{ "command": "shell", args: ["myscript ${input:fontList}"], "inputs": [
{
"id": "fontList",
"type": "command",
"command": "tinymist.getSummary",
"args": ["${file}"]
} },
] }
}
I understand you worries, but I still prefer to provide these information without having to perform any action in the UI. If it is hard to use by non-technical people, they can require some specialized commands, e.g. one that outputs a list of used fonts separated by newline.
Very reasonable.
Given my limited experience in developing VSCode extensions, particularly with the commands aspect, I prefer to avoid hastily writing this feature, which may mess the codebase up.
For now, I can continue using my branch locally, and will eagerly anticipate the landing of this extension command in the future.
I rethink it a bit, and make a small summary (todo list) from above discussion.
Document Metrics
to ensure stable interface for users in a separated PR.
This PR can be merged with some minor changes. The current implementation doesn't look bad but I would like to change it a bit.
json
or csv
.csv
, it is okay to have a builtin filter, like FS Only
, but I want to make it more dumb so to ensure consistency with the command used by VSCode task or Neovim scripting:
camelCase
csv headers.name
style
, weight
, stretch
location
: enumerated, either fileSystem
or memory
.path
: Empty if the source is memory
. It must be absolute.<input type="checkbox">
.location=fileSystem
, rendered as <select>/<option>
.Wow, thanks for the clear summary list.
I can make these nice changes, but I've been occupied with other daily work things lately.
I'll likely come back to it in a few days!
Changes:
csv-stringify
libraryThings for discussion:
select[multiple]
is a multi-row box. Even withsize: 1
, it seems less aesthetically pleasing when displayed inline. Moreover, it requires holding down Ctrl
/Command
for multiple selections, which seems somewhat cumbersome. So, I temporarily still display the location
filter as several input[type="checkbox"]
. Any better options here? Would it be worth implementing a combo box with dropdown checkboxes specially for this?The default appearance of select[multiple] is a multi-row box. Even with
size: 1
, it seems less aesthetically pleasing when displayed inline. Moreover, it requires holding down Ctrl/Command for multiple selections, which seems somewhat cumbersome. So, I temporarily still display the location filter as several input[type="checkbox"]. Any better options here? Would it be worth implementing a combo box with dropdown checkboxes specially for this?
I think it is already nice. Location with [ ] FS [ ] Memory
allows us to select both or neither, which looks more flexible. This will not block merging.
About the export command, do we only need to support JSON format for now? I briefly looked at VSCode's extension command documentation last night, and I think I can add it in this PR, after we finish the GUI part.
I personally think export a csv by command is not quite useful, so we don't have to add a format option to the export command. When one makes some scripting, some input in json format is usually better than one in csv format.
I tested locally. It looks pretty well.
This PR adds a "Copy" icon to the top right corner of the font list card, in the VSCode extension's summary page:
Clicking it opens a font list export panel, which can export the list of fonts as plain text:
By default, only the paths of external font files are exported.
The options above can control whether to include Typst built-in fonts and whether to add extra information such as font names:
Click the "Copy" button at the bottom to perform the copy.
This feature fully from a personal need of mine. Upon discovering that tinymist already had a feature of showing document font lists, I think implement it here may save my coding time(And it's true).
If the author also finds this feature useful, I am more than happy to polish the code based on review comments.
If you feel this feature is not suitable for the tinymist extension, please feel free to close the PR.