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

feat(markdown): support text language for code block style without any highlighting #875

Merged
merged 1 commit into from Jul 27, 2018

Conversation

endiliey
Copy link
Contributor

@endiliey endiliey commented Jul 27, 2018

Motivation

Close #874

Currently, highlight.js supported languages and prism.js supported languages does not support text language

Our current logic for unsupported prism.js / highlight.js language is that we try to detect the language automatically with this code below:
https://github.com/facebook/Docusaurus/blob/75538395beb3bcd7591f586877d5971c51d4f5db/lib/core/renderMarkdown.js#L57-L59

Hence, there is no way for user to remove any highlighting for code block defined like this
test

It will be detected as JavaScript although it has been tagged as 'text' by user
This PR enables user to have code block style without any highlighting by using text language

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan


---
title: EXAMPLE
---

```text
function $initHighlight(block, cls) {
  try {
    if (cls.search(/\bno\-highlight\b/) != -1)
      return process(block, true, 0x0F) +
             ` class="${cls}"`;
  } catch (e) {
    /* handle exception */
  }
  for (var i = 0 / 2; i < classes.length; i++) {
    if (checkCondition(classes[i]) === undefined)
      console.log('undefined');
  }
}

export  $initHighlight;
```

```js
function $initHighlight(block, cls) {
  try {
    if (cls.search(/\bno\-highlight\b/) != -1)
      return process(block, true, 0x0F) +
             ` class="${cls}"`;
  } catch (e) {
    /* handle exception */
  }
  for (var i = 0 / 2; i < classes.length; i++) {
    if (checkCondition(classes[i]) === undefined)
      console.log('undefined');
  }
}

export  $initHighlight;
```

Before
before

After
after

@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-preview ready!

Built with commit cebddb7

https://deploy-preview-875--docusaurus-preview.netlify.com

@endiliey endiliey merged commit a6db22b into facebook:master Jul 27, 2018
@endiliey endiliey deleted the highlight branch July 27, 2018 17:55
@bettiolo
Copy link

Confirmed fixed: bettiolo/docusaurus-hl-bug@c4bdc4d

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

Successfully merging this pull request may close these issues.

None yet

4 participants