0

Whilst posting an answer on SO, I noticed that code sample formatting did not work correctly when posting snippets of code in numbered or order lists. For example:

  1. Point one

    public class TwitterConnection { private string _consumerKey = ConfigurationManager.AppSettings.Get("consumerKey"); private string _consumerSecret = ConfigurationManager.AppSettings.Get("consumerSecret"); private string _accessKey = ConfigurationManager.AppSettings.Get("accessToken"); private string _accessToken = ConfigurationManager.AppSettings.Get("accessTokenSecret");

        private IHubContext _context = GlobalHost.ConnectionManager.GetHubContext<TwitterHub>();
    
        public TwitterConnection()
        {
            // Access the filtered stream
            var filteredStream = Stream.CreateFilteredStream();
    
            filteredStream.MatchingTweetReceived += (sender, args) => 
            { 
                _context.Clients.All.broadcast(args.Tweet.Text);
            };
    
            filteredStream.StartStreamMatchingAllConditions();
    
        }
    

    }

    1. Point two

As you can see, the code sample feature does not work when included in a list. Does anyone know of any way around this? Or am I just being stupid?

Feel free to edit, to try and replicate the bug

1
  • 2
    In code lists, you need 4 extra spaces. Commented Apr 19, 2015 at 19:19

1 Answer 1

5

Just remember you need extra indentation for the numbered list.

Your example, quoted and corrected:

Whilst posting an answer on SO, I noticed that code sample formatting did not work correctly when posting snippets of code in numbered or order lists. For example:

  1. Point one

    public class TwitterConnection {
            private string _consumerKey = ConfigurationManager.AppSettings.Get("consumerKey");
            private string _consumerSecret = ConfigurationManager.AppSettings.Get("consumerSecret");
            private string _accessKey = ConfigurationManager.AppSettings.Get("accessToken");
            private string _accessToken = ConfigurationManager.AppSettings.Get("accessTokenSecret");
    
            private IHubContext _context = GlobalHost.ConnectionManager.GetHubContext<TwitterHub>();
    
            public TwitterConnection()
            {
                // Access the filtered stream
              var filteredStream = Stream.CreateFilteredStream();
    
              filteredStream.MatchingTweetReceived += (sender, args) => 
              { 
                  _context.Clients.All.broadcast(args.Tweet.Text);
              };
    
              filteredStream.StartStreamMatchingAllConditions();
    
            }
    }
    

  1. Point two

As you can see, the code sample feature does not work when included in a list. Does anyone know of any way around this? Or am I just being stupid?

Feel free to edit, to try and replicate the bug

The source:

Whilst posting an answer on SO, I noticed that code sample formatting did not work correctly when posting snippets of code in numbered or order lists. For example:

 1. Point one

        public class TwitterConnection {
                private string _consumerKey = ConfigurationManager.AppSettings.Get("consumerKey");
                private string _consumerSecret = ConfigurationManager.AppSettings.Get("consumerSecret");
                private string _accessKey = ConfigurationManager.AppSettings.Get("accessToken");
                private string _accessToken = ConfigurationManager.AppSettings.Get("accessTokenSecret");

                private IHubContext _context = GlobalHost.ConnectionManager.GetHubContext<TwitterHub>();

                public TwitterConnection()
                {
                    // Access the filtered stream
                    var filteredStream = Stream.CreateFilteredStream();

                    filteredStream.MatchingTweetReceived += (sender, args) => 
                    { 
                        _context.Clients.All.broadcast(args.Tweet.Text);
                    };

                    filteredStream.StartStreamMatchingAllConditions();

                }
        }

<!-- -->

2. Point two 


As you can see, the code sample feature does not work when included in a list. Does anyone know of any way around this? Or am I just being stupid?

Feel free to edit, to try and replicate the bug

As an aside, the indentation seems funky.

6
  • 1
    Why is it like that? That's very unpractical. For example, this post had that issue, and I had to add four spaces on each line by hand since CTRL+K only adds/removes the first four spaces on each line. Can we get this fixed? Commented Jan 14, 2017 at 9:54
  • Consider using a trick: Adding a letter so you can use the indent-feature. And if you want to change it, describe exactly how it should work instead in a feature-request. It gets... far more complicated. Commented Jan 14, 2017 at 21:14
  • Why would it be more complicated? Wouldn't it work if four spaces at the beginning of a line just meant that it's code, no matter if it's in a list or not? Commented Jan 14, 2017 at 21:55
  • 1
    @DonaldDuck: Then how would you put a list in a list? Commented Jan 14, 2017 at 22:41
  • That's a good point. I found a feature request for fixing this issue here. Commented Jan 15, 2017 at 11:23
  • yeah it's really annoying .... still not fixed. For example when you start to write something without even hitting the list button - like 1. something and then you want to use a code formatting in the new line, it simply doesn't work Commented Sep 18, 2021 at 19:51

Not the answer you're looking for? Browse other questions tagged .