Giter Club home page Giter Club logo

marp-core's Introduction

@marp-team/marp-core

CircleCI Codecov npm LICENSE

The core of Marp converter.

In order to use on Marp tools, we have extended from the slide deck framework Marpit. You can use the practical Markdown syntax, advanced features, and official themes.

Install

# npm
npm install --save @marp-team/marp-core
# yarn
yarn add @marp-team/marp-core

Usage

We provide Marp class, that is inherited from Marpit.

import { Marp } from '@marp-team/marp-core'

// Convert Markdown slide deck into HTML and CSS
const marp = new Marp()
const { html, css } = marp.render('# Hello, marp-core!')

Features

We will only explain features extended in marp-core. Please refer to Marpit framework if you want to know the basic features.


Marp Markdown

Marp Markdown is a custom Markdown flavor based on Marpit and CommonMark. Following are principle differences from the original:

  • CommonMark
    • For making secure, we will deny most of HTML tags used in Markdown by default. Allowed HTML tags are <br> only for now.
    • Support table and strikethrough syntax, based on GitHub Flavored Markdown.
    • Line breaks in paragraph will convert to <br> tag.
    • Slugification for headings (assigning auto-generated id attribute for <h1> - <h6>) is enabled by default.

We provide bulit-in official themes for Marp. See more details in themes.

Default Gaia Uncover
<!-- theme: default --> <!-- theme: gaia --> <!-- theme: uncover -->

size global directive

Do you want a traditional 4:3 slide size? Marp Core adds the support of size global directive. The extended theming system can switch the slide size easier.

---
theme: gaia
size: 4:3
---

# A traditional 4:3 slide

Bulit-in themes for Marp have provided 16:9 (1280x720) and 4:3 (960x720) preset sizes.

Define size presets in custom theme CSS

If you want to use more size presets in your own theme, you have to define @size metadata(s) in theme CSS. Learn in the document of theme metadata for Marp Core.

Theme author does not have to worry an unintended design being used with unexpected slide size because user only can use pre-defined presets by author.


Emoji support

Emoji shortcode (like :smile:) and Unicode emoji ๐Ÿ˜„ will convert into the SVG vector image provided by twemoji ๐Ÿ˜„. It could render emoji with high resolution.


Math typesetting

We have Pandoc's Markdown style math typesetting support. Surround your formula by $...$ to render math as inline, and $$...$$ to render as block.

Markdown Rendered slide
Render inline math such as $ax^2+bc+c$.

$$ I_{xx}=\int\int_Ry^2f(x,y)\cdot{}dydx $$

$$
f(x) = \int_{-\infty}^\infty
    \hat f(\xi)\,e^{2 \pi i \xi x}
    \,d\xi
$$

Math typesetting support

You can choose using library for math from MathJax and KaTeX in math global directive (or JS constructor option). By default, we prefer MathJax for better rendering and syntax support, but KaTeX is faster rendering if you had a lot of formulas.

math global directive

Through math global directive, Marp Core is supporting to declare math library that will be used within current Markdown.

Set mathjax or katex in the math global directive like this:

---
# Declare to use KaTeX in this Markdown
math: katex
---

$$
\begin{align}
x &= 1+1 \tag{1} \\
  &= 2
\end{align}
$$

If not declared, Marp Core will use MathJax to render math. But we recommend to declare the library whenever to use math typesetting.

โš ๏ธ The declaration of math library is given priority over math JS constructor option, but you cannot turn on again via math global directive if disabled math typesetting by the constructor.


Auto-scaling features

Marp Core has some auto-scaling features:

Auto-scaling is available if defined @auto-scaling metadata in an using theme CSS.

/*
 * @theme foobar
 * @auto-scaling true
 */

All of Marp Core's built-in themes are ready to use full-featured auto scalings. If you're the theme author, you can control target elements which enable auto-scaling by using metadata keyword(s).

This feature depends to inline SVG, so note that it will not working if disabled Marpit's inlineSVG mode by setting inlineSVG: false in constructor option.

โš ๏ธ Auto-scaling is designed for horizontal scaling. In vertical, the scaled element still may stick out from top and bottom of slide if there are a lot of contents around it.

Fitting header

When the headings contains <!-- fit --> comment, the size of headings will resize to fit onto the slide size.

# <!-- fit --> Fitting header

This syntax is similar to Deckset's [fit] keyword, but we use HTML comment to hide a fit keyword on Markdown rendered as document.

Auto-shrink the block

Some of blocks will be shrunk to fit onto the slide. It is useful preventing stuck out the block from the right of the slide.

Traditional rendering Auto-scaling
Code block Traditional rendering Auto-scaling
KaTeX math block Traditional rendering Auto-scaling

โ„น๏ธ MathJax math block will always be scaled without even setting @auto-scaling metadata.


Constructor options

You can customize a behavior of Marp parser by passing an options object to the constructor. You can also pass together with Marpit constructor options.

โ„น๏ธ Marpit's markdown option is accepted only object options because of always using CommonMark.

const marp = new Marp({
  // marp-core constructor options
  html: true,
  emoji: {
    shortcode: true,
    unicode: false,
    twemoji: {
      base: '/resources/twemoji/',
    },
  },
  math: 'katex',
  minifyCSS: true,
  script: {
    source: 'cdn',
    nonce: 'xxxxxxxxxxxxxxx',
  },
  slug: false,

  // It can be included Marpit constructor options
  looseYAML: false,
  markdown: {
    breaks: false,
  },
})

html: boolean | object

Setting whether to render raw HTML in Markdown. It's an alias to markdown.html (markdown-it option) but has additional feature about HTML allowlist.

  • true: The all HTML will be allowed.
  • false: All HTML except supported in Marpit Markdown will be disallowed.

By passing object, you can set the allowlist to specify allowed tags and attributes.

// Specify tag name as key, and attributes to allow as string array.
{
  a: ['href', 'target'],
  br: [],
}
// You may use custom attribute sanitizer by passing object.
{
  img: {
    src: (value) => (value.startsWith('https://') ? value : '')
  }
}

Marp core allows only <br> tag by default. That is defined in a readonly html member in Marp class.

Whatever any option is selected, <!-- HTML comment --> and <style> tags are always parsed by Marpit for directives / tweaking style.

emoji: object

Setting about emoji conversions.

  • shortcode: boolean | "twemoji"
    • By setting false, it does not convert any emoji shortcodes.
    • By setting true, it converts emoji shortcodes into Unicode emoji. :dog: โ†’ ๐Ÿถ
    • By setting "twemoji" string, it converts into twemoji vector image. :dog: โ†’ ๐Ÿถ (default)
  • unicode: boolean | "twemoji"
    • It can convert Unicode emoji into twemoji when setting "twemoji". ๐Ÿถ โ†’ ๐Ÿถ (default)
    • If you not want this aggressive conversion, please set false.

For developers: When you setting unicode option as true, Markdown parser will convert Unicode emoji into tokens internally. The rendering result is same as in false.

math: boolean | "mathjax" | "katex" | object

Enable or disable math typesetting syntax and math global directive.

You can choose the default library for math by passing "mathjax" (default) or "katex", and modify more settings by passing an object of sub-options.

  • lib: "mathjax" | "katex"
    • Choose the default library for math typesetting. (mathjax by default)
  • katexOption: object
    • Options that will be passed to KaTeX. Please refer to KaTeX document.
  • katexFontPath: string | false
    • By default, Marp Core will use online web-font resources through jsDelivr CDN. You have to set path to fonts directory if you want to use local resources. If you set false, we will not manipulate the path (Use KaTeX's original path: fonts/KaTeX_***-***.woff2).

minifyCSS: boolean

Enable or disable minification for rendered CSS. true by default.

script: boolean | object

Setting about an injected helper script for the browser context. This script is necessary for applying WebKit polyfill and rendering auto-scaled elements correctly.

  • true (default): Inject the inline helper script into after the last of slides.
  • false: Don't inject helper script. Developer must execute a helper script manually, exported in @marp-team/marp-core/browser. Requires bundler such as webpack. It's suitable to the fully-controlled tool such as Marp Web.

You can control details of behavior by passing object.

  • source: string - Choose the kind of script.
    • inline: Inject the inline script. It would work correctly also in the environment that there is not network. (default)
    • cdn: Inject script referred through jsDelivr CDN. It's better choice on the restricted environment by CSP.

slug: boolean | function | object

Configure slugification for headings. By default, Marp Core tries to make the slug by the similar way to GitHub. It should be compatible with Markdown Language Server.

  • true (default): Assign auto-generated id attribute from the contents of <h1>-<h6> headings.
  • false: Disable auto-assigning slug to headings.
  • function: Set the custom slugifier function, that takes one argument: the content of the heading. It must return a generated slug string.

You can control details of behavior by passing object.

  • slugifier: function - Set the custom slugifier function.

  • postSlugify: function - Set the post-process function after generated a slug. The function takes 2 arguments, the string of generated slug and the index of the same slug, and must return a string for assigning to id attribute of the heading.

    By default, Marp Core applies the post-process to avoid assigning duplicated ids in the document: (slug, index) => (index > 0 ? `${slug}-${index}` : slug)

    Assigning the custom post-process function is also helpful to append the custom prefix and suffix to the generated slug: (slug, i) => `prefix:${slug}:${i}`

Take care not to confuse Marp Core's slug option and Marpit's anchor option. slug is for the Markdown headings, and anchor is for the slide elements.

Marp class is extended from Marpit class so you can customize both options in the constructor. To fully disable auto-generated id attribute, set both options as false. (This is important to avoid breaking your Web application by user's Markdown contents)

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 package releases under the MIT License.

marp-core's People

Contributors

ben-thul avatar dependabot[bot] avatar matsubara0507 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

marp-core's Issues

Questions about theming

Hello

I have a made a custom theme and now i want to have a theme that support multiple size (4:3 16:9 4K A4) with completely different css rules for size A4.

Do you have a class applied when size is setup ?

Change result when using engine

With the following files engine.js and index.md. I get different result if I execute marp index.js

screenshot1

or marp --engine ./engine.js index.md

screenshot2

I have found that the problem exist if I use the theme default or gaia, uncover seems to work correctly with this example. I guess the problem is coming from the theme, I can look into it but do you have any tips in where to search ?

Feature - directive to create TOC

I would like to have a directive to show a TOC with page numbers and link to slide.

Ideally with options to customize level of toc or ignore some title.

What do you think about that ?

Support for prism js

Please, add option to replace highlightjs with prism for highlighting.
It adds much more useful and consistent highlighting for kotlin, current state may be found in this repo: https://github.com/asm0dey/kotlin-spark/

Sometimes code blocks are almost not highlighted and sometimes they are being highlighted inconsistently.
Prismjs has lots of plugins and support for lots of languages.

A dynamically generated image does not have the correct size

Hello,

And thanks for creating Marp. It has become my main tool to work on slides.
There is one thing that I cannot get to work properly - I want to use PlantUML in my slides.
I used mardown-it-plantuml. I can see the image, but it is distorted:

distorted UML diagram

I am using Marp CLI with a custom marp.config.js (like mentioned in #112). I found #131 which seems to relate to my problem. I tried making my own engine.js, with the same result. I also know that Marp does not officially support the PlantUML plugin, but is there an easy way to fix it on my side? I tried to use SVG and PNG, and looked at CSS options for SVG objects, to no avail.

Thanks a lot.

Tables Settings

I am looking for a way to use tables to layout images in a single slide. But, to do it in a neat way, I would need to tackle some of the following features

  • Table without header
  • Header without being bold
  • Table without borders
  • Table without alternating background colour

Is there a way to do the things above that I am not currently aware of?

PS.: I've tried to do the table in pure html tags, it didn't seem to work.

GFM strikethrough syntax

The old Marp app is supported GFM stirikethough ~~like this~~, but Marp Next is not. We are listening the quiet feedback from some users want us to support strikethrough syntax.

Marp Next's policy is "Avoid breaking CommonMark as much as possible" and strikethrough syntax is against our policy. But if the new syntax is useful and well-known feature in Markdown community widely, Marp Core allows additional feature like breaking CommonMark syntax. (e.g. Math typesetting)

So I think strikethrough syntax ~~ might as well add to Marp Core.

It is good for first contribute because it has only to turn on strikethrough rule in markdown.enable().

this.markdown.enable(['table', 'linkify'])

Test on top of page

When I use the default theme, the text appeared in the middle of the page.
How can I force the text on top with a css which import the default ?

Get back size global directive

Background

The old Marp app has $size global directive to change slide size, but it omitted in Marpit framework by restriction of inline SVG slide for realizing zero-JS slide.

In the position of theme author, it means does not need to worry about responsive design. So it would become easy to create theme with less effort. (We also have an opinion that the other slide framework has few community themes because it's hard to care responsive layout on the Web)

Marp Core is also following this way of thinking. Our official themes only provide 16:9 slide, is the standard size in PowerPoint and Keynote.

Feedback

On the other hand, we have recieved many feedbacks that want to change slide size. (marp-team/marpit#163, marp-team/marp-vscode#43, #90)

Currently we are recommending to use new theme with @import 'base-theme' + custom section size, but it's bit complex and have some unsupported Marp integrations: VS Code, React, Vue.

#90 suggests to provide 4:3 slide as the variation of built-in theme but we could not accept because it denys our position that theme author does not need to worry responsive size. Marp Core's theme support should select whether theme author allowed custom size.

Idea

Get back size global directive from the old Marp app.

Theme author has to permit pre-defined custom size in Marp Core's theme metadata, so don't have to worry collapsed design by unexpected size.

Usage

/*
 * @theme foobar
 * @size 4:3 960px 720px
 * @size 16:9 1280px 720px
 */
---
theme: foobar
size: 4:3
---

# 4:3 slide

ToDo

  • Add size global directive to Marp Core by using Marpit's custom directive support
  • Parse theme metadata @size 4:3 960px 720px
    • size global directive can only use pre-defined size in @size meta.
  • Generate temporary custom theme based on parsed size directive
    • Marp Core can override Marpit's style generation method, so we should generate temporary custom theme like #90 programmatically.

Toggle additional features through theme metadata

Motivation

I have concerned that Marp Core's additional feature (especially auto-scaling) makes theme creation difficult for theme author compared to Marpit.

Typically our presentation app will release with Marp Core, so we have to focus the theming experience within Core. Marpit allows to create theme based on ours, but a fully customized theme requires knowledge of Marp Core. The typical example is --preserve-aspect-ratio variable for alignment in auto-scaling.

We aim to be able to create theme CSS by everyone who familiar with general CSS and HTML markup. So these definitions might prevent our way.

Proposal

By using theme meta, a theme author will make be toggleable our additional feature of Marp Core. Meta flags should support in additional features that have to consider the complex CSS style.

/**
  * Marp core theme
  *
  * @theme theme-name
  * @auto-scaling true
  */ 

If the author has not defined meta, the additional feature does not work in a specified theme.

Currently, we can already recognize @fittingCode (for UNCOVER theme), and this proposal is a generalization of it. The other example of an additional feature that has to consider styling is the footnote. (See: yhatt/marp#2)

Define word-wrap css property as break-word in gaia and uncover theme

Default theme has word-wrap: break-word; CSS property to section for breaking a line that has long words, but it does not defined in others.
marp-team/marp-vscode#76

It may be more natural behavior to prevent sticking out line by built-in themes. We can add word-wrap: break-word; property declaration to section selector.

https://github.com/marp-team/marp-core/blob/master/themes/gaia.scss#L209
https://github.com/marp-team/marp-core/blob/master/themes/uncover.scss#L65

No parsing of transparent background for PNG images

Summary

PNG images with transparent backgrounds are rendered with white backgrounds

MRE

---
marp: true
---

<!--
	backgroundColor: blue
	color : white
-->

# Testing image

![w:500](http://www.pngall.com/wp-content/uploads/2016/04/Plum-Free-PNG-Image.png)

Expected result

Something like this (sans sloppy paintjob)
image

Obtained result

image

[Question] How can I customize pagination style?

Hello,
I want to use uncover theme's pagination style in Gaia theme, how to do that in YAML front-matter?

And how can I change pagination's position to the bottom center of the slide? The following configuration is not working.

---
marp: true
theme: gaia
paginate: true
style: |
  section::after {
    text-align: bottom center;
  }
---

How to do autofit so content won't be cropped off?

Firstly thanks for developing this great tool. I just started using it and it's fantastic. The real time previewing in VS Code is like nothing I've seen before :)

In my first test, one slide is not able to hold all the content. I am wondering if Marp can scale the result to fit all content into one page. (I don't mind the text font will be smaller.)

I've tried to use the following options.

theme: enable-all-auto-scaling
auto-scaling: true   

I can see the code block is scaled. But the text lines are still overflown.

PDF not being rendered with background image

I am using marp-cli via the Docker container and although it is working in general, the PDF files are not being rendered with the background image in my custom theme, although it works fine in the HTML.

Should this work and do you have any ideas or pointers on how I could troubleshoot this?

Here are some details about the setup and workflow...

On a Mac OS X system in a directory with the following files:

class-docker-compose.md
images/chalkboard-16by9.jpg
sunburst.css
spkane.css

I am running the following commands:

docker pull marpteam/marp-cli
docker run --rm -v $PWD:/home/marp/app/ marpteam/marp-cli class-*.md --theme-set spkane.css
docker run --rm -v $PWD:/home/marp/app/ marpteam/marp-cli class-*.md --theme-set spkane.css --pdf

KaTeX math block with auto scaling will not align tags correctly

Reported in marp-team/marp#124.

the tag of a mathematic formula will cover the formula, can we solve it ?
Example, the formula is
$$
x^n+y^n=z^n \tag{1}
$$
the preview is
image

.tag class has styled by position: absolute. The parent container data-marp-fitting-svg-content for detecting the width before applying scale will not consider the width of tag.

Add line based code highlighting

Thanks a ton for creating marp, been using it since some time and really like it!

One feature I am missing (or maybe I haven't found it) is the partial highlighting of codeblocks.

Deckset allows for incremental highlighting via its [.code-highlight: ...] snippet, I think something similar would be great for marp as well.

Safari does not shrink down protruding KaTeX math block

In Safari, very long math block won't shrink down by auto-scaling in Marp Core.

<style>
svg { outline: 3px solid red; }
</style>

$$
f(x)=a+b+c+d+e+f+g+h+i+j+k+l
$$

$$
f(x)=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s
$$

$$
f(x)=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z
$$
Safari Chrome Firefox
marp-bug-safari marp-bug-chrome marp-bug-firefox

As indicated by outlines for <svg>, DOM layout for auto-scaling don't protrude. Simply Safari's long-stucked bug over 11 years has affected to nested <foreignObject> rendering.

Curiously fitting header and code block won't protrude even in Safari. I suppose rendering of the complex contents may not be working.

Math not rendering

$L = \sum_i w(x) L(f(X_i), Y_i)$  // render
$L = \sum_i w(x) L(f(X_i), Y_i) $ // does not render
$ L = \sum_i w(x) L(f(X_i), Y_i)$ // does not render

Animate paragraphs/text line by line

Hi,

I was just giving Marp a try: it looks like the perfect solution for doing slides quickly.
Unfortunately, I can't figure out how to "animate" the text on each slide.

I'm not looking for anything fancy. I just want to be able to gradually introduce the text on the slide, line by line to the audience. I don't want to display the full slide with the whole text, because it's too much information at once. This will distract the audience, in my experience.

Is there a way to do this in Marp? I apologize if this is trivial. I searched in the marp-core & marpit issues, and on the https://marp.app/ and https://marpit.marp.app/ websites.

In particular, is there a way to animate the equations in begin{aligned} one by one? (Once again, displaying a block of 10 equations to the audience is not a good idea in my experience.)

Thank you,
Alin

Later edit: I am basically looking for something like \pause in Beamer or like "pauses" in pandoc's presentation mode

Option to output an inline helper script without injecting it in HTML

Currently, an inline helper script is injected into only after the last slide. (cf. https://github.com/marp-team/marp-core#script-boolean--object) Therefore, if I use only one of the rendered slides (like html[slideIndexToDisplay]), it may not have the script and may not be displayed correctly.

So, I need an option to inject the script into all slides.

However, I thought it would be more flexible to output the script without injecting it in HTML.

const { html, css, js } = marp.render('# Hello, marp-core!')

How to move title up or down?

Sorry to bother.
Is it possible to move the title up or down according to some user defined value?
In the following test page, I'd like to move the title up a little bit. Can it be done?
Thanks!
image

Creating documents that are not slides

I can't find how to create regular documents that are not slides with marp. Is there a way to do that?
PS.: I also couldn't find where to post this question, so I am adding it as an issue.

pdf.js rendering issue with linear-gradient

pdf.js (Firefox's default pdf engine) doesn't render page corners of the uncover theme.

> marp slides.md -o slides.pdf

Firefox:
image

Chrome:
image

Current workaround:
I've replaced the linear gradient with a svg image.

uncover.scss:14

  &::after {
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 100 100" width="100" height="100"><path d="M0 100h100v-100Z" fill="' + rgba($text, 0.05) + '"/></svg>');
    background-size: 100%;
    color: $text;
    text-shadow: 0 0 5px $bg;
  }

It now works in both Chrome and Firefox, but I have not tested on other pdf readers.

Unknown permission type: clipboardRead

Hi, I have trouble with marp. It works fine last week, but it throw errors as follows this week. Please help. Thanks.

npx @marp-team/marp-cli foo.md --preview
[  INFO ] Converting 1 markdown...
[  INFO ] foo.md => foo.html
[  INFO ] [Watch mode] Start watching...
[  INFO ] [Preview] (EXPERIMENTAL) Opening
          file:///Users/zhaozhiming/Documents/foo...
(node:36765) UnhandledPromiseRejectionWarning: Error: Protocol error (Browser.grantPermissions): Unknown permission type: clipboardRead
.......
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:36985) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:36985) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

How should I insert multiple pictures

I would like to put multiple, like 6 or 8 pictures in one page, so how should I do in Marp? I tried table, but it looks a little ugly. May I know if any other good method for it?

Presenter view

Hello, folks!

Thank you for your amazing work. Marp Next is way more powerful than previous Marp!

It would be super-useful to implement speaker view like reveal.js does here

ResizeObserver-based fitting observer

Currently we use polling-based observation for fitting header. It tracks the change of size includes CSS animation certainly, but it has a big effect to the performance.

Chrome >= 64 is supported ResizeObserver to observe change the size of element with better performance. It has better to use it if possible.

Code blocks disappear when using markdown-it-plantuml

I'm trying to use markdown-it-plantuml.

I'm using marp/cli with this marp.config.js file

const { Marp } = require('@marp-team/marp-core')

module.exports = {
    engine: opts => new Marp(opts).use(require('markdown-it-plantuml'))
}

Now I have plantuml working, but the content of my code blocks has disappeared
image

Am I doing something wrong?

v1.0.0 throws "z is not a function"

Marp Core v1.0.0 throws TypeError: z is not a function just by calling require('@marp-team/marp-core').

> require('@marp-team/marp-core')
Thrown:
TypeError: z is not a function
    at Object.<anonymous> (/Users/yhatt/Programs/marp-team/marp-cli/node_modules/@marp-team/marp-core/lib/marp.js:1:941)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)

The same issue has reported in marp-team/marp-cli#198 and marp-team/marp-react#19.

Feature Request: User themes index

Feature description

Create a searchable index for user created themes for marp.

Ideas

  • Can be a simple wiki page, or in the docs.
  • Another option would be a repository with a single markdown page with that the users can add to with pull requests.
  • An even easier one is to just define a repository name pattern (e.g. marp-theme-[name] and ask theme designers to use it in the theme documentation. So marp themes can be searched in github itself.

Porting typesetting parsing from markdown-it-katex to remove dependency

We're using markdown-it-katex plugin to support math typesettings (#11). However, it is not maintained by author.

In marp-core, markdown-it-katex parses math typesettings from Markdown, but renderer is overridden by own implements to be able to use the latest KaTeX for rendering.

In this case, JS bundler on the dependented projects like marp-web is going to try to bundle 2 KaTeX versions, provided by markdown-it-katex and marp-core. It means that bundled size would increase about 300 KiB.

Currently we can avoid double-bundling by using yarn resolutions (#40), but it does not propagate to dependented packages. The best solution is removing markdown-it-katex from dependencies.

Tasks

Make built-in theme customization easy through CSS variables

Continue from marp-team/marp#48. Marp built-in themes are made by Sass and some themes are using mixin-based color scheme definition.
https://github.com/marp-team/marp-core/tree/master/themes

However it makes difficult to change theme color through tweaking style by <style> because some color schemes are defined as Sass variables. Some users are confusing to the fact that still require Sass compiler just for customize colors (marp-team/marp#73).

So must be better to move into using CSS variables. The legacy browser that has not supported CSS variables is already no longer required to consider.

โš ๏ธ This migration may make broken the look of exist Marp slides so this change must be the major update.

ToDo

  • Default theme (v3)
  • Gaia theme (v2.0.0)
  • Uncover theme (v2.0.0)

Vertical fit

I use marp for a lot of programming related presentations but sometimes what happens is that slides get too long vertically. The elements adjust well based on horizontal line size but I can't figure out a way to do this from reading all the docs and example decks.

Sometimes I end up removing titles and other text to push to another slide but I think I'd prefer it if it scales the slide vertically over having a cut out at the top and bottom.

MathJaX v3 support

Hi there, I am author of the following plugins

As I'd like to use MathJaX v3 in map-core, I open this issue. MathJaX v3 has a new plugin for bussproofs missing in the older versions, and also, has a SVG rendering without any fonts. There is good conformance for your project at the SVG feature.

I've already implemented markdown-it plugin with TypeScript based on markdown-it-katex as like marp-core. Thus, I can add MathJaX plugin to your project immediately.

I'd like to ask you, which options do you choose?

  1. Replacing KaTeX plugin with MathJaX plugin
  2. Adding MathJaX plugin, and keeping KaTeX plugin

Thanks!

Expose selected size to the parent of each slide

This idea came from #134.

By exposing selected size as data attribute of <section> slide container, theme author can change style by size.

---
theme: xxx
size: A4
---

# Hello!
<section data-size="A4">
  <h1>Hello!</h1>
</section>
/*!
 * @theme xxx
 * @size 4:3 960px 720px
 * @size A4 210mm 297mm
 */

section {
  /* Default style (16:9) */
}

section[data-size="4:3"] {
  /* Style for 4:3 slide */
}

section[data-size="A4"] {
  /* Style for A4 slide */
}

It might be better to work at Marpit framework, to expose the value of global directives as like as local directives.

Combining Slides from Marp with existing PDF

I don't think this feature exists, and I think it would be very helpful.

I have an existing lecture slide. I wish I could use Marp, which I currently do via VS Code, to write my own notes on top of the existing PDF. The nodes would be new slide pages. I imagining it could work something like this.

With the theme and other options within a MD file, I could point to an existing PDF.

Then, as we write an new slide page, we could have some special tag on it to determine how and where that slide would be added. For instance, we inform a page number, and if that slide should be added before or after that page number.

The page number references would be relative to the original slides.

Then, as we compile from .md to .pdf we would mix both original slides and the nodes we are adding.

Maybe another tag to remove a certain page, or page ranges could also be helpful.

What are your thoughts on that? Do you think that is helpful? Is that something already exists and I just did a bad search?

Code block autoscaling does not work properly

Thanks for creating Marp!
I've started using Marp and faced some issues with code auto-scaling with all themes:

  • The default theme results in part of title and the last sentence to be chopped off because of bad positioning:
    image
  • The gaia theme results in part of code block and the last sentence to chopped off because of bad scaling:
    image

Here are the global setting on my slides:

marp: true
paginate: true
theme: gaia
class: invert

My code slide source:

---
# Chunks
\```
-------------------------------------------------------------------
|        MagicNumber(4b)        |           version(1b)           |
-------------------------------------------------------------------
|         block-1 bytes         |          checksum (4b)          |
-------------------------------------------------------------------
|         block-2 bytes         |          checksum (4b)          |
-------------------------------------------------------------------
|         block-n bytes         |          checksum (4b)          |
-------------------------------------------------------------------
|                        #blocks (uvarint)                        |
-------------------------------------------------------------------
| #entries(uvarint) | mint, maxt (varint) | offset, len (uvarint) |
-------------------------------------------------------------------
| #entries(uvarint) | mint, maxt (varint) | offset, len (uvarint) |
-------------------------------------------------------------------
| #entries(uvarint) | mint, maxt (varint) | offset, len (uvarint) |
-------------------------------------------------------------------
| #entries(uvarint) | mint, maxt (varint) | offset, len (uvarint) |
-------------------------------------------------------------------
|                      checksum(from #blocks)                     |
-------------------------------------------------------------------
|                    #blocks section byte offset                  |
-------------------------------------------------------------------
\```
`mint` and `maxt` describe the minimum and maximum Unix nanosecond timestamp, respectively.

Stop auto detection of syntax highlight language

By the historical background, Marp has detected the language for syntax highlight in the code block automatically until now.

```
const a = 1
```

However, this behavior is a bit confusable because the other services using Markdown have not colored the plain code block. e.g. marp-team/marp-vscode#12 had mentioned to this problem.

In addition, recently we've recieved the potential ReDOS vulnerabilities in GHSA-7wwv-vh3v-89cq (Fix in #201). Using highlightAuto may be vulnerable.

return highlightjs.highlightAuto(code).value

Thus, we have to consider stopping auto detection of syntax highlight language.

This change will break existed slides, and affected user should specify the language manually. But I think this is a natural behavior as Markdown.

Chrome 81 for macOS gets thin font

Description

The latest Chrome 81 for macOS may get always thinner font than previous version.

For example, the exported PDF, PPTX and image from Markdown which is using Marp Core's default theme has clearly difference the thickness of font than VS Code's preview (Rendered by a bit older Chromium).

default theme and uncover theme are affected this regression. We can stop using BlinkMacSystemFont as a temporally workaround to mitigate this, but it will have breaking change of rendered font in macOS (San Fransico font cannot use through font-family: "San Fransico").

It's a difficult to determine which of options: Allow breaking change of the font in macOS to keep reproducibility in all tools, or wait to fix in the upstream Chrome / Chromium.

This regression actually affects a lot of sites, includes GitHub. If you are using Chrome 81 in macOS (Catalina), the header of this issue "Description" should have thinner font than in the other browser.

References

Import/Include content from other files. Slide grouping and organization.

Hello Marp-Team

Is there a way to include the content of other markdown files into the current one?

I use Marp via the VS Code extension, and my presentations can get quite big and hard to manage slides, their order, maybe group them, etc.

I imagine that by being able to import the content of another presentation into the current one would help me with this.

Is there such a think in marp? Or, are you planning on adding a similar feature in the future?

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.