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

Added support for plaintext #2738

Merged
merged 3 commits into from
Mar 5, 2021
Merged

Conversation

RunDevelopment
Copy link
Member

This came up in #2665:

Right now, we use language-none (or just none) to mean "no language" but that has actually two meanings. "No language" could mean either plaintext or that the language is undefined/unknown. These two distinct concepts are both represented by none.

This is a problem when language detection comes into play. A code block with no (defined) language will get language none by default, so the language detector can do its job. But what happens for a plaintext code block? The user will use the language-none class to indicate plaintext. But these two cases are indistinguishable from the perspective of the language detector.

The simple solution for this problem is to split none into two languages: none and plain.
From now on, none only represents an undefined/unknown language and plain will represent plaintext.

This solves the problem has some additional advantages as well. Since none has no grammar, plugins like Show Invisibles cannot be used. plain will have an empty grammar, so plugins like SI will work.


I'm also thinking about giving plain some aliases like plaintext, plain-text, text, and txt but this will make the implementation less simple.

@github-actions
Copy link

github-actions bot commented Jan 25, 2021

JS File Size Changes (gzipped)

A total of 2 files have changed, with a combined diff of +27 B (+0.5%).

file master pull size diff % diff
components/prism-core.min.js 3.03 KB 3.04 KB +15 B +0.5%
plugins/show-language/prism-show-language.min.js 2.27 KB 2.28 KB +12 B +0.5%

Generated by 🚫 dangerJS against b6ad5d7

@joshgoebel
Copy link

I'm also thinking about giving plain some aliases like plaintext, plain-text, text, and txt but this will make the implementation less simple.

Just FYI in Highlight.js we named the grammar 'plaintext' and have aliases for txt and text.

@RunDevelopment
Copy link
Member Author

I'm also thinking about giving plain some aliases like plaintext, plain-text, text, and txt but this will make the implementation less simple.

Just FYI in Highlight.js we named the grammar 'plaintext' and have aliases for txt and text.

Thanks for the info! In that case, I'll add the aliases.

@RunDevelopment RunDevelopment merged commit 970674c into PrismJS:master Mar 5, 2021
@RunDevelopment RunDevelopment deleted the core-plain branch March 5, 2021 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants