How to call the marked library to handle the markdown language when introducing HTML in Matlab appdesigner?

41 ビュー (過去 30 日間)
健文
健文 2024 年 11 月 8 日 5:56
コメント済み: 健文 2024 年 11 月 8 日 9:55
How to call the marked library to handle the markdown language when introducing HTML in Matlab appdesigner? Currently, I am using the local marked library, but Matlab shows that it is not supported

回答 (1 件)

Sameer
Sameer 2024 年 11 月 8 日 9:21
編集済み: Sameer 2024 年 11 月 8 日 9:31
To use the "marked library" in MATLAB App Designer, there is a limitation with the "uihtml" component:
"HTML files that you specify for the HTMLSource property cannot access third-party JavaScript libraries by way of a Content Delivery Network (CDN). Save libraries in a location that your local file system can access."
By saving the "JavaScript" libraries locally you can access them
Here's an example implementation:
1. Download "marked.min.js" :Go to https://cdn.jsdelivr.net/npm/marked/marked.min.js and save the code locally.
2. Save the HTML content
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Markdown Renderer</title>
<script src="marked.min.js"></script> <!-- Local JS file -->
</head>
<body>
<div id="content"></div>
<script>
window.onload = function() {
var markdownText = '# Marked in the browser\n\nRendered by **marked**.';
document.getElementById('content').innerHTML = marked.parse(markdownText);
};
</script>
</body>
</html>
3. Set the "HTMLSource" field of your HTML component
Now the rendered Markdown content will be displayed as follows:
Hope this helps!
  1 件のコメント
健文
健文 2024 年 11 月 8 日 9:55
Thanks, but I put my script file in another separate file and used setup (HTMLcomponent) to interact with matlab, which seems to cause an. Also, I want to call mathjax or katex to render formulas. How should I do it?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by