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

fix: replaced \n with html <br> tags #869

Conversation

DhairyaMajmudar
Copy link
Member

@jdesrosiers
Copy link
Member

This is the wrong solution. I should be able to write markdown in the "bio" property. Markdown should not include HTML. This is just hacking around the problem.

@DhairyaMajmudar DhairyaMajmudar deleted the fix/contractor.json branch January 28, 2025 05:18
@benjagm
Copy link
Collaborator

benjagm commented Jan 28, 2025

Hi everyone. As far as I know, \n is not Markdown. Right?

As per the Markdown standard, linebreaks can be implemented with backslash or 2 or more spaces. \n is to me another way of hacking around the problem.

https://spec.commonmark.org/0.31.2/#hard-line-breaks

@jdesrosiers
Copy link
Member

\n is just how a newline is represented in a JSON string.

For example, here's some markdown in plain text.

# Title

This is a text block.

Here's another block of text.

Now here's the same markdown encoded as JSON.

"# Title\n\nThis is a text block.\n\nHere's another block of text.\n"

And the same markdown encoded as YAML.

bio: |
  # Title
  
  This is a text block.
  
  Here's another block of text.

These are all different encodings of the exact same thing. Once the the JSON or YAML is parsed, these three are identical. \n isn't something you normally visually see in a plaintext markdown file, but they're are lots of them in there. It's just that in plaintext, you see what the newline represents (a new line), but in JSON, you just see the character that represents a new line.

@benjagm
Copy link
Collaborator

benjagm commented Jan 29, 2025

How other text styles are applied in a JSON String? For example, If you like to add bold text or links in your Bio.

@jdesrosiers
Copy link
Member

I think you're confused. It sounds like you're talking about a JSON string as some sort of alternative to markdown syntax. The three examples I showed are all markdown. They can have any markdown syntax in them. The difference between the three examples is how the markdown is encoded and written in a file.

The first example is the markdown stored as plaintext, which has no structure or formatting. That's usually have markdown is stored and what you're familiar with.

The second example is the markdown stored as a JSON string, which surrounds the text in quotes ("). This is just a string literal like you would find in any programming language. You can't have newlines in a string literal, so you have use \n instead. You can't have " because it would be confused for the marker for the end of the string literal, so you have to use \" ("a \"quoted\" example"). This is just the representation in the file. Once you parse the JSON, the \n are normal newlines and the \"s become just ". It's the same markdown as in the plaintext file. It's not just equivalent to the markdown in the plaintext file. It is the same markdown.

The third example is the markdown stored as YAML. YAML has syntax for expressing a string with newlines and without characters that need to be escaped so it's nicer to read and write. That string contains markdown just like the JSON example. Once you parse the YAML string, you get the same markdown as the plaintext file.

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

Successfully merging this pull request may close these issues.

3 participants