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

Default ability to add a language parameter to @markup #51

Open
tjbenton opened this issue Aug 5, 2014 · 3 comments
Open

Default ability to add a language parameter to @markup #51

tjbenton opened this issue Aug 5, 2014 · 3 comments

Comments

@tjbenton
Copy link

tjbenton commented Aug 5, 2014

I'm trying to use prism and I need the ability to pass a language param to the code

<div>
 <h3>Example</h3>
 <div class="example">
  {{ markup.example | safe }}
 </div>
 <h1>{{ state.name }}</h1>
 <pre><code class="language-{{ markup.lang }}">
{{ markup.escaped }}
 </code></pre>
</div>

I figured it could work something like this to make it simple.

@markup scss
...
@darcyclarke
Copy link
Member

You can already create a custom variable to pass information along to the templates if you want. Here's an example of a custom variable, custom parser and a custom template that would solve this.

Custom CSS/Comment:

// @lang scss

Custom JavaScript/Parser:

dss.parser( 'lang', function( i, line, block ) {
  return line;
});

Custom HTML/Template:

<h3>Example</h3>

<div class="example">
  {{ markup.example | safe }}
</div>

<h1>{{ state.name }}</h1>

<pre><code class="language-{{ lang }}">
  {{ markup.escaped }}
</code></pre>

As an aside: the @markup variable/implementation will be changing soon (and it will actually be using a similar format to what you mocked out). The plan is to support HTML, Markdown and Jade as default markup formats instead of just HTML (like we do right now).

Example:

// @markup html
//   <h1>A Header Example</h1>
// @markup jade
//   h1 A Header Example
// @markup markdown
//   # A Header Example

@darcyclarke
Copy link
Member

Further thought... this is definitely a custom parser situation. I'm going to write an example of how you can do this sometime over the next week but it is 100% possible to do right now if you took some time to investigate writing one yourself.

@tjbenton
Copy link
Author

tjbenton commented May 6, 2015

It is, I figured out how to customize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants