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

Display bug in line numbering #1886

Closed
webmozart opened this issue Nov 4, 2012 · 14 comments
Closed

Display bug in line numbering #1886

webmozart opened this issue Nov 4, 2012 · 14 comments
Labels

Comments

@webmozart
Copy link
Contributor

When a code block has more than one digit in its line numbers, the display in the docs currently breaks for Google Chrome 22.0.1229.94 under Ubuntu 12.10:

http://i47.tinypic.com/1zg89xf.png

(http://symfony.com/doc/current/components/dependency_injection/types.html)

The issue can be fixed by increasing the width of td.linenos from 35px to 36px. The min-width should probably be adjusted too.

With three digit line numbers, the display breaks again. The minimum width that works here for "999" is 44px.

On a related note: YAML and XML snippets are missing line numbers.

@wouterj
Copy link
Member

wouterj commented Nov 4, 2012

I had this issue too some weeks ago. It is fixed in Chrome 24, which I use now, and I think in chrome 23 too. I use a windows PC.

@webmozart
Copy link
Contributor Author

Ah ok. What about line numbers in YAML and XML on that page?

@wouterj
Copy link
Member

wouterj commented Dec 17, 2012

I have highlighting issues as well. For instance, the php+html blocks aren't highlighted: http://symfony.com/doc/current/contributing/code/standards.html

weaverryan added a commit that referenced this issue Dec 18, 2012
@weaverryan
Copy link
Member

I did a bunch of browser screens of this, and yea, it looks like it basically affects just Chrome 21 & Chrome 22 and some of the IE browsers. So, I'm not sure how much this really matters, but I do see that td.linenos seems to actually need 37px of space and we're giving it only 35px. Most browsers are smart enough to figure it out... just not a few.

@wouterj for php+html, I'm just not sure that it's a valid format - it's only used on one place, so I removed it at sha: 23d2961 - should fix the issue :).

@wouterj
Copy link
Member

wouterj commented Dec 18, 2012

@weaverryan from what I can see, it is: https://github.com/fabpot/sphinx-php/blob/master/sensio/sphinx/configurationblock.py#L28

But Yaml highlighting doesn't work all times too.

@weaverryan
Copy link
Member

It might just be a CSS issue for things like php+html, but there's really no reason to have both formats anyways. If you still see a few spots where highlighting isn't working, we should hunt those down and figure out why.

@webmozart
Copy link
Contributor Author

So can we adjust the width of the line numbers? For Debian-based Linuxes, Chrome 22 currently seems to be the only option (I failed to install a newer one on Ubuntu 12.10).

@wouterj
Copy link
Member

wouterj commented Dec 25, 2012

Another place where syntax highlighting is missing: http://symfony.com/doc/current/book/forms.html#form-theming (the second code block)

It uses the html+jinja format. From the above comment of @weaverryan, I concluded that it should be jinja+html. But I think it isn't the problem.

The first and second code block in this example uses the same formats, I can't find any difference between them. However, the first gets highlighting and the second doesn't.

@wouterj
Copy link
Member

wouterj commented Feb 25, 2013

I have indexed all not working code blocks in the book: https://gist.github.com/WouterJ/5029110

From that, I think I can conclude the following: Code blocks are not highlighted if they contain invalid mark-up, or are not indented the way it should be done

For instance:

  • Yaml code blocks with % and @ outside quotes aren't highlighted because these are reserved characters in Yaml. We should find all code blocks containing this invalid markup and put them inside quotes. For instance:

       .. code-block:: yaml
    
           # app/config/config.yml
           parameters:
               my_mailer.class:      Acme\HelloBundle\Mailer
               my_mailer.transport:  sendmail
    
           services:
               my_mailer:
                   class:        "%my_mailer.class%"
                   arguments:    [%my_mailer.transport%]

    should become:

       .. code-block:: yaml
    
           # app/config/config.yml
           parameters:
               my_mailer.class:      Acme\HelloBundle\Mailer
               my_mailer.transport:  sendmail
    
           services:
               my_mailer:
                   class:        "%my_mailer.class%"
                   arguments:    ["%my_mailer.transport%"]
  • XML/HTML/Twig code blocks which use ... to fold some attributes causes the parser to not highlight it because that is invalid markup. We can do 2 things:

    Removing the ...

       .. code-block:: xml
    
           <!-- app/config/config.xml -->
           <framework:config>
               <!-- ... -->
               <framework:router resource="%kernel.root_dir%/config/routing.xml" />
           </framework:config>

    Put ... in a comment

       .. code-block:: xml
    
           <!-- app/config/config.xml -->
           <framework:config <!-- ... -->>
               <!-- ... -->
               <framework:router resource="%kernel.root_dir%/config/routing.xml" />
           </framework:config>

    or, what I like more:

       .. code-block:: xml
    
           <!-- app/config/config.xml -->
           <framework:config
               <!-- ... -->
           >
               <!-- ... -->
               <framework:router resource="%kernel.root_dir%/config/routing.xml" />
           </framework:config>

This means that this isn't a website issue, but a code issue. That means that this issues shouldn't get the website label, but should get labeled with easy pick or actionable (@weaverryan )

@stof
Copy link
Member

stof commented Feb 25, 2013

note that <!-- ... --> cannot be used inside the tag attributes for XML as you cannot start a tag there.

@wouterj
Copy link
Member

wouterj commented Feb 25, 2013

@stof thank you, that means we should remove the ... completely (but I don't like that). @weaverryan do you have some other suggestions?

@cordoval
Copy link
Contributor

cordoval commented Jan 6, 2014

@wouterj i cannot gather what is it that is left to do in this issue, could you please summarize? thanks

@wouterj
Copy link
Member

wouterj commented Jan 7, 2014

my last comment is what is left. All highlighting-breaking characters should be removed, or placed in quotes.

weaverryan added a commit that referenced this issue Jan 21, 2014
…ghting (xabbuh)

This PR was merged into the 2.3 branch.

Discussion
----------

enclose YAML string with double quotes to fix syntax highlighting

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | all
| Fixed tickets | #1886

as mentioned by @ifdattic in #3467

Commits
-------

24be690 enclose YAML string with double quotes to fix syntax highlighting
weaverryan added a commit that referenced this issue Jan 22, 2014
This PR was merged into the 2.3 branch.

Discussion
----------

Fix highlighting

Initial idea was to fix the highlighting. While doing that, others things
also got a fix:

* indenting
* missing formats
* some `...` in XML elements
* missing comments in other formats

| Q   | A
| --- | ---
| Doc fix? | yes
| New docs? | no
| Applies to | all
| Fixed tickets | partially #1886

Commits
-------

7c0cf89 Fixed (mostly) yaml code blocks
2a43a97 Fixed YAML code blocks in the book
weaverryan added a commit that referenced this issue Jul 29, 2014
This PR was merged into the 2.3 branch.

Discussion
----------

enclose YAML strings containing % with quotes

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | all
| Fixed tickets | #1886, #4029

Thanks @iamdto, did you spot some other occurences in the docs?

Commits
-------

c1c4bc8 remove "..." from XML element tags
dbc02a2 quote YAML strings starting with % or @ characters
@javiereguiluz
Copy link
Member

@wouterj I've checked some of the links that you compiled here: https://gist.github.com/WouterJ/5029110 and the highlighting is indeed wrong for 2.0 version but it's OK for 2.3 and higher versions.

Given that any pre 2.3 version is no longer supported, we can safely close this issue because fixing 2.0, 2.1 and 2.2 is a won't fix.

Thank you all for reporting and fixing these highlighting errors.

@wouterj wouterj closed this as completed Sep 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants