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

text vs plaintext vs pgsql #1001

Closed
bcmadsen opened this issue Jan 24, 2023 · 5 comments
Closed

text vs plaintext vs pgsql #1001

bcmadsen opened this issue Jan 24, 2023 · 5 comments

Comments

@bcmadsen
Copy link

bcmadsen commented Jan 24, 2023

I finally got curious enough about why "```text" turned into "```plaintext" between MM v1 and MM v2 when escaping blocks of text, and so I have been Googling what makes them different. I came upon this link -- github-linguist/linguist#5135 -- where the first comment asks the original poster why he's using anything after the backticks at all, since just enclosing text with three of them before and after is (he says) supposed to render the same as plain text.

That made logical sense to me, so I tried that, and I find that MM (both v1 and v2) is rendering that as "pgsql". And I had to Google that, because I didn't know what that meant -- and Google pointed me at PostgreSQL, for whatever reason. If "pgsql" is "PostgreSQL", and even if it isn't, I am surprised to find that that isn't one of the choices for Code Language when I use Alt-C or the menu bar to Insert and formatted source code snippet. In fact, I can't find a way to select "pgsql" as the code-formatting style except to avoid the Alt-C command altogether and just do three backticks (alone) myself by hand.

So I guess I have a handful of related questions:

  1. Is "pgsql" something that should be in the list of Code Snippets? If so, why isn't it? (Or: is it, and I'm just not looking for it under the right name?)
  2. Why does "```" by itself render as if it's "```pgsql"? Why doesn't that render the same way that "```text" and/or "```plaintext" do? (Is the commenter I cited above right to say that three backticks without a modifier should render as plain text?)
  3. Why did inserting text as "Text - no formatting" show up in MM v1 as "```text" but now shows up in MM v2 as "```plaintext"? I understand they're synonyms, but why is one preferred now but the other was preferred before? I assume that "```plaintext" has become the new preferred name for "```text", but why?
@RickStrahl
Copy link
Owner

RickStrahl commented Jan 25, 2023

MM uses highlightJS for its highlighter, and if you don't specify any syntax, it'll try to detect the language in use (which is not bad). I'm guessing the pgsql language is just a bad guess when no language is specified.

To force plain text you can use:

You can use:

```text
plain text here
```

The following all work this way:

  • text
  • plain
  • plaintext

as some platforms support combinations of those.

GitHub works with nothing after the backticks using plain ~~~ or ~~~~text. The following uses ~~~text:

int x = 10;
x++;
foreach(var i = 0; x < 10; x++) 
{
	Console.WriteLine(i + ". Line");
}

and that will work both in MM and on GitHub.

@RickStrahl
Copy link
Owner

So I guess the real question here is if MM should inherit the default highlighJS behavior of auto-detection, or explicitly set no language specified to text.

I think we could go either way on that, perhaps even with an option, but really it should probably match what GitHub does because that's the most likely target for deployment of the files.

Any special fixup with text only applies to Markdown Monster's preview or any explicit exports.

At the end of the day you probably want settings that match your end usage environment. For example, on my blog I use highlightJS as well, so I would want to match the behavior.

@bcmadsen
Copy link
Author

bcmadsen commented Feb 1, 2023

Since I don't publish to GitHub, the GitHub behavior is not something I depend on or would miss if it went away. I do like the idea of three backticks without a modifier defaulting to displaying as plain text. (Also, I didn't realize before this that three tildes behave like three backticks, so that's good to know.)

Part of me thinks it would be ideal to ask for a MM setting that would give me the "if I don't specify anything, then please default to: " behavior, but if I'm the only one who would use it, I'd feel funny asking for it.

Bottom line: I guess, stick with things the way they are, and I'll know to expect that that's how it works. At its core, my question really was just a question -- how does MM work, and why is it the way it is? -- and you've answered that for me (so, thank you!). In other words, I didn't come here asking for anything to change, and there isn't (in my mind) any bug or issue that needs to be resolved.

@RickStrahl
Copy link
Owner

Realistically you should be as precise as possible so specifying text after the three backticks is the way to go regardless. This will make sure it work everywhere.

I'm considering switching the behavior to not auto-detect, because frankly it's often wrong (as you found out). Given GitHub doesn't auto-detect it would make sense to just default to text on empty.

Regardless I still recommend using text 😄

@RickStrahl RickStrahl self-assigned this Feb 3, 2023
@RickStrahl
Copy link
Owner

So I added logic to render as plain text when no code language is provied.

image

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