-
-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v4.x] New code highlighter #296
Comments
The latest Shiki v1.15.0 has been introduced experimental JavaScript RegExp Engine. This may become a huge step for this task. An concern of using Shiki highilghter is depending on Oniguruma RegExp engine to recognize TextMate JSON. That is provided by WASM, and not supporting non-asynchronous function that is only supported by markdown-it API. The JavaScript RegExp engine could become to remove that dependency, support sync function, and make simplify the architecture. |
Hi @yhatt, // engine.js
import Shiki from "@shikijs/markdown-it";
const shiki = await Shiki({
themes: {
light: "one-light",
dark: "one-dark-pro",
},
});
export default ({ marp }) => marp.use(shiki); Would it be possible to also incorporate magic-move ? |
@isBatak Yes, this is the correct way to use Shiki with the current version of Marp Core. In an environment where there are no issues with using WASM and where a (We are currently waiting for the stabilization of synchronous API and JavaScript RegExp engine to maintain maximum compatibility with other environments) The application of magic-move is challenging for some reasons:
However, it should not be impossible if implemented custom syntax extension and a tailored slide display HTML for Marp Core slides. |
Related: marp-team/marp#103, #194
Let's start to think new architecture for code highlight toward Marp Core v4.
CSS variables based coloring
highlight.js based highlighting has high flexibility that came from stylabillity based on CSS class.
On the other hand, it is hard than expected to overload exist color scheme by the context. If the theme author wanted to use different highlight colors in
section.invert
, required reverting all styles about highlight.js and adding styles for changed colors.When using theme inheritance by
@import
, need to know all of styles using for highlight in the parent theme and revert them surely.I think it's painful for the custom theme author, so providing much better coloring system in code highlight would be best. https://github.com/orgs/marp-team/discussions/103#discussioncomment-702465
If Marp adopted CSS variables for code highlighting, changing color scheme by
class
context would be drastically simpler. It also means to deny detailed styling for highlighted keywords through CSS properties, but it's a corner case in the syntax highlight.highlight.js -> Shiki
#194 (comment) has suggested a modern highlighter Shiki, made on TextMate json and Oniguruma RegExp engine.
Concerns
In future, this concern may become to resolve by adopting JavaScript RegExp instead of Oniguruma.
deasync
but requires no native bindings ornode-gyp
)Marp.render()
Extended syntax for code fence
CommonMark defines the info string for fenced code block, like
```javascript
. It leaves to Markdown processors about how to use this string, so may add more useful features to Marp.```lang 1,3-4
```lang line-numbers
(```lang line-numbers=3
to begin from the middle of line numbers)We need work to them carefully because complexity of Marp Core theme CSS will increase at the same time.
The text was updated successfully, but these errors were encountered: