facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
56.73k stars 8.54k forks source link

Out-of-the-box syntax highlighting is broken for at least Java, PHP, & Ruby. #4535

Closed flossypurse closed 3 years ago

flossypurse commented 3 years ago

šŸ› Bug Report

Out-of-the-box syntax highlighting is broken for at least Java, PHP, & Ruby.

There may be others...

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

Yes.

To Reproduce

If possible, use https://new.docusaurus.io to create a CodeSandbox reproducible demo of the bug.

Sandbox didn't work. Received a docusaurus not found error when I tried to save changes, even after logging in.

(Write your steps here:)

  1. Do a fresh install of Docusuarus using the classic theme, i.e.:

npx @docusaurus/init@latest init my-website classic

  1. Add java, php, or ruby code to a Markdown page, such as:

Java:

import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowInterface;
import io.temporal.workflow.WorkflowMethod;
import org.slf4j.Logger;

public class GettingStarted {

    private static Logger logger = Workflow.getLogger(GettingStarted.class);

    @WorkflowInterface
    public interface HelloWorld {
        @WorkflowMethod
        void sayHello(String name);
    }

    public static class HelloWorldImpl implements HelloWorld {

        @Override
        public void sayHello(String name) {
            logger.info("Hello " + name + "!");
        }
    }
}

PHP:

#[ActivityInterface("file_activities.")]
interface FileProcessingActivities
{
    public function upload(string $bucketName, string $localName, string $targetName);

    #[ActivityMethod("transcode_file")]
    public function download(string $bucketName, string $remoteName);

    public function processFile(): string;

    public function deleteLocalFile(string $fileName);
}

Ruby:

class AsyncActivity < Temporal::Activity
  timeouts start_to_close: 120

  def execute
    logger.warn "run `bin/activity complete #{activity.async_token}` to complete activity"

    activity.async
  end
end
  1. Run a local server to view the site.

Expected behavior

Code examples specified with a code type should have code specific syntax highlighting for popular languages like PHP, Ruby, and Java.

Actual Behavior

There is NO syntax highlighting for some langauges. It works for some like Go and Javascript. But not all. See screen shots:

Source: Screen Shot 2021-03-29 at 4 24 06 PM

Built site: Screen Shot 2021-03-29 at 4 24 53 PM

Your Environment

But some testing revealed issues starting with 2.0.0-alpha.68 I am using 2.0.0-alpha.66 which works find

Reproducible Demo

If possible, use https://new.docusaurus.io to create a CodeSandbox reproducible demo of the bug.

That did not work for me - Just do a fresh install and see for yourself - takes 1 min.

Josh-Cena commented 3 years ago

According to the docusaurus doc,

By default, Docusaurus comes with this subset of commonly used languages.

Which doesn't include Java, PHP, or Ruby. You have to manually include them in the config.

I have encountered the same thing, and I wonder why they didn't choose these languages to support out-of-the-box...

flossypurse commented 3 years ago

Ah, yes just figuring this out. The thing is - those languages used to be included by default. I was confused because we upgraded our site, and discovered that some of the languages stopped working...

Appreciate it @Josh-Cena Thank you!