Coder Social home page Coder Social logo

marp-team / marp-vscode Goto Github PK

View Code? Open in Web Editor NEW
1.5K 14.0 70.0 13.95 MB

Marp for VS Code: Create slide deck written in Marp Markdown on VS Code

Home Page: https://marketplace.visualstudio.com/items?itemName=marp-team.marp-vscode

License: MIT License

JavaScript 2.67% TypeScript 96.72% CSS 0.61%
marp markdown vscode-extension vscode visual-studio-code

marp-vscode's Introduction

Marp for VS Code

CircleCI Codecov Visual Studio Marketplace Open VSX LICENSE

Create slide deck written in Marp Markdown on VS Code.

We will enhance your VS Code as the slide deck writer. Mark marp: true, and write your deck!

See the documentation of Marpit Markdown and the features of Marp Core about how to write.

Please refer https://marp.app/ for more details of Marp ecosystem. We have powerful tools for Marp Markdown: Marpit Framework, CLI tool, Web interface and so on.

Usage

Marp features will be enabled when marp: true is written in a front-matter of Markdown document.

---
marp: true
---

# Your slide deck

Start writing!

You can create a new Marp Markdown document from "New File..." menu (Alt + Ctrl + Win + N / Alt + Cmd + Ctrl + N) to start writing a slide deck quickly.

Create Marp Markdown

marp: true also can toggle by opening the quick picker from toolbar icon and selecting "Toggle Marp feature for current Markdown". (markdown.marp.toggleMarpFeature).

Toggle Marp preview

Features

Preview Marp Markdown

While enabled Marp features by marp: true, Marp for VS Code can preview your Marp Markdown with the same way as a built-in Markdown preview.

If you are not familiar with editing Markdown on VS Code, we recommend to learn what you can do in VS Code documentation at first.

IntelliSense for Marp directives

Directives, the inherited feature from Marpit framework, is an important syntax to write the deck in Marp.

If enabled Marp feature by marp: true, Marp for VS Code extends IntelliSense to support auto completion, syntax highlight, hover help, and diagnostics for Marp directives.

Auto completion

Marp for VS Code can suggest global/local directives supported by Marp ecosystem. We remember all so you may forget them! 😛

Hit Ctrl + Space within the front-matter or HTML comment to show the list of directives. You can peek the help of selected directive by hitting Ctrl + Space again.

Auto completion

Some directives such as theme and paginate are also supported auto completion for the value.

Highlight and hover help

The key of recognized directives are highlighted in the different color from the around. This visualization may help to find out meaningless definitions.

And you can see the help of a defined directive by hovering cursor on the recognized directive.

Highlight and hover help

Diagnostics

Marp for VS Code can detect some basic problems in Marp directives. Diagnostics will help following our recommended way for writing slides.

Diagnostics

Name Description Quick Fix
define-math-global-directive Recommend to declare math typesetting library via math global directive
deprecated-color-setting-shorthand Check deprecated shorthands for setting slide colors
deprecated-dollar-prefix Check obsoleted directives prefixed by $
ignored-math-global-directive Report ignored math global directive if disabled math by the extension setting
overloading-global-directive Find out overloaded global directives
unknown-size Notify if the specified size preset was not defined in a theme
unknown-theme Notify a not recognized theme name

Export slide deck to HTML, PDF, PPTX, and image 🛡️

We have integrated Marp CLI to export your deck into several formats.

To export the content of active Markdown editor, open the quick pick from Marp icon on toolbar and select "Export slide deck...". (markdown.marp.export)

Export slide deck

You can also execute command from the Command Palette (F1 or Ctrl/Cmd+Shift+P).

Supported file types

  • HTML
  • PDF
  • PPTX (PowerPoint document)
  • PNG (First slide only)
  • JPEG (First slide only)

Default file type can choose by markdown.marp.exportType preference.

⚠️ Export except HTML requires to install any one of Google Chrome, Chromium, or Microsoft Edge. You may also specify the custom path for Chrome / Chromium-based browser by preference markdown.marp.chromePath.

Use custom theme CSS 🛡️

You can register and use custom theme CSS for Marpit / Marp Core by setting markdown.marp.themes, that includes remote URLs, or relative paths to local files in the current workspace.

// Please put `.vscode/settings.json` on your workspace
{
  "markdown.marp.themes": [
    "https://example.com/foo/bar/custom-theme.css",
    "./themes/your-theme.css"
  ]
}

It's very similar to a way for using custom styles in ordinary Markdown preview. The registered theme can use by specifying theme name in theme global directive.

/* @theme your-theme */

@import 'default';

section {
  background: #fc9;
}
---
marp: true
theme: your-theme
---

# Use your own theme

Markdown preview will reload updated theme CSS automatically when you edited the registered local CSS file. It's very useful for creating your own theme.

Use custom theme

Outline extension

When Marp Markdown is enabled, you can use the extended outline view like following. They are enabled by default but you may disable by markdown.marp.outlineExtension preference.

Outline view for each slide

We extend the outline view to support slide pages in Marp Markdown.

Outline view for each slide

ℹ️ Please choose Sort By: Position from context menu of its panel if you see incorrect slide order.

Slide folding in editor

You can fold the content of slide in editor while editing Marp Markdown.

Slide folding in editor

Security

Some features that may met malicious are restricted in the untrusted workspace/window. Please read VS Code's user guide for details.

Features may be restricted are marked by the shield icon 🛡️ in this documentation. Marp for VS Code is available even if the current workspace is not trusted but you can use only a basic Marp preview and IntelliSense.

Enable HTML in Marp Markdown 🛡️

You can enable previsualization of HTML code within Marp Markdown with the markdown.marp.enableHtml option.

It could allow script injection from untrusted Markdown files. Thus, this feature is disabled as a default and will be always ignored in the untrusted workspace. Use with caution.

Web extension

You can use Marp extension in VS Code for the Web environment like vscode.dev and github.dev. Try opening https://github.dev/marp-team/marp-vscode/blob/main/docs/example.md, with an environment that has installed Marp extension.

The web extension has some limitations:

  • Export command cannot use because it is depending on Marp CLI that is not designed for Web. Please use VS Code that is installed to your local environment, or use either VS Code Server or GitHub Codespaces if you wanted an environment working on Web.

Contributing

Are you interested in contributing? Please see CONTRIBUTING.md and the common contributing guideline for Marp team.

Author

Managed by @marp-team.

License

This extension releases under the MIT License.

marp-vscode's People

Contributors

dependabot[bot] avatar eric-burel avatar yhatt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

marp-vscode's Issues

preview of slides do not scale properly on linux

having marp-cli integrated into vscode is really great, I just noticed that in the latest version, the slides do not scale properly in the preview panel

Version: 1.31.1
Commit: 1b8e8302e405050205e69b59abb3559592bb9e60
Date: 2019-02-12T02:19:29.629Z
Electron: 3.1.2
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Linux x64 4.15.0-45-generic

image

Add separate setting about line breaks for Marp preview

Unlike CommonMark, it is Marp Core's default behavior to convert line break into <br /> tag. (https://github.com/marp-team/marp-core#marp-markdown)

VS Code can configure the behavior of line breaks by markdown.preview.breaks (false by default) and Marp VSCode is also following. But it may confuse by the difference of default line break setting when using the same Markdown in the other Marp tools.

It would be good if there was separated markdown.marp.breaks option (true by default).

Can't export in PDF using VS Code, Ubuntu, tmp file not found

Hi, I end up with this Error when running the export using VS Code

Failure to export. Marp CLI throwed unexpected error with exit code 1.

Any idea how I could get a more precise error message?
I run VS code 1.39.2 on Ubuntu 18
The rendering is otherwise fine in VS code, including using a custom theme.

I've installed the CLI + set my chrome path to Chromium (/snap/bin/chromium), without success.

In VS Code console I get [ ERROR ] Failed converting Markdown. (net::ERR_FILE_NOT_FOUND at file:///tmp/tmp-9409eYKvX0jV6Xfg.html)
I don't have any HTML file in /tmp

If it can help, I also have this message: [Embedded Page] Uncaught TypeError: Cannot assign to read only property 'className' of object '#<SVGSVGElement>'

Note that I don't have the export options window screenshotted in the doc, I can't pick either pdf or html, I just get a system window asking for the filename.
Edit: it only affects PDF export, I can export in HTML

strange text colors

I have finally switched to the Marp Next framework.
I am using VSCode to edit and preview my markdown but the rendering is the same when I generate htlm or pdf.
There are some strange color in the text that I cannot explain.

the configuration is like this in my markdown

---
marp: true
size: 16:9
theme: gaia
backgroundColor: #0C2D4D
color: white
paginate: true
---

size global directive failed in vs code extension 0.8.0

Hi, I have tried out new feature for customized css in 0.8.0. It works fine. However, it seems that the size global directive 4:3 has been somehow deactivated. The only size that worked is 16:9, if I use the size: 4:3, the preview won't change. The exported pdf is fine for 4:3 though.

20190801-marp-issue

I couldn't confirm whether this is an individual case which is just for my end, or ... any way, I am also using the marp web app installed from chrome, the size directive is ok in there.

Looking forward to your reply, THX.

Custom theme

We are planning to support custom theme for Marpit/Marp Core. It can provide the right way to customize deck's design by the user. (#13 has mentioned to this)

The best way is using a native preference markdown.styles and detecting @theme meta prop from specified css files. However, we have concerned that the theme for Marp may break the regular preview style for Markdown.

An alternative way is new markdown.marp.themes preference. It works as like as markdown.styles only for Marp theme. We have to explore which one implements.

ToDo

  • Explore support for native preferences
  • Load CSS specified in adopted preference
    • Follow resolve rule of file path in markdown.styles (by security reason)
  • Watch changes for CSS theme and reload theme of Marp instance

Toggle Marp preview by command of quick-picker

If there was a command like markdown.marp.toggleMarpPreview to toggle marp front-matter by command that can access from quick-picker, it would become easy to use.

ToDo

  • Add markdown.marp.toggleMarpPreview command
    • Add front-matter section and marp: true when front-matter is not detected
    • Replace marp: true to false when front-matter is detected with marp: true
    • Replace marp: false to true when front-matter is detected with marp: false
    • Add marp: true to existed section when front-matter is detected without marp key

Drop support for VS Code < 1.36

We are considering to drop support for VS Code 1.31-1.35, that are using Electron which is required polyfill to render Marp preview.

We must leave ugly logics to apply polyfill for the correct preview in old versions. (e.g. #8, #19) In addition, The least version 1.31 cannot use auto fix command in Diagnostic API.

// act.isPreferred = true // TODO: Require VS Code >= v1.32

Thus, it's hard to maintain old compatibility while using features for the recent version. VS Code has auto-updation into the latest version, and we can't think that there are stuck users in the previous version.

Long line goes out of screen

When I enter a long linux path to the markdown file, the line displayed in marp goes beyond the screen, how to solve the problem? The problem can be seen here
This is my configurations in the head of the markdown file:

marp: true
theme: uncover
paginate: true
_paginate: false

Thank you so much!

Add toolbar button to show quick picker for Marp commands

marp-vscode v0.3.x has added a command to export slide deck to PDF, HTML, and images (#30). And we are considering to add toolbar button for accessing to export command easily.

toolbar

It should show VS Code's quick picker for Marp commands when clicked. In future, we would add some commands acessible from that.

Link has wrong hit area in VS Code 1.36-insider

The latest build of VS Code 1.36-insider has updated Electron from 3.x to 4.x.

Version: 1.36.0-insider
Commit: c089daa858f34631f5f827ff8a0313bf1e2ded6d
Date: 2019-06-07T06:13:41.194Z
Electron: 4.2.3
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Darwin x64 18.6.0

I have already known Chrome <= 69 still has a serious bug in rendering Marpit's inline SVG slide. (See marp-team/marpit#35 that I found a year ago)

Chrome 66 (Electron 3.x) cannot scale hit area and rendering by inline SVG. Only DevTool knows the actual scaled DOM. I had same issue in marp-team/marp-cli#15. Fortunately we can fix it by just applying a WebKit polyfill manually, so Marp for VS Code had used marpit-svg-polyfill.

In Chrome 69 (Electron 4.x), only the hit area is following correct scaling by inline SVG, and rendering is not. The polyfill should keep using to fix rendering, but hit area will too scaled.

electron4

Incorrect theme style

v0.0.2 shows incorrect styles in some themes, caused by VS Code's default style.

---
marp: true
---

Incorrect `code` rendering

    WTF!?

```javascript
const foo = 'bar'
```

> test

Correct (Output in Marp CLI)

test

Incorrect

incorrect

Question - Can i do a4 documentation ?

Hello,

I like marp to do slide presentation. I want to go further and use it for internal documentation. I think to create a custom style for slide and A4 document and then when i want to do documentation i would change $size and custom style properties.

Is it possible with marp ? Is it intented for usage like that ? Coud you give some advice ?

Add documentation about how to enable HTML into README

Surely we have no documentation about markdown.marp.enableHtml preference.

That's a great feature, could you add a line about this option in the Readme?
It's very hard to find doc about HTML support in Markdown, either in Marp or with other tools. > It's usually supported but it's not always obvious, I had to dig until I found this issue.

Or maybe the fact that HTML is supported should be specified in Marpit doc directly?

Originally posted by @eric-burel in #10 (comment)

My custom theme doesn´t affect vscode preview presentation

I have followed the instruction on how to add a custom theme in the readme file. But the css changes I write on my your-theme.css does not affect vscodes preview presentation. But my theme will appear if I export my .md file to pdf.
My vscode version is:
Version: 1.40.0
Electron: 6.1.2
Chrome: 76.0.3809.146
Node.js: 12.4.

Play slides on VS Code through exported HTML

Marp for VS Code is just a extension to Markdown pane for preview Marp slides when writing. Normally user should use exported HTML/PDF/PPTX for the practical presentation.

However, We have received some (silent) feedbacks to want to play slideshow on VS Code. We are considering to support playing the exported HTML from Marp CLI directly in VS Code, by adding custom WebView by Marp extension.

A vscode-reveal extension, based on reveal.js, has already supported playing slideshow within VS Code. So we should be able the same with similar approach.

ToDo

  • Consider a way to export HTML for custom WebView via Marp CLI
    • Generate HTML when executing command? (Presented slides cannot edit dynamically)
    • Use server mode (--server)? (Should pay attention to the behavior of remote extension)
  • Add command to play slideshow
  • Add custom WebView to render converted HTML
    • UPDATED: We might not use VS Code WebView in favor of Marp CLI's preview window.

Fragmented list doesn't work in PowerPoint export

When I used the Fragmented unordered list and export to PPTX, the "fragmented" / animation part doesn't work--that is, all the items appear at once. The fragmented effect works fine in HTML, but not in PPTX
Markdown example:

Title
* item 1
* item 2

My system
OS: Windows 10 Pro version 1803 (build 17134.885)
VSCode: 1.37.1
Marp extension: 0.9.0

Math blocks don't scale

For the current version, equations are not scaled anymore to fit the size of the slide. Probably this issue is related to marp-core functionality, but for me, this appears within vs-code.
In the documentation of marp-core, it's written that the auto-scaling does not work with the uncover-theme. I am using theme: default.
It does not matter whether any [bg right] image is included on the slide or not.

Thanks!

# Some title

Eq. that fits into one line (no block) 
$S_1 = C_0 + n S_3$


Eq. that doesn't fit into one line (block)
$$S_1-S_3 = C_0 + \left(1-n\right)P_p - \left(1-n\right)S_3$$

Eq. that doesn't fit into one line (no block)
$S_1-S_3 = C_0 + \left(1-n\right)P_p - \left(1-n\right)S_3$

![bg right](test.png)

image

Could not export to PPTX (Marp for VS Code 0.10.1)

To export slides to PPTX, I opened the quick picker from toolbar icon and typed "markdown.marp.exportType" but I found nothing. The "markdown.marp.export" gave no options for filetypes (e.g. PDF, PPTX). Only PDFs can be exported to. I am using VS Code version 1.33.0 and Marp for VS Code 0.10.1.

Marpit's color shorthand does not work

Marpit's color shorthand does not work on VS Code preview. It would work only in the exported PDF and HTML.

---
marp: true
---

# Named color (rebeccapurple BG + White text)

![bg](rebeccapurple)
![](white)

---

# RGB values (Orange BG + White text)

![bg](rgb(255,128,0))
![](rgb(255,255,255))
VS Code preview Exported PDF
vscode pdf

Only hex color is working, so I guess the reason for breaking syntax would VS Code's link normalizer. (#27)

Support absolute path for extra theme

I have tried this option "markdown.marp.themes" and like it is described, it only work with relative css file in workspace or url.

I want to have a external folder with multiple themes. Do you think u could support absolute path for that ?

How to highlight words?

I read this guideline. Therefore I tried to put this question on StackOverflow, but I needed over 1500 reputations to place a new tag "marp". Unfortunately, I don't have over 1500 reputations, so please forgive me.
How to highlight words on marp? I used ==abc== when I was using the desktop app but doesn't work on VS Code edition.

P.S. I want to highlight words like the Gaia theme on the default theme.

Last slide visually shifted in HTML export

Really love marp for vscode - Thank you.

I noticed that the last slide on the generated HTML export is always slightly shifted vertically in the browser. It looks lke the "Marp Core's Browser" JS is getting put inside the last slide's SVG. If the JS was moved outside the last SVG (perhaps just before the closing body tag), then the preview appears correct without any visual position shifting.

tested on:
macOS 10.14 - Chrome latest, Safari 13.0.2, Firefox 70.0.1

Example MD and HTML attached:
marp-shift.zip

Images don't appeared in exported PDF

When I previews slides in VSCode and when I exported them to HTML, the images appear. However, when I export the same file to PDF, the images don't are missing.

Here is my code (I tried both HTML and standard markdown)
<img src="assets/potentiometer-482082_960_720.jpg" style="width:50px" /> ![width:300px](assets/1565313673103.png)

Here is the PDF export with the missing images
image

For comparison, here is the preview from VSCode with the images present
image

More img usage example

Hello,
I've been using Marp desktop (deprecated) and I love it.
I recently found out there is Marp Next project and VSCode extension.

The problem I have is the image usage is different from Marp desktop and VSCode version.
Could you provide more examples on how to add image?

How to change the font of the preview?

---
marp: true
---

<style>
.slide{
font-family: 'Noto Sans JP', serif !important;
}
</style>

If I changed the font like this, the exported pdf was the font but the preview was not.
I also added "markdown.preview.fontFamily": "Meiryo UI", in the settings.json of VScode, but the preview was not.

Custom engine

Is there any way to change the engine used by marp-vscode ? Like in marp-cli when we run the command marp --engine ./engine.js content.md.

Can't preview with Ctrl + K V & Ctrl + Shift + V if other markdown viewers are installed

Markdown viewers like https://github.com/shd101wyy/markdown-preview-enhanced replacing the default viewer also take over keyboard shortcuts Ctrl+K V & Ctrl+Shift+V, which is used for opening them. 3rd-party viewers prevents us from previewing slides using the default viewer and this extension.

To reproduction:

  1. Install this extension and Markdown Preview Enhanced.
  2. Create new slide written Marp-flavored Markdown
  3. Preview by pressing Ctrl+K V
  4. Markdown Preview Enhanced appears and slide preview doesn't.

Page Number not shown

I'm using the VSCode plugin of Marp and when I insert <!-- page_number: true --> at the beginning of my slide, no page number is shown at bottom-right corner. Other features work fine such as size, theme, and footer.

Add setting to allow HTML

It is good to be togglable enable or disable HTML as a configuration of extension. It would work as same as --html option in Marp CLI.

Feedbacked to #4 (comment).

Marp preview not work

Hi,
When I try toggle markdown with marp, nothing happend but my header marp: true is changed to marp: false. The same situation if call it in Ctrl + Shift + P.

What's wrong here?

equations are not rendered correctly when extension "Markdown All in One" is enabled

I noticed that equations are not rendered correctly when another extension (Markdown All in One) is active. As this one is quite popular, I thought it's worth to mention it.

Version: 1.31.1
Commit: 1b8e8302e405050205e69b59abb3559592bb9e60
Date: 2019-02-12T02:19:29.629Z
Electron: 3.1.2
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Linux x64 4.15.0-45-generic

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.