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

BNF #1402

Closed
Jedore opened this issue Dec 21, 2018 · 4 comments
Closed

BNF #1402

Jedore opened this issue Dec 21, 2018 · 4 comments
Labels

Comments

@Jedore
Copy link

Jedore commented Dec 21, 2018

Does marked support BNF, EBNF ?

@UziTech
Copy link
Member

UziTech commented Dec 21, 2018

Are you asking about code highlighting?

Marked doesn't do any highlighting but you can add a highlighter in the options

@Jedore
Copy link
Author

Jedore commented Dec 21, 2018

Yeah, I use highlight.js, but met a problem.
And I use https://cdnjs.cloudflare.com/ajax/libs/marked/0.5.2/marked.min.js in my Django template file

let renderer = new marked.Renderer();
marked.setOptions({
    renderer: renderer,
    breaks: true,
    smartLists: true,
});
let html =  marked(text);

When I use BNF like

```bnf
name ::= identifier
```

Marked converts above markdown string to html with class attributes like

<pre><code class="language-bnf">name ::= identifier</code></pre>

but without hljs it seems to be invalid.
If set langPrefix to '', I got

<pre><code class="bnf hljs nginx"><span class="hljs-attribute">name</span> ::= identifier</code></pre>

why ?
Then I try set langPrefix to default value with null markdown string

```bnf
```

and I got

<pre><code class="bnf hljs"></code></pre>

So I don't understand ... Thanks @UziTech

@UziTech
Copy link
Member

UziTech commented Dec 21, 2018

but without hljs it seems to be invalid.

What seems to be invalid, the HTML that is output by marked?

Whatever hljs does with the HTML is not controlled by marked. This might be a question for highlight.js instead.

@Jedore
Copy link
Author

Jedore commented Dec 21, 2018

uh... You're right, I thought hljs is controlled by Marked.
Thanks.

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

No branches or pull requests

2 participants