Skip to content
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

Type setting for theme metadata #170

Closed
4 tasks done
yhatt opened this issue Jun 14, 2019 · 0 comments · Fixed by #171
Closed
4 tasks done

Type setting for theme metadata #170

yhatt opened this issue Jun 14, 2019 · 0 comments · Fixed by #171
Labels
enhancement New feature or request

Comments

@yhatt
Copy link
Member

yhatt commented Jun 14, 2019

We are considering to support type setting for theme metadata specified in the metaType option in Theme#fromCSS, ThemeSet#add, and ThemeSet.metaType member.

Currently theme metadata only allows a single value. This behavior is very natural because Marpit only requires @theme metadata.

But in the extended class as like as Marp Core, there may be the meta key want to allow multi-time definitions. Thus, we should accept metaType option when creating Theme instance.

It is an object that has a key as the name of metadata and a value as the specified type which of String or Array. We will parse meta as String by default, included undefined meta key. The user has to set Array if the theme allows multi-time definitions in same meta key.

/**
 * @theme example
 * @foo Single value
 * @foo allows only one string
 * @bar Multiple value 1
 * @bar Multiple value 2
 * @bar Multiple value 3
 */
const themeSet = new ThemeSet()

themeSet.metaType = {
  foo: String,
  bar: Array,
}

themeSet.add(css)

console.log(themeSet.getThemeMeta('example', 'foo'))
// => 'allows only one string'

console.log(themeSet.getThemeMeta('example', 'bar'))
// => ['Multiple value 1', 'Multiple value 2', 'Multiple value 3']

It requires in proposed marp-team/marp-core#91: The proposed @size metadata requires multi-time definitions.

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

ToDo

  • Allow metaType option value in Theme#fromCSS
  • [ ] Allow metaType option value in ThemeSet#add
    • Typically using theme with different type definitions would make confusion. Option argument to override metatype had better not allow.
  • Add metaType member in ThemeSet class to set the default type setting for ThemeSet#add
  • Reserve @theme metadata as String and disallow changing type
  • [ ] Support merging array in ThemeSet#getThemeProp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant