Folo icon indicating copy to clipboard operation
Folo copied to clipboard

Automatically detect code language in reading mode for better highlighting

Open Ray-D-Song opened this issue 11 months ago • 5 comments

Clear and concise description of the problem

In reading mode, mozilla/readability causes the code highlighting effect and language annotation attributes to disappear, but I noticed that shiki still highlights the content. It would be better if the language could be automatically detected before highlighting.

Suggested solution

In the past, I ported guesslang, a library that detects the programming language of source code through deep learning, to run in the browser using TensorFlow.js.
I added the esm format and web worker calls to it and used it in a production environment. You can also refer to this online demo:

https://ray-d-song.github.io/guesslang-js/

Alternative

No response

Additional context

No response

Validations

  • [x] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • [x] This issue is valid

Ray-D-Song avatar Jan 07 '25 08:01 Ray-D-Song

https://www.npmjs.com/package/@vscode/vscode-languagedetection

PrinOrange avatar Jan 07 '25 11:01 PrinOrange

Yes, initially my goal was also to use the language detection module in vscode, but this library relies on node.js, while follow needs to run in a browser.

但为君故 @.***>于2025年1月7日 周二下午7:56写道:

@.***/vscode-languagedetection

— Reply to this email directly, view it on GitHub https://github.com/RSSNext/Follow/issues/2490#issuecomment-2575102339, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARCC3QFJHIIJAE6NY5K45AL2JO6GRAVCNFSM6AAAAABUXGLHYGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNZVGEYDEMZTHE . You are receiving this because you authored the thread.Message ID: @.***>

Ray-D-Song avatar Jan 07 '25 12:01 Ray-D-Song

https://www.npmjs.com/package/@vscode/vscode-languagedetection

At the same time, I believe that applications providing PWA functionality should have some offline capabilities through service workers.

Ray-D-Song avatar Jan 07 '25 12:01 Ray-D-Song

It looks like vscode-languagedetection can run in the browser environment

https://www.npmjs.com/package/@vscode/vscode-languagedetection#advanced-options

hyoban avatar Apr 17 '25 04:04 hyoban