-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Inject browser script to rendered Markdown automatically #115
Conversation
@@ -0,0 +1,3 @@ | |||
const dummy = 'This is a placeholder for the content of built browser script.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using a strange trick for bundling precompiled IIFE script as string by rollup, without any errors.
https://github.com/marp-team/marp-core/pull/115/files#diff-ff6e5f22a9c7e66987b19c0199636480R23
@@ -6,6 +6,7 @@ | |||
"noImplicitAny": false, | |||
"outDir": "lib", | |||
"resolveJsonModule": true, | |||
"rootDir": ".", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To resolve URL for CDN, we have to load package.json
placed on the project root. Thus, rootDir
was changed from src
to .
. It would change the structure of types
directory too.
Based on feedbacks in #112 and marp-team/marp-cli#168, I've implemented better script injection to work WebKit polyfill and auto-scaling observer in anywhere.
This implementation would make Marp Core work well in customized engine of Marp CLI. In addition, Marp CLI's browser script detection would no longer need.
script
optionMarp constructor has a new
script
option to control browser script injection.true
: Insert the inline browser script into the last of slides. (default)false
: Not insert any script. Developer has to execute the script exported in@marp-team/marp-core/browser
manually. It's suitable to the fully-controlled tool such as Marp Web.source
: Choose the kind of script.inline
: Insert inline script. It would work correctly also in the environment that there is not network. (default)cdn
: Insert script referred through jsDelivr CDN. It's better choice on the restricted environment by CSP.nonce
: Setnonce
attribute of<script>
.Deprecated
Marp.ready()
Marp.ready()
was marked as deprecated because typically the script injection won't require to call browser script manually. If developer wants to use browser script (e.g. Marp Web), it can use a better entry point@marp-team/marp-core/browser
splitted from Marp class.ToDo