-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Better executable code syntax in MD #1166
Comments
Making sure I understand the issue: The goal is to avoid For example, in Typora, the following markdown: # Heading
Text
<script>
console.log('foo')
</script> Will be rendered as follows: Helper syntax options are limited if we want to keep markdown output clean when rendered outside of docsify. The options are 1) leverage existing markdown syntax (like a blockquote) or 2) use an HTML comment. Anything else is going to be rendered by markdown processors unless they specifically understand docsify's helpers syntax. Perhaps something like this? # Heading
Text
<!-- [script] src="path/to/script.js" -->
<!-- [script]
console.log('foo')
--> The downside to using comments-as-helpers is that syntax highlighting is lost. The upside is that it's valid markdown (because it's just HTML) and universally supported (because all markdown processors ignore HTML comments). This ties into the larger discussion of what a standard docsify helper syntax could/should look like. For those interested in that discussion, #413 (comment) and #413 (comment) are worth reviewing. |
yes, i was thinking if we can do like this
this will render in non docsify as
in for docsify,
to
while parsing and in this way, we can get the syntax highlighting as well. |
I don’t understand. I thought the goal of this issue is to allow JavaScript to be added to markdown and executed by docsify while being completely ignored (i.e. not rendered, not executed) in other environments. The examples above will render code blocks in all environments (including docsify). |
actually, I was thinking if we need to show it on other env or not. But yeah I agree, let's go with what was the original issue. Yea we can use the commented thing you mentioned. 👍 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I think more something like this: Here is a _neat_ example:
<!-- run-script -->
```js
console.log(foo)
``` which would render as: Here is a neat example: console.log(foo) Also check out the syntax open-wc uses: https://open-wc.org/mdjs/. It is like this: ```js script
console.log(foo)
``` which renders as the following which apparently works in GitHub markdown, but not sure about other flavors: console.log(foo) If that last approach using |
If we do that approach then it will have the wrong syntax color outside of Docsify. |
Yeah that's the goal |
Problem
This is with reference to
executeScript
property. Currently, docsify checking an executable script tag using thisThe markdown input for these doesn't look good ref
solution
if we are moving with pluggable markdown parser then create a plugin ( or use if exists ) to add custom syntax to uniquely identify some pre-coded syntax which can be replaced in the renderer.
The text was updated successfully, but these errors were encountered: