question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[YAML Highlight] # inside strings is treated as comment

See original GitHub issue

In YAML, the # for comments can appear inside strings which are enclosed with " or '

Github formatting:

# comment
foo: "#bar"
foo: "bar"

Prism: image

I understand it is because https://github.com/PrismJS/prism/blob/gh-pages/components/prism-yaml.js#L7 is too greedy. But Im not sure how to change it. Would look behind for " or ' be sufficient?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
zeitgeist87commented, May 8, 2017

This should be fixed by #1095

0reactions
mjrussellcommented, Feb 9, 2017

Awesome to see some progress on this! Agree I had many issues with greedy behavior before so excited to see how @zeitgeist87’s tweaks work

Read more comments on GitHub >

github_iconTop Results From Across the Web

YAML - Comments - Tutorialspoint
Features of Comments​​ Comments must not appear inside scalars. YAML does not include any way to escape the hash symbol (#) so within...
Read more >
YAML: Do I need quotes for strings in YAML? - Stack Overflow
the YAML cookbook says: Enclosing strings in double quotes allows you to use escaping to represent ASCII and Unicode characters. Does this mean...
Read more >
Strings in YAML - To Quote or not to Quote | tinita [blogs.perl.org]
Any character except ' will be returned literally. You can not use escapes sequences here. ... So the # the end of the...
Read more >
How to use YAML nesting, lists, and comments in Ansible ...
Identify comments by using the hash ( # ) symbol. YAML strings can be represented within single or double quotes. For multiline strings,...
Read more >
Highlighting YAML comments correctly - Emacs Stack Exchange
s ?\t)) , as in: (defun yaml-mode-syntax-propertize-function (beg end) (save-excursion (goto-char beg) (while (search-forward "#" end t) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found